Skip to content

Commit ff06d9c

Browse files
authored
[PM-22852] [RC] Fix master password unlock subsequent attempts (#1687)
1 parent 3fbb3d7 commit ff06d9c

File tree

17 files changed

+82
-34
lines changed

17 files changed

+82
-34
lines changed

AuthenticatorShared/Core/Vault/Services/TestHelpers/BitwardenSdk+VaultMocking.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,12 @@ extension CipherListView {
7373
permissions: cipher.permissions,
7474
viewPassword: cipher.viewPassword,
7575
attachments: UInt32(cipher.attachments?.count ?? 0),
76+
hasOldAttachments: false,
7677
creationDate: cipher.creationDate,
7778
deletedDate: cipher.deletedDate,
78-
revisionDate: cipher.revisionDate
79+
revisionDate: cipher.revisionDate,
80+
copyableFields: [],
81+
localData: cipher.localData.map(LocalDataView.init)
7982
)
8083
}
8184
}
@@ -84,7 +87,7 @@ extension CipherListViewType {
8487
init(cipher: Cipher) {
8588
switch cipher.type {
8689
case .card:
87-
self = .card
90+
self = .card(.init(brand: nil))
8891
case .identity:
8992
self = .identity
9093
case .login:

Bitwarden.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

BitwardenShared/Core/Auth/Repositories/AuthRepository.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,7 @@ extension DefaultAuthRepository: AuthRepository {
11021102
kdfParams: account.kdf.sdkKdf,
11031103
email: account.profile.email,
11041104
privateKey: encryptionKeys.encryptedPrivateKey,
1105+
signingKey: nil,
11051106
method: method
11061107
)
11071108
)

BitwardenShared/Core/Auth/Repositories/AuthRepositoryTests.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,7 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
12121212
kdfParams: account.kdf.sdkKdf,
12131213
email: account.profile.email,
12141214
privateKey: "private",
1215+
signingKey: nil,
12151216
method: .password(password: "NEW_PASSWORD", userKey: "encryptedUserKey")
12161217
)
12171218
)
@@ -1728,6 +1729,7 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
17281729
kdfParams: .pbkdf2(iterations: UInt32(Constants.pbkdf2Iterations)),
17291730
17301731
privateKey: "PRIVATE_KEY",
1732+
signingKey: nil,
17311733
method: .password(password: "password", userKey: "USER_KEY")
17321734
)
17331735
)
@@ -1904,6 +1906,7 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
19041906
kdfParams: KdfConfig().sdkKdf,
19051907
19061908
privateKey: "private",
1909+
signingKey: nil,
19071910
method: .keyConnector(masterKey: "key", userKey: "user")
19081911
)
19091912
)
@@ -1955,6 +1958,7 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
19551958
kdfParams: KdfConfig().sdkKdf,
19561959
19571960
privateKey: "private",
1961+
signingKey: nil,
19581962
method: .keyConnector(masterKey: "key", userKey: "user")
19591963
)
19601964
)
@@ -2147,6 +2151,7 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
21472151
kdfParams: .pbkdf2(iterations: UInt32(Constants.pbkdf2Iterations)),
21482152
21492153
privateKey: "PRIVATE_KEY",
2154+
signingKey: nil,
21502155
method: .authRequest(
21512156
requestPrivateKey: "AUTH_REQUEST_PRIVATE_KEY",
21522157
method: .masterKey(protectedMasterKey: "KEY", authRequestKey: "USER_KEY")
@@ -2177,6 +2182,7 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
21772182
kdfParams: .pbkdf2(iterations: UInt32(Constants.pbkdf2Iterations)),
21782183
21792184
privateKey: "PRIVATE_KEY",
2185+
signingKey: nil,
21802186
method: .authRequest(
21812187
requestPrivateKey: "AUTH_REQUEST_PRIVATE_KEY",
21822188
method: .userKey(protectedUserKey: "KEY")
@@ -2210,6 +2216,7 @@ class AuthRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_bo
22102216
kdfParams: .pbkdf2(iterations: UInt32(Constants.pbkdf2Iterations)),
22112217
22122218
privateKey: "PRIVATE_KEY",
2219+
signingKey: nil,
22132220
method: .pin(pin: "123", pinProtectedUserKey: "123")
22142221
)
22152222
)

BitwardenShared/Core/Vault/Extensions/BitwardenSdk+Vault.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,16 @@ extension BitwardenSdk.Cipher {
345345
extension BitwardenSdk.CipherListView: @retroactive Identifiable, Fido2UserVerifiableCipherView {}
346346

347347
extension BitwardenSdk.CipherListViewType {
348+
/// Whether the type is card.
349+
var isCard: Bool {
350+
switch self {
351+
case .card:
352+
return true
353+
default:
354+
return false
355+
}
356+
}
357+
348358
/// Whether the type is login.
349359
var isLogin: Bool {
350360
switch self {

BitwardenShared/Core/Vault/Extensions/BitwardenSdkVaultTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class BitwardenSdkCipherListViewTypeTests: BitwardenTestCase {
7878
/// `isLogin` returns whether the type is a login.
7979
func test_isLogin() {
8080
XCTAssertTrue(CipherListViewType.login(.fixture()).isLogin)
81-
XCTAssertFalse(CipherListViewType.card.isLogin)
81+
XCTAssertFalse(CipherListViewType.card(.init(brand: nil)).isLogin)
8282
XCTAssertFalse(CipherListViewType.identity.isLogin)
8383
XCTAssertFalse(CipherListViewType.secureNote.isLogin)
8484
XCTAssertFalse(CipherListViewType.sshKey.isLogin)
@@ -91,7 +91,7 @@ class BitwardenSdkCipherListViewTypeTests: BitwardenTestCase {
9191
CipherListViewType.login(expectedResult).loginListView,
9292
expectedResult
9393
)
94-
XCTAssertNil(CipherListViewType.card.loginListView)
94+
XCTAssertNil(CipherListViewType.card(.init(brand: nil)).loginListView)
9595
XCTAssertNil(CipherListViewType.identity.loginListView)
9696
XCTAssertNil(CipherListViewType.secureNote.loginListView)
9797
XCTAssertNil(CipherListViewType.sshKey.loginListView)

BitwardenShared/Core/Vault/Models/Domain/Fixtures/CipherListView+Fixtures.swift

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ extension CipherListView {
1818
permissions: BitwardenSdk.CipherPermissions? = nil,
1919
viewPassword: Bool = true,
2020
attachments: UInt32 = 0,
21+
hasOldAttachments: Bool = false,
2122
creationDate: Date = Date(),
2223
deletedDate: Date? = nil,
23-
revisionDate: Date = Date()
24+
revisionDate: Date = Date(),
25+
copyableFields: [CopyableCipherFields] = [],
26+
localData: LocalDataView? = nil
2427
) -> CipherListView {
2528
.init(
2629
id: id,
@@ -38,9 +41,12 @@ extension CipherListView {
3841
permissions: permissions,
3942
viewPassword: viewPassword,
4043
attachments: attachments,
44+
hasOldAttachments: hasOldAttachments,
4145
creationDate: creationDate,
4246
deletedDate: deletedDate,
43-
revisionDate: revisionDate
47+
revisionDate: revisionDate,
48+
copyableFields: copyableFields,
49+
localData: localData
4450
)
4551
}
4652

@@ -60,9 +66,12 @@ extension CipherListView {
6066
permissions: BitwardenSdk.CipherPermissions? = nil,
6167
viewPassword: Bool = true,
6268
attachments: UInt32 = 0,
69+
hasOldAttachments: Bool = false,
6370
creationDate: Date = Date(),
6471
deletedDate: Date? = nil,
65-
revisionDate: Date = Date()
72+
revisionDate: Date = Date(),
73+
copyableFields: [CopyableCipherFields] = [],
74+
localData: LocalDataView? = nil
6675
) -> CipherListView {
6776
.init(
6877
id: id,
@@ -80,9 +89,12 @@ extension CipherListView {
8089
permissions: permissions,
8190
viewPassword: viewPassword,
8291
attachments: attachments,
92+
hasOldAttachments: hasOldAttachments,
8393
creationDate: creationDate,
8494
deletedDate: deletedDate,
85-
revisionDate: revisionDate
95+
revisionDate: revisionDate,
96+
copyableFields: copyableFields,
97+
localData: localData
8698
)
8799
}
88100
}

BitwardenShared/Core/Vault/Repositories/VaultRepository.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ class DefaultVaultRepository { // swiftlint:disable:this type_body_length
767767
let items: [VaultListItem]
768768
switch group {
769769
case .card:
770-
items = activeCiphers.filter { $0.type == .card }.compactMap(VaultListItem.init)
770+
items = activeCiphers.filter { $0.type.isCard }.compactMap(VaultListItem.init)
771771
case let .collection(id, _, _):
772772
items = activeCiphers.filter { $0.collectionIds.contains(id) }.compactMap(VaultListItem.init)
773773
case let .folder(id, _):
@@ -920,7 +920,7 @@ class DefaultVaultRepository { // swiftlint:disable:this type_body_length
920920
)
921921
}
922922

923-
let typesCardCount = activeCiphers.lazy.filter { $0.type == .card }.count
923+
let typesCardCount = activeCiphers.lazy.filter { $0.type.isCard }.count
924924
let typesIdentityCount = activeCiphers.lazy.filter { $0.type == .identity }.count
925925
let typesLoginCount = activeCiphers.lazy.filter(\.type.isLogin).count
926926
let typesSecureNoteCount = activeCiphers.lazy.filter { $0.type == .secureNote }.count
@@ -1715,7 +1715,7 @@ private extension CipherListView {
17151715
func belongsToGroup(_ group: VaultListGroup) -> Bool {
17161716
return switch group {
17171717
case .card:
1718-
type == .card
1718+
type.isCard
17191719
case let .collection(id, _, _):
17201720
collectionIds.contains(id)
17211721
case let .folder(id, _):

BitwardenShared/Core/Vault/Services/TestHelpers/BitwardenSdk+VaultMocking.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,12 @@ extension CipherListView {
7373
permissions: cipher.permissions,
7474
viewPassword: cipher.viewPassword,
7575
attachments: UInt32(cipher.attachments?.count ?? 0),
76+
hasOldAttachments: false,
7677
creationDate: cipher.creationDate,
7778
deletedDate: cipher.deletedDate,
78-
revisionDate: cipher.revisionDate
79+
revisionDate: cipher.revisionDate,
80+
copyableFields: [],
81+
localData: cipher.localData.map(LocalDataView.init)
7982
)
8083
}
8184
}
@@ -84,7 +87,7 @@ extension CipherListViewType {
8487
init(cipher: Cipher) {
8588
switch cipher.type {
8689
case .card:
87-
self = .card
90+
self = .card(.init(brand: nil))
8891
case .identity:
8992
self = .identity
9093
case .login:

BitwardenShared/UI/Vault/Helpers/VaultItemMoreOptionsHelperTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class VaultItemMoreOptionsHelperTests: BitwardenTestCase { // swiftlint:disable:
6666
let account = Account.fixture()
6767
stateService.activeAccount = account
6868

69-
var item = try XCTUnwrap(VaultListItem(cipherListView: .fixture(type: .card)))
69+
var item = try XCTUnwrap(VaultListItem(cipherListView: .fixture(type: .card(.init(brand: nil)))))
7070

7171
// If the card item has no number or code, only the view and add buttons should display.
7272
vaultRepository.fetchCipherResult = .success(.cardFixture())

0 commit comments

Comments
 (0)