Skip to content

Commit 9f0c578

Browse files
[PM-25651] Update CryptoClient updatePassword references to makeUpdatePassword (#1996)
1 parent 5e0c390 commit 9f0c578

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

BitwardenShared/Core/Auth/Repositories/AuthRepository.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ extension DefaultAuthRepository: AuthRepository {
814814

815815
// TDE user
816816
if account.profile.userDecryptionOptions?.trustedDeviceOption != nil {
817-
let passwordResult = try await clientService.crypto().updatePassword(newPassword: password)
817+
let passwordResult = try await clientService.crypto().makeUpdatePassword(newPassword: password)
818818
requestPasswordHash = passwordResult.passwordHash
819819
requestUserKey = passwordResult.newKey
820820
requestKeys = nil
@@ -1144,7 +1144,7 @@ extension DefaultAuthRepository: AuthRepository {
11441144
reason: ForcePasswordResetReason
11451145
) async throws {
11461146
let account = try await stateService.getActiveAccount()
1147-
let updatePasswordResponse = try await clientService.crypto().updatePassword(newPassword: newPassword)
1147+
let updatePasswordResponse = try await clientService.crypto().makeUpdatePassword(newPassword: newPassword)
11481148

11491149
let masterPasswordHash = try await clientService.auth().hashPassword(
11501150
email: account.profile.email,

BitwardenShared/Core/Auth/Repositories/AuthRepositoryTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
11641164
func test_setMasterPassword() async throws {
11651165
let account = Account.fixture()
11661166
client.result = .httpSuccess(testData: .emptyResponse)
1167-
clientService.mockCrypto.updatePasswordResult = .success(
1167+
clientService.mockCrypto.makeUpdatePasswordResult = .success(
11681168
UpdatePasswordResponse(passwordHash: "NEW_PASSWORD_HASH", newKey: "NEW_KEY")
11691169
)
11701170
stateService.accountEncryptionKeys["1"] = AccountEncryptionKeys(
@@ -1222,7 +1222,7 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
12221222

12231223
/// `setMasterPassword()` throws an error if one occurs.
12241224
func test_setMasterPassword_error() async {
1225-
clientService.mockCrypto.updatePasswordResult = .failure(BitwardenTestError.example)
1225+
clientService.mockCrypto.makeUpdatePasswordResult = .failure(BitwardenTestError.example)
12261226
stateService.activeAccount = Account.fixtureWithTdeNoPassword()
12271227
stateService.accountEncryptionKeys["1"] = AccountEncryptionKeys(
12281228
accountKeys: .fixture(),
@@ -1249,7 +1249,7 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
12491249
.httpSuccess(testData: .organizationKeys),
12501250
.httpSuccess(testData: .emptyResponse),
12511251
]
1252-
clientService.mockCrypto.updatePasswordResult = .success(
1252+
clientService.mockCrypto.makeUpdatePasswordResult = .success(
12531253
UpdatePasswordResponse(passwordHash: "NEW_PASSWORD_HASH", newKey: "NEW_KEY")
12541254
)
12551255
stateService.accountEncryptionKeys["1"] = AccountEncryptionKeys(
@@ -1267,7 +1267,7 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
12671267
resetPasswordAutoEnroll: true
12681268
)
12691269

1270-
XCTAssertEqual(clientService.mockCrypto.updatePasswordNewPassword, "NEW_PASSWORD")
1270+
XCTAssertEqual(clientService.mockCrypto.makeUpdatePasswordNewPassword, "NEW_PASSWORD")
12711271
XCTAssertEqual(
12721272
stateService.accountEncryptionKeys["1"],
12731273
AccountEncryptionKeys(
@@ -2340,7 +2340,7 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
23402340

23412341
/// `updateMasterPassword()` rethrows an error if an error occurs.
23422342
func test_updateMasterPassword_error() async throws {
2343-
clientService.mockCrypto.updatePasswordResult = .failure(BitwardenTestError.example)
2343+
clientService.mockCrypto.makeUpdatePasswordResult = .failure(BitwardenTestError.example)
23442344
stateService.activeAccount = .fixture()
23452345

23462346
await assertAsyncThrows(error: BitwardenTestError.example) {
@@ -2356,7 +2356,7 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
23562356
/// `updateMasterPassword()` performs the API request to update the user's password.
23572357
func test_updateMasterPassword_weakMasterPasswordOnLogin() async throws {
23582358
client.result = .httpSuccess(testData: .emptyResponse)
2359-
clientService.mockCrypto.updatePasswordResult = .success(
2359+
clientService.mockCrypto.makeUpdatePasswordResult = .success(
23602360
UpdatePasswordResponse(passwordHash: "NEW_PASSWORD_HASH", newKey: "NEW_KEY")
23612361
)
23622362
stateService.accountEncryptionKeys["1"] = AccountEncryptionKeys(
@@ -2375,7 +2375,7 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
23752375
reason: .weakMasterPasswordOnLogin
23762376
)
23772377

2378-
XCTAssertEqual(clientService.mockCrypto.updatePasswordNewPassword, "NEW_PASSWORD")
2378+
XCTAssertEqual(clientService.mockCrypto.makeUpdatePasswordNewPassword, "NEW_PASSWORD")
23792379

23802380
XCTAssertEqual(client.requests.count, 1)
23812381
XCTAssertNotNil(client.requests[0].body)

BitwardenShared/Core/Auth/Services/TestHelpers/MockCryptoClient.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ class MockCryptoClient: CryptoClientProtocol {
6868
)
6969
)
7070

71-
var updatePasswordNewPassword: String?
72-
var updatePasswordResult: Result<UpdatePasswordResponse, Error> = .success(
71+
var makeUpdatePasswordNewPassword: String?
72+
var makeUpdatePasswordResult: Result<UpdatePasswordResponse, Error> = .success(
7373
UpdatePasswordResponse(
7474
passwordHash: "password hash",
7575
newKey: "new key"
@@ -127,12 +127,11 @@ class MockCryptoClient: CryptoClientProtocol {
127127
}
128128

129129
func makeUpdatePassword(newPassword: String) throws -> UpdatePasswordResponse {
130-
updatePasswordNewPassword = newPassword
131-
return try updatePasswordResult.get()
130+
makeUpdatePasswordNewPassword = newPassword
131+
return try makeUpdatePasswordResult.get()
132132
}
133133

134134
func updatePassword(newPassword: String) throws -> BitwardenSdk.UpdatePasswordResponse {
135-
updatePasswordNewPassword = newPassword
136-
return try updatePasswordResult.get()
135+
fatalError("Use makeUpdatePassword(newPassword:) instead")
137136
}
138137
}

0 commit comments

Comments
 (0)