fix unit tests
This commit is contained in:
parent
5c090ce40d
commit
630eb14686
|
@ -23,7 +23,7 @@ import { FakeAccountService, mockAccountServiceWith } from "@bitwarden/common/sp
|
||||||
import { CsprngArray } from "@bitwarden/common/types/csprng";
|
import { CsprngArray } from "@bitwarden/common/types/csprng";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
import { MasterKey, UserKey } from "@bitwarden/common/types/key";
|
import { MasterKey, UserKey } from "@bitwarden/common/types/key";
|
||||||
import { KeyService } from "@bitwarden/key-management";
|
import { KeyService, UserAsymmetricKeysRegenerationService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { InternalUserDecryptionOptionsServiceAbstraction } from "../abstractions/user-decryption-options.service.abstraction";
|
import { InternalUserDecryptionOptionsServiceAbstraction } from "../abstractions/user-decryption-options.service.abstraction";
|
||||||
import { AuthRequestLoginCredentials } from "../models/domain/login-credentials";
|
import { AuthRequestLoginCredentials } from "../models/domain/login-credentials";
|
||||||
|
@ -52,6 +52,7 @@ describe("AuthRequestLoginStrategy", () => {
|
||||||
let billingAccountProfileStateService: MockProxy<BillingAccountProfileStateService>;
|
let billingAccountProfileStateService: MockProxy<BillingAccountProfileStateService>;
|
||||||
let vaultTimeoutSettingsService: MockProxy<VaultTimeoutSettingsService>;
|
let vaultTimeoutSettingsService: MockProxy<VaultTimeoutSettingsService>;
|
||||||
let kdfConfigService: MockProxy<KdfConfigService>;
|
let kdfConfigService: MockProxy<KdfConfigService>;
|
||||||
|
let userAsymmetricKeysRegenerationService: MockProxy<UserAsymmetricKeysRegenerationService>;
|
||||||
|
|
||||||
const mockUserId = Utils.newGuid() as UserId;
|
const mockUserId = Utils.newGuid() as UserId;
|
||||||
let accountService: FakeAccountService;
|
let accountService: FakeAccountService;
|
||||||
|
@ -87,6 +88,7 @@ describe("AuthRequestLoginStrategy", () => {
|
||||||
billingAccountProfileStateService = mock<BillingAccountProfileStateService>();
|
billingAccountProfileStateService = mock<BillingAccountProfileStateService>();
|
||||||
vaultTimeoutSettingsService = mock<VaultTimeoutSettingsService>();
|
vaultTimeoutSettingsService = mock<VaultTimeoutSettingsService>();
|
||||||
kdfConfigService = mock<KdfConfigService>();
|
kdfConfigService = mock<KdfConfigService>();
|
||||||
|
userAsymmetricKeysRegenerationService = mock<UserAsymmetricKeysRegenerationService>();
|
||||||
|
|
||||||
accountService = mockAccountServiceWith(mockUserId);
|
accountService = mockAccountServiceWith(mockUserId);
|
||||||
masterPasswordService = new FakeMasterPasswordService();
|
masterPasswordService = new FakeMasterPasswordService();
|
||||||
|
@ -116,6 +118,7 @@ describe("AuthRequestLoginStrategy", () => {
|
||||||
billingAccountProfileStateService,
|
billingAccountProfileStateService,
|
||||||
vaultTimeoutSettingsService,
|
vaultTimeoutSettingsService,
|
||||||
kdfConfigService,
|
kdfConfigService,
|
||||||
|
userAsymmetricKeysRegenerationService,
|
||||||
);
|
);
|
||||||
|
|
||||||
tokenResponse = identityTokenResponseFactory();
|
tokenResponse = identityTokenResponseFactory();
|
||||||
|
|
|
@ -38,7 +38,7 @@ import {
|
||||||
import { CsprngArray } from "@bitwarden/common/types/csprng";
|
import { CsprngArray } from "@bitwarden/common/types/csprng";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
import { UserKey, MasterKey } from "@bitwarden/common/types/key";
|
import { UserKey, MasterKey } from "@bitwarden/common/types/key";
|
||||||
import { KeyService } from "@bitwarden/key-management";
|
import { KeyService, UserAsymmetricKeysRegenerationService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { LoginStrategyServiceAbstraction } from "../abstractions";
|
import { LoginStrategyServiceAbstraction } from "../abstractions";
|
||||||
import { InternalUserDecryptionOptionsServiceAbstraction } from "../abstractions/user-decryption-options.service.abstraction";
|
import { InternalUserDecryptionOptionsServiceAbstraction } from "../abstractions/user-decryption-options.service.abstraction";
|
||||||
|
@ -120,6 +120,7 @@ describe("LoginStrategy", () => {
|
||||||
let billingAccountProfileStateService: MockProxy<BillingAccountProfileStateService>;
|
let billingAccountProfileStateService: MockProxy<BillingAccountProfileStateService>;
|
||||||
let vaultTimeoutSettingsService: MockProxy<VaultTimeoutSettingsService>;
|
let vaultTimeoutSettingsService: MockProxy<VaultTimeoutSettingsService>;
|
||||||
let kdfConfigService: MockProxy<KdfConfigService>;
|
let kdfConfigService: MockProxy<KdfConfigService>;
|
||||||
|
let userAsymmetricKeysRegenerationService: MockProxy<UserAsymmetricKeysRegenerationService>;
|
||||||
|
|
||||||
let passwordLoginStrategy: PasswordLoginStrategy;
|
let passwordLoginStrategy: PasswordLoginStrategy;
|
||||||
let credentials: PasswordLoginCredentials;
|
let credentials: PasswordLoginCredentials;
|
||||||
|
@ -144,6 +145,7 @@ describe("LoginStrategy", () => {
|
||||||
policyService = mock<PolicyService>();
|
policyService = mock<PolicyService>();
|
||||||
passwordStrengthService = mock<PasswordStrengthService>();
|
passwordStrengthService = mock<PasswordStrengthService>();
|
||||||
billingAccountProfileStateService = mock<BillingAccountProfileStateService>();
|
billingAccountProfileStateService = mock<BillingAccountProfileStateService>();
|
||||||
|
userAsymmetricKeysRegenerationService = mock<UserAsymmetricKeysRegenerationService>();
|
||||||
|
|
||||||
vaultTimeoutSettingsService = mock<VaultTimeoutSettingsService>();
|
vaultTimeoutSettingsService = mock<VaultTimeoutSettingsService>();
|
||||||
|
|
||||||
|
@ -172,6 +174,7 @@ describe("LoginStrategy", () => {
|
||||||
billingAccountProfileStateService,
|
billingAccountProfileStateService,
|
||||||
vaultTimeoutSettingsService,
|
vaultTimeoutSettingsService,
|
||||||
kdfConfigService,
|
kdfConfigService,
|
||||||
|
userAsymmetricKeysRegenerationService,
|
||||||
);
|
);
|
||||||
credentials = new PasswordLoginCredentials(email, masterPassword);
|
credentials = new PasswordLoginCredentials(email, masterPassword);
|
||||||
});
|
});
|
||||||
|
@ -484,6 +487,7 @@ describe("LoginStrategy", () => {
|
||||||
billingAccountProfileStateService,
|
billingAccountProfileStateService,
|
||||||
vaultTimeoutSettingsService,
|
vaultTimeoutSettingsService,
|
||||||
kdfConfigService,
|
kdfConfigService,
|
||||||
|
userAsymmetricKeysRegenerationService,
|
||||||
);
|
);
|
||||||
|
|
||||||
apiService.postIdentityToken.mockResolvedValue(identityTokenResponseFactory());
|
apiService.postIdentityToken.mockResolvedValue(identityTokenResponseFactory());
|
||||||
|
|
|
@ -22,11 +22,9 @@ import { IdentityTokenResponse } from "@bitwarden/common/auth/models/response/id
|
||||||
import { IdentityTwoFactorResponse } from "@bitwarden/common/auth/models/response/identity-two-factor.response";
|
import { IdentityTwoFactorResponse } from "@bitwarden/common/auth/models/response/identity-two-factor.response";
|
||||||
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";
|
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";
|
||||||
import { ClientType } from "@bitwarden/common/enums";
|
import { ClientType } from "@bitwarden/common/enums";
|
||||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
|
||||||
import { VaultTimeoutAction } from "@bitwarden/common/enums/vault-timeout-action.enum";
|
import { VaultTimeoutAction } from "@bitwarden/common/enums/vault-timeout-action.enum";
|
||||||
import { KeysRequest } from "@bitwarden/common/models/request/keys.request";
|
import { KeysRequest } from "@bitwarden/common/models/request/keys.request";
|
||||||
import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
|
import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
|
||||||
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
|
@ -82,8 +80,7 @@ export abstract class LoginStrategy {
|
||||||
protected billingAccountProfileStateService: BillingAccountProfileStateService,
|
protected billingAccountProfileStateService: BillingAccountProfileStateService,
|
||||||
protected vaultTimeoutSettingsService: VaultTimeoutSettingsService,
|
protected vaultTimeoutSettingsService: VaultTimeoutSettingsService,
|
||||||
protected KdfConfigService: KdfConfigService,
|
protected KdfConfigService: KdfConfigService,
|
||||||
protected UserAsymmetricKeysRegenerationService: UserAsymmetricKeysRegenerationService,
|
protected userAsymmetricKeysRegenerationService: UserAsymmetricKeysRegenerationService,
|
||||||
protected configService: ConfigService,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
abstract exportCache(): CacheData;
|
abstract exportCache(): CacheData;
|
||||||
|
@ -270,17 +267,7 @@ export abstract class LoginStrategy {
|
||||||
await this.setUserKey(response, userId);
|
await this.setUserKey(response, userId);
|
||||||
await this.setPrivateKey(response, userId);
|
await this.setPrivateKey(response, userId);
|
||||||
|
|
||||||
const privateKeyRegenerationFlag = await this.configService.getFeatureFlag(
|
await this.userAsymmetricKeysRegenerationService.handleUserAsymmetricKeysRegeneration(userId);
|
||||||
FeatureFlag.PrivateKeyRegeneration,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (privateKeyRegenerationFlag) {
|
|
||||||
const shouldRegenerate =
|
|
||||||
await this.UserAsymmetricKeysRegenerationService.shouldRegenerate(userId);
|
|
||||||
if (shouldRegenerate) {
|
|
||||||
await this.UserAsymmetricKeysRegenerationService.regenerateUserAsymmetricKeys(userId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.messagingService.send("loggedIn");
|
this.messagingService.send("loggedIn");
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ import {
|
||||||
import { CsprngArray } from "@bitwarden/common/types/csprng";
|
import { CsprngArray } from "@bitwarden/common/types/csprng";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
import { MasterKey, UserKey } from "@bitwarden/common/types/key";
|
import { MasterKey, UserKey } from "@bitwarden/common/types/key";
|
||||||
import { KeyService } from "@bitwarden/key-management";
|
import { KeyService, UserAsymmetricKeysRegenerationService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { LoginStrategyServiceAbstraction } from "../abstractions";
|
import { LoginStrategyServiceAbstraction } from "../abstractions";
|
||||||
import { InternalUserDecryptionOptionsServiceAbstraction } from "../abstractions/user-decryption-options.service.abstraction";
|
import { InternalUserDecryptionOptionsServiceAbstraction } from "../abstractions/user-decryption-options.service.abstraction";
|
||||||
|
@ -79,6 +79,7 @@ describe("PasswordLoginStrategy", () => {
|
||||||
let billingAccountProfileStateService: MockProxy<BillingAccountProfileStateService>;
|
let billingAccountProfileStateService: MockProxy<BillingAccountProfileStateService>;
|
||||||
let vaultTimeoutSettingsService: MockProxy<VaultTimeoutSettingsService>;
|
let vaultTimeoutSettingsService: MockProxy<VaultTimeoutSettingsService>;
|
||||||
let kdfConfigService: MockProxy<KdfConfigService>;
|
let kdfConfigService: MockProxy<KdfConfigService>;
|
||||||
|
let userAsymmetricKeysRegenerationService: MockProxy<UserAsymmetricKeysRegenerationService>;
|
||||||
|
|
||||||
let passwordLoginStrategy: PasswordLoginStrategy;
|
let passwordLoginStrategy: PasswordLoginStrategy;
|
||||||
let credentials: PasswordLoginCredentials;
|
let credentials: PasswordLoginCredentials;
|
||||||
|
@ -105,6 +106,7 @@ describe("PasswordLoginStrategy", () => {
|
||||||
billingAccountProfileStateService = mock<BillingAccountProfileStateService>();
|
billingAccountProfileStateService = mock<BillingAccountProfileStateService>();
|
||||||
vaultTimeoutSettingsService = mock<VaultTimeoutSettingsService>();
|
vaultTimeoutSettingsService = mock<VaultTimeoutSettingsService>();
|
||||||
kdfConfigService = mock<KdfConfigService>();
|
kdfConfigService = mock<KdfConfigService>();
|
||||||
|
userAsymmetricKeysRegenerationService = mock<UserAsymmetricKeysRegenerationService>();
|
||||||
|
|
||||||
appIdService.getAppId.mockResolvedValue(deviceId);
|
appIdService.getAppId.mockResolvedValue(deviceId);
|
||||||
tokenService.decodeAccessToken.mockResolvedValue({
|
tokenService.decodeAccessToken.mockResolvedValue({
|
||||||
|
@ -143,6 +145,7 @@ describe("PasswordLoginStrategy", () => {
|
||||||
billingAccountProfileStateService,
|
billingAccountProfileStateService,
|
||||||
vaultTimeoutSettingsService,
|
vaultTimeoutSettingsService,
|
||||||
kdfConfigService,
|
kdfConfigService,
|
||||||
|
userAsymmetricKeysRegenerationService,
|
||||||
);
|
);
|
||||||
credentials = new PasswordLoginCredentials(email, masterPassword);
|
credentials = new PasswordLoginCredentials(email, masterPassword);
|
||||||
tokenResponse = identityTokenResponseFactory(masterPasswordPolicy);
|
tokenResponse = identityTokenResponseFactory(masterPasswordPolicy);
|
||||||
|
|
|
@ -29,7 +29,7 @@ import { FakeAccountService, mockAccountServiceWith } from "@bitwarden/common/sp
|
||||||
import { CsprngArray } from "@bitwarden/common/types/csprng";
|
import { CsprngArray } from "@bitwarden/common/types/csprng";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
import { DeviceKey, UserKey, MasterKey } from "@bitwarden/common/types/key";
|
import { DeviceKey, UserKey, MasterKey } from "@bitwarden/common/types/key";
|
||||||
import { KeyService } from "@bitwarden/key-management";
|
import { KeyService, UserAsymmetricKeysRegenerationService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AuthRequestServiceAbstraction,
|
AuthRequestServiceAbstraction,
|
||||||
|
@ -62,6 +62,7 @@ describe("SsoLoginStrategy", () => {
|
||||||
let billingAccountProfileStateService: MockProxy<BillingAccountProfileStateService>;
|
let billingAccountProfileStateService: MockProxy<BillingAccountProfileStateService>;
|
||||||
let vaultTimeoutSettingsService: MockProxy<VaultTimeoutSettingsService>;
|
let vaultTimeoutSettingsService: MockProxy<VaultTimeoutSettingsService>;
|
||||||
let kdfConfigService: MockProxy<KdfConfigService>;
|
let kdfConfigService: MockProxy<KdfConfigService>;
|
||||||
|
let userAsymmetricKeysRegenerationService: MockProxy<UserAsymmetricKeysRegenerationService>;
|
||||||
|
|
||||||
let ssoLoginStrategy: SsoLoginStrategy;
|
let ssoLoginStrategy: SsoLoginStrategy;
|
||||||
let credentials: SsoLoginCredentials;
|
let credentials: SsoLoginCredentials;
|
||||||
|
@ -97,6 +98,7 @@ describe("SsoLoginStrategy", () => {
|
||||||
billingAccountProfileStateService = mock<BillingAccountProfileStateService>();
|
billingAccountProfileStateService = mock<BillingAccountProfileStateService>();
|
||||||
vaultTimeoutSettingsService = mock<VaultTimeoutSettingsService>();
|
vaultTimeoutSettingsService = mock<VaultTimeoutSettingsService>();
|
||||||
kdfConfigService = mock<KdfConfigService>();
|
kdfConfigService = mock<KdfConfigService>();
|
||||||
|
userAsymmetricKeysRegenerationService = mock<UserAsymmetricKeysRegenerationService>();
|
||||||
|
|
||||||
tokenService.getTwoFactorToken.mockResolvedValue(null);
|
tokenService.getTwoFactorToken.mockResolvedValue(null);
|
||||||
appIdService.getAppId.mockResolvedValue(deviceId);
|
appIdService.getAppId.mockResolvedValue(deviceId);
|
||||||
|
@ -141,6 +143,7 @@ describe("SsoLoginStrategy", () => {
|
||||||
billingAccountProfileStateService,
|
billingAccountProfileStateService,
|
||||||
vaultTimeoutSettingsService,
|
vaultTimeoutSettingsService,
|
||||||
kdfConfigService,
|
kdfConfigService,
|
||||||
|
userAsymmetricKeysRegenerationService,
|
||||||
);
|
);
|
||||||
credentials = new SsoLoginCredentials(ssoCode, ssoCodeVerifier, ssoRedirectUrl, ssoOrgId);
|
credentials = new SsoLoginCredentials(ssoCode, ssoCodeVerifier, ssoRedirectUrl, ssoOrgId);
|
||||||
});
|
});
|
||||||
|
|
|
@ -26,7 +26,7 @@ import { FakeAccountService, mockAccountServiceWith } from "@bitwarden/common/sp
|
||||||
import { CsprngArray } from "@bitwarden/common/types/csprng";
|
import { CsprngArray } from "@bitwarden/common/types/csprng";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
import { UserKey, MasterKey } from "@bitwarden/common/types/key";
|
import { UserKey, MasterKey } from "@bitwarden/common/types/key";
|
||||||
import { KeyService } from "@bitwarden/key-management";
|
import { KeyService, UserAsymmetricKeysRegenerationService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { InternalUserDecryptionOptionsServiceAbstraction } from "../abstractions/user-decryption-options.service.abstraction";
|
import { InternalUserDecryptionOptionsServiceAbstraction } from "../abstractions/user-decryption-options.service.abstraction";
|
||||||
import { UserApiLoginCredentials } from "../models/domain/login-credentials";
|
import { UserApiLoginCredentials } from "../models/domain/login-credentials";
|
||||||
|
@ -55,6 +55,7 @@ describe("UserApiLoginStrategy", () => {
|
||||||
let billingAccountProfileStateService: MockProxy<BillingAccountProfileStateService>;
|
let billingAccountProfileStateService: MockProxy<BillingAccountProfileStateService>;
|
||||||
let vaultTimeoutSettingsService: MockProxy<VaultTimeoutSettingsService>;
|
let vaultTimeoutSettingsService: MockProxy<VaultTimeoutSettingsService>;
|
||||||
let kdfConfigService: MockProxy<KdfConfigService>;
|
let kdfConfigService: MockProxy<KdfConfigService>;
|
||||||
|
let userAsymmetricKeysRegenerationService: MockProxy<UserAsymmetricKeysRegenerationService>;
|
||||||
|
|
||||||
let apiLogInStrategy: UserApiLoginStrategy;
|
let apiLogInStrategy: UserApiLoginStrategy;
|
||||||
let credentials: UserApiLoginCredentials;
|
let credentials: UserApiLoginCredentials;
|
||||||
|
@ -87,6 +88,7 @@ describe("UserApiLoginStrategy", () => {
|
||||||
billingAccountProfileStateService = mock<BillingAccountProfileStateService>();
|
billingAccountProfileStateService = mock<BillingAccountProfileStateService>();
|
||||||
vaultTimeoutSettingsService = mock<VaultTimeoutSettingsService>();
|
vaultTimeoutSettingsService = mock<VaultTimeoutSettingsService>();
|
||||||
kdfConfigService = mock<KdfConfigService>();
|
kdfConfigService = mock<KdfConfigService>();
|
||||||
|
userAsymmetricKeysRegenerationService = mock<UserAsymmetricKeysRegenerationService>();
|
||||||
|
|
||||||
appIdService.getAppId.mockResolvedValue(deviceId);
|
appIdService.getAppId.mockResolvedValue(deviceId);
|
||||||
tokenService.getTwoFactorToken.mockResolvedValue(null);
|
tokenService.getTwoFactorToken.mockResolvedValue(null);
|
||||||
|
@ -114,6 +116,7 @@ describe("UserApiLoginStrategy", () => {
|
||||||
billingAccountProfileStateService,
|
billingAccountProfileStateService,
|
||||||
vaultTimeoutSettingsService,
|
vaultTimeoutSettingsService,
|
||||||
kdfConfigService,
|
kdfConfigService,
|
||||||
|
userAsymmetricKeysRegenerationService,
|
||||||
);
|
);
|
||||||
|
|
||||||
credentials = new UserApiLoginCredentials(apiClientId, apiClientSecret);
|
credentials = new UserApiLoginCredentials(apiClientId, apiClientSecret);
|
||||||
|
|
|
@ -24,7 +24,7 @@ import { VaultTimeoutSettingsService } from "@bitwarden/common/services/vault-ti
|
||||||
import { FakeAccountService, mockAccountServiceWith } from "@bitwarden/common/spec";
|
import { FakeAccountService, mockAccountServiceWith } from "@bitwarden/common/spec";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
import { PrfKey, UserKey } from "@bitwarden/common/types/key";
|
import { PrfKey, UserKey } from "@bitwarden/common/types/key";
|
||||||
import { KeyService } from "@bitwarden/key-management";
|
import { KeyService, UserAsymmetricKeysRegenerationService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import { InternalUserDecryptionOptionsServiceAbstraction } from "../abstractions/user-decryption-options.service.abstraction";
|
import { InternalUserDecryptionOptionsServiceAbstraction } from "../abstractions/user-decryption-options.service.abstraction";
|
||||||
import { WebAuthnLoginCredentials } from "../models/domain/login-credentials";
|
import { WebAuthnLoginCredentials } from "../models/domain/login-credentials";
|
||||||
|
@ -51,6 +51,7 @@ describe("WebAuthnLoginStrategy", () => {
|
||||||
let billingAccountProfileStateService: MockProxy<BillingAccountProfileStateService>;
|
let billingAccountProfileStateService: MockProxy<BillingAccountProfileStateService>;
|
||||||
let vaultTimeoutSettingsService: MockProxy<VaultTimeoutSettingsService>;
|
let vaultTimeoutSettingsService: MockProxy<VaultTimeoutSettingsService>;
|
||||||
let kdfConfigService: MockProxy<KdfConfigService>;
|
let kdfConfigService: MockProxy<KdfConfigService>;
|
||||||
|
let userAsymmetricKeysRegenerationService: MockProxy<UserAsymmetricKeysRegenerationService>;
|
||||||
|
|
||||||
let webAuthnLoginStrategy!: WebAuthnLoginStrategy;
|
let webAuthnLoginStrategy!: WebAuthnLoginStrategy;
|
||||||
|
|
||||||
|
@ -94,6 +95,7 @@ describe("WebAuthnLoginStrategy", () => {
|
||||||
billingAccountProfileStateService = mock<BillingAccountProfileStateService>();
|
billingAccountProfileStateService = mock<BillingAccountProfileStateService>();
|
||||||
vaultTimeoutSettingsService = mock<VaultTimeoutSettingsService>();
|
vaultTimeoutSettingsService = mock<VaultTimeoutSettingsService>();
|
||||||
kdfConfigService = mock<KdfConfigService>();
|
kdfConfigService = mock<KdfConfigService>();
|
||||||
|
userAsymmetricKeysRegenerationService = mock<UserAsymmetricKeysRegenerationService>();
|
||||||
|
|
||||||
tokenService.getTwoFactorToken.mockResolvedValue(null);
|
tokenService.getTwoFactorToken.mockResolvedValue(null);
|
||||||
appIdService.getAppId.mockResolvedValue(deviceId);
|
appIdService.getAppId.mockResolvedValue(deviceId);
|
||||||
|
@ -119,6 +121,7 @@ describe("WebAuthnLoginStrategy", () => {
|
||||||
billingAccountProfileStateService,
|
billingAccountProfileStateService,
|
||||||
vaultTimeoutSettingsService,
|
vaultTimeoutSettingsService,
|
||||||
kdfConfigService,
|
kdfConfigService,
|
||||||
|
userAsymmetricKeysRegenerationService,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create credentials
|
// Create credentials
|
||||||
|
|
|
@ -37,7 +37,7 @@ import {
|
||||||
} from "@bitwarden/common/spec";
|
} from "@bitwarden/common/spec";
|
||||||
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
import { KeyService } from "@bitwarden/key-management";
|
import { KeyService, UserAsymmetricKeysRegenerationService } from "@bitwarden/key-management";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AuthRequestServiceAbstraction,
|
AuthRequestServiceAbstraction,
|
||||||
|
@ -76,6 +76,7 @@ describe("LoginStrategyService", () => {
|
||||||
let vaultTimeoutSettingsService: MockProxy<VaultTimeoutSettingsService>;
|
let vaultTimeoutSettingsService: MockProxy<VaultTimeoutSettingsService>;
|
||||||
let kdfConfigService: MockProxy<KdfConfigService>;
|
let kdfConfigService: MockProxy<KdfConfigService>;
|
||||||
let taskSchedulerService: MockProxy<TaskSchedulerService>;
|
let taskSchedulerService: MockProxy<TaskSchedulerService>;
|
||||||
|
let userAsymmetricKeysRegenerationService: MockProxy<UserAsymmetricKeysRegenerationService>;
|
||||||
|
|
||||||
let stateProvider: FakeGlobalStateProvider;
|
let stateProvider: FakeGlobalStateProvider;
|
||||||
let loginStrategyCacheExpirationState: FakeGlobalState<Date | null>;
|
let loginStrategyCacheExpirationState: FakeGlobalState<Date | null>;
|
||||||
|
@ -108,6 +109,7 @@ describe("LoginStrategyService", () => {
|
||||||
vaultTimeoutSettingsService = mock<VaultTimeoutSettingsService>();
|
vaultTimeoutSettingsService = mock<VaultTimeoutSettingsService>();
|
||||||
kdfConfigService = mock<KdfConfigService>();
|
kdfConfigService = mock<KdfConfigService>();
|
||||||
taskSchedulerService = mock<TaskSchedulerService>();
|
taskSchedulerService = mock<TaskSchedulerService>();
|
||||||
|
userAsymmetricKeysRegenerationService = mock<UserAsymmetricKeysRegenerationService>();
|
||||||
|
|
||||||
sut = new LoginStrategyService(
|
sut = new LoginStrategyService(
|
||||||
accountService,
|
accountService,
|
||||||
|
@ -135,6 +137,7 @@ describe("LoginStrategyService", () => {
|
||||||
vaultTimeoutSettingsService,
|
vaultTimeoutSettingsService,
|
||||||
kdfConfigService,
|
kdfConfigService,
|
||||||
taskSchedulerService,
|
taskSchedulerService,
|
||||||
|
userAsymmetricKeysRegenerationService,
|
||||||
);
|
);
|
||||||
|
|
||||||
loginStrategyCacheExpirationState = stateProvider.getFake(CACHE_EXPIRATION_KEY);
|
loginStrategyCacheExpirationState = stateProvider.getFake(CACHE_EXPIRATION_KEY);
|
||||||
|
|
Loading…
Reference in New Issue