generated from bitwarden/template
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PM-12312: Update autofill setup progress when account is created and …
…autofill is enabled (#963)
- Loading branch information
1 parent
26ddba5
commit 6827509
Showing
3 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ class AuthServiceTests: BitwardenTestCase { // swiftlint:disable:this type_body_ | |
var client: MockHTTPClient! | ||
var clientService: MockClientService! | ||
var configService: MockConfigService! | ||
var credentialIdentityStore: MockCredentialIdentityStore! | ||
var environmentService: MockEnvironmentService! | ||
var keychainRepository: MockKeychainRepository! | ||
var stateService: MockStateService! | ||
|
@@ -44,6 +45,7 @@ class AuthServiceTests: BitwardenTestCase { // swiftlint:disable:this type_body_ | |
version: "2024.6.0" | ||
) | ||
)) | ||
credentialIdentityStore = MockCredentialIdentityStore() | ||
environmentService = MockEnvironmentService() | ||
keychainRepository = MockKeychainRepository() | ||
policyService = MockPolicyService() | ||
|
@@ -57,6 +59,7 @@ class AuthServiceTests: BitwardenTestCase { // swiftlint:disable:this type_body_ | |
authAPIService: authAPIService, | ||
clientService: clientService, | ||
configService: configService, | ||
credentialIdentityStore: credentialIdentityStore, | ||
environmentService: environmentService, | ||
keychainRepository: keychainRepository, | ||
policyService: policyService, | ||
|
@@ -75,6 +78,7 @@ class AuthServiceTests: BitwardenTestCase { // swiftlint:disable:this type_body_ | |
client = nil | ||
clientService = nil | ||
configService = nil | ||
credentialIdentityStore = nil | ||
environmentService = nil | ||
keychainRepository = nil | ||
stateService = nil | ||
|
@@ -393,6 +397,7 @@ class AuthServiceTests: BitwardenTestCase { // swiftlint:disable:this type_body_ | |
appSettingsStore.appId = "App id" | ||
clientService.mockAuth.hashPasswordResult = .success("hashed password") | ||
configService.featureFlagsBool[.nativeCreateAccountFlow] = true | ||
credentialIdentityStore.state.mockIsEnabled = false | ||
stateService.preAuthEnvironmentUrls = EnvironmentUrlData(base: URL(string: "https://vault.bitwarden.com")) | ||
systemDevice.modelIdentifier = "Model id" | ||
|
||
|
@@ -452,6 +457,33 @@ class AuthServiceTests: BitwardenTestCase { // swiftlint:disable:this type_body_ | |
assertGetConfig() | ||
} | ||
|
||
/// `loginWithMasterPassword(_:username:captchaToken:)` logs the user in with the password for | ||
/// a newly created account and sets their autofill account setup progress to complete if | ||
/// autofill is already enabled. | ||
func test_loginWithMasterPassword_isNewAccount_autofillEnabled() async throws { | ||
client.results = [ | ||
.httpSuccess(testData: .preLoginSuccess), | ||
.httpSuccess(testData: .identityTokenSuccess), | ||
] | ||
appSettingsStore.appId = "App id" | ||
clientService.mockAuth.hashPasswordResult = .success("hashed password") | ||
configService.featureFlagsBool[.nativeCreateAccountFlow] = true | ||
credentialIdentityStore.state.mockIsEnabled = true | ||
stateService.preAuthEnvironmentUrls = EnvironmentUrlData(base: URL(string: "https://vault.bitwarden.com")) | ||
systemDevice.modelIdentifier = "Model id" | ||
|
||
// Attempt to login. | ||
try await subject.loginWithMasterPassword( | ||
"Password1234!", | ||
username: "[email protected]", | ||
captchaToken: nil, | ||
isNewAccount: true | ||
) | ||
|
||
XCTAssertEqual(stateService.accountSetupAutofill["13512467-9cfe-43b0-969f-07534084764b"], .complete) | ||
XCTAssertEqual(stateService.accountSetupVaultUnlock["13512467-9cfe-43b0-969f-07534084764b"], .incomplete) | ||
} | ||
|
||
/// `loginWithMasterPassword(_:username:captchaToken:)` logs in with the password updates AccountProfile's | ||
/// `.forcePasswordResetReason` value if policy requires user to update password. | ||
func test_loginWithMasterPassword_updatesAccountProfile() async throws { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters