mirror of
https://github.com/bitwarden/browser.git
synced 2025-12-05 09:14:28 +01:00
neglected electron key service test cleanup
This commit is contained in:
parent
8d7e88ee29
commit
a60427a517
@ -13,11 +13,13 @@ import { UserKey } from "@bitwarden/common/types/key";
|
||||
import { BiometricStateService, KdfConfigService } from "@bitwarden/key-management";
|
||||
|
||||
import {
|
||||
makeSymmetricCryptoKey,
|
||||
FakeAccountService,
|
||||
mockAccountServiceWith,
|
||||
FakeStateProvider,
|
||||
makeSymmetricCryptoKey,
|
||||
mockAccountServiceWith,
|
||||
} from "../../../../libs/common/spec";
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import { VAULT_TIMEOUT } from "../../../../libs/common/src/key-management/vault-timeout";
|
||||
|
||||
import { DesktopBiometricsService } from "./biometrics/desktop.biometrics.service";
|
||||
import { ElectronKeyService } from "./electron-key.service";
|
||||
@ -40,11 +42,13 @@ describe("ElectronKeyService", () => {
|
||||
let accountService: FakeAccountService;
|
||||
let masterPasswordService: FakeMasterPasswordService;
|
||||
|
||||
beforeEach(() => {
|
||||
beforeEach(async () => {
|
||||
accountService = mockAccountServiceWith(mockUserId);
|
||||
masterPasswordService = new FakeMasterPasswordService();
|
||||
stateProvider = new FakeStateProvider(accountService);
|
||||
|
||||
await stateProvider.setUserState(VAULT_TIMEOUT, 10, mockUserId);
|
||||
|
||||
keyService = new ElectronKeyService(
|
||||
masterPasswordService,
|
||||
keyGenerationService,
|
||||
@ -79,38 +83,17 @@ describe("ElectronKeyService", () => {
|
||||
expect(biometricStateService.getBiometricUnlockEnabled).toHaveBeenCalledWith(mockUserId);
|
||||
});
|
||||
|
||||
describe("biometric unlock enabled", () => {
|
||||
beforeEach(() => {
|
||||
biometricStateService.getBiometricUnlockEnabled.mockResolvedValue(true);
|
||||
});
|
||||
it("sets biometric key when biometric unlock enabled", async () => {
|
||||
biometricStateService.getBiometricUnlockEnabled.mockResolvedValue(true);
|
||||
|
||||
it("sets null biometric client key half and biometric unlock key when require password on start disabled", async () => {
|
||||
biometricStateService.getRequirePasswordOnStart.mockResolvedValue(false);
|
||||
await keyService.setUserKey(userKey, mockUserId);
|
||||
|
||||
await keyService.setUserKey(userKey, mockUserId);
|
||||
|
||||
expect(biometricService.setBiometricProtectedUnlockKeyForUser).toHaveBeenCalledWith(
|
||||
mockUserId,
|
||||
userKey,
|
||||
);
|
||||
expect(biometricStateService.setEncryptedClientKeyHalf).not.toHaveBeenCalled();
|
||||
expect(biometricStateService.getBiometricUnlockEnabled).toHaveBeenCalledWith(mockUserId);
|
||||
});
|
||||
|
||||
describe("require password on start enabled", () => {
|
||||
beforeEach(() => {
|
||||
biometricStateService.getRequirePasswordOnStart.mockResolvedValue(true);
|
||||
});
|
||||
|
||||
it("sets biometric key", async () => {
|
||||
await keyService.setUserKey(userKey, mockUserId);
|
||||
|
||||
expect(biometricService.setBiometricProtectedUnlockKeyForUser).toHaveBeenCalledWith(
|
||||
mockUserId,
|
||||
userKey,
|
||||
);
|
||||
});
|
||||
});
|
||||
expect(biometricService.setBiometricProtectedUnlockKeyForUser).toHaveBeenCalledWith(
|
||||
mockUserId,
|
||||
userKey,
|
||||
);
|
||||
expect(biometricStateService.setEncryptedClientKeyHalf).not.toHaveBeenCalled();
|
||||
expect(biometricStateService.getBiometricUnlockEnabled).toHaveBeenCalledWith(mockUserId);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -9,3 +9,5 @@ export {
|
||||
VaultTimeoutStringType,
|
||||
} from "./types/vault-timeout.type";
|
||||
export { MaximumVaultTimeoutPolicyData } from "./types/maximum-vault-timeout-policy.type";
|
||||
// Only used by desktop's electron-key.service.spec.ts test
|
||||
export { VAULT_TIMEOUT } from "./services/vault-timeout-settings.state";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user