Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@ class MockCryptoClient: CryptoClientProtocol {
var initializeUserCryptoRequest: InitUserCryptoRequest?
var initializeUserCryptoResult: Result<Void, Error> = .success(())

var makeUpdateKdfKdf: Kdf?
var makeUpdateKdfPassword: String?
var makeUpdateKdfResult: Result<UpdateKdfResponse, Error> = .success(
UpdateKdfResponse(
masterPasswordAuthenticationData: MasterPasswordAuthenticationData(
kdf: .pbkdf2(iterations: NonZeroU32(600_000)),
salt: "AUTHENTICATION_SALT",
masterPasswordAuthenticationHash: "MASTER_PASSWORD_AUTHENTICATION_HASH"
),
masterPasswordUnlockData: MasterPasswordUnlockData(
kdf: .pbkdf2(iterations: NonZeroU32(600_000)),
masterKeyWrappedUserKey: "MASTER_KEY_WRAPPED_USER_KEY",
salt: "UNLOCK_SALT"
),
oldMasterPasswordAuthenticationData: MasterPasswordAuthenticationData(
kdf: .pbkdf2(iterations: NonZeroU32(600_000)),
salt: "OLD_AUTHENTICATION_SALT",
masterPasswordAuthenticationHash: "MASTER_PASSWORD_AUTHENTICATION_HASH"
)
)
)

var updatePasswordNewPassword: String?
var updatePasswordResult: Result<UpdatePasswordResponse, Error> = .success(
UpdatePasswordResponse(
Expand Down Expand Up @@ -95,6 +117,17 @@ class MockCryptoClient: CryptoClientProtocol {
return try initializeUserCryptoResult.get()
}

func makeUpdateKdf(password: String, kdf: Kdf) throws -> UpdateKdfResponse {
makeUpdateKdfPassword = password
makeUpdateKdfKdf = kdf
return try makeUpdateKdfResult.get()
}

func makeUpdatePassword(newPassword: String) throws -> UpdatePasswordResponse {
updatePasswordNewPassword = newPassword
return try updatePasswordResult.get()
}

func updatePassword(newPassword: String) throws -> BitwardenSdk.UpdatePasswordResponse {
updatePasswordNewPassword = newPassword
return try updatePasswordResult.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ extension CipherListView {
creationDate: cipher.creationDate,
deletedDate: cipher.deletedDate,
revisionDate: cipher.revisionDate,
archivedDate: cipher.archivedDate,
copyableFields: [],
localData: cipher.localData.map(LocalDataView.init)
)
Expand Down Expand Up @@ -138,7 +139,8 @@ extension Cipher {
passwordHistory: cipherView.passwordHistory?.map(PasswordHistory.init),
creationDate: cipherView.creationDate,
deletedDate: cipherView.deletedDate,
revisionDate: cipherView.revisionDate
revisionDate: cipherView.revisionDate,
archivedDate: cipherView.archivedDate
)
}
}
Expand Down Expand Up @@ -171,7 +173,8 @@ extension CipherView {
passwordHistory: cipher.passwordHistory?.map(PasswordHistoryView.init),
creationDate: cipher.creationDate,
deletedDate: cipher.deletedDate,
revisionDate: cipher.revisionDate
revisionDate: cipher.revisionDate,
archivedDate: cipher.archivedDate
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extension AttachmentView {

extension Cipher {
static func fixture(
archivedDate: Date? = nil,
attachments: [Attachment]? = nil,
card: Card? = nil,
collectionIds: [String] = [],
Expand Down Expand Up @@ -80,13 +81,15 @@ extension Cipher {
passwordHistory: passwordHistory,
creationDate: creationDate,
deletedDate: deletedDate,
revisionDate: revisionDate
revisionDate: revisionDate,
archivedDate: archivedDate
)
}
}

extension CipherView {
static func fixture(
archivedDate: Date? = nil,
attachments: [AttachmentView]? = nil,
card: CardView? = nil,
collectionIds: [String] = [],
Expand Down Expand Up @@ -140,11 +143,13 @@ extension CipherView {
passwordHistory: passwordHistory,
creationDate: creationDate,
deletedDate: deletedDate,
revisionDate: revisionDate
revisionDate: revisionDate,
archivedDate: archivedDate
)
}

static func cardFixture(
archivedDate: Date? = nil,
attachments: [AttachmentView]? = nil,
card: CardView = CardView.fixture(),
collectionIds: [String] = [],
Expand Down Expand Up @@ -193,11 +198,13 @@ extension CipherView {
passwordHistory: passwordHistory,
creationDate: creationDate,
deletedDate: deletedDate,
revisionDate: revisionDate
revisionDate: revisionDate,
archivedDate: archivedDate
)
}

static func loginFixture(
archivedDate: Date? = nil,
attachments: [AttachmentView]? = nil,
collectionIds: [String] = [],
creationDate: DateTime = Date(year: 2023, month: 11, day: 5, hour: 9, minute: 41),
Expand Down Expand Up @@ -246,7 +253,8 @@ extension CipherView {
passwordHistory: passwordHistory,
creationDate: creationDate,
deletedDate: deletedDate,
revisionDate: revisionDate
revisionDate: revisionDate,
archivedDate: archivedDate
)
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import BitwardenKit
import BitwardenSdk

@testable import BitwardenShared
Expand Down Expand Up @@ -45,6 +46,28 @@ class MockCryptoClient: CryptoClientProtocol {
var initializeUserCryptoRequest: InitUserCryptoRequest?
var initializeUserCryptoResult: Result<Void, Error> = .success(())

var makeUpdateKdfKdf: Kdf?
var makeUpdateKdfPassword: String?
var makeUpdateKdfResult: Result<UpdateKdfResponse, Error> = .success(
UpdateKdfResponse(
masterPasswordAuthenticationData: MasterPasswordAuthenticationData(
kdf: .pbkdf2(iterations: NonZeroU32(Constants.pbkdf2Iterations)),
salt: "AUTHENTICATION_SALT",
masterPasswordAuthenticationHash: "MASTER_PASSWORD_AUTHENTICATION_HASH"
),
masterPasswordUnlockData: MasterPasswordUnlockData(
kdf: .pbkdf2(iterations: NonZeroU32(Constants.pbkdf2Iterations)),
masterKeyWrappedUserKey: "MASTER_KEY_WRAPPED_USER_KEY",
salt: "UNLOCK_SALT"
),
oldMasterPasswordAuthenticationData: MasterPasswordAuthenticationData(
kdf: .pbkdf2(iterations: NonZeroU32(Constants.pbkdf2Iterations)),
salt: "OLD_AUTHENTICATION_SALT",
masterPasswordAuthenticationHash: "MASTER_PASSWORD_AUTHENTICATION_HASH"
)
)
)

var updatePasswordNewPassword: String?
var updatePasswordResult: Result<UpdatePasswordResponse, Error> = .success(
UpdatePasswordResponse(
Expand Down Expand Up @@ -97,6 +120,17 @@ class MockCryptoClient: CryptoClientProtocol {
return try initializeUserCryptoResult.get()
}

func makeUpdateKdf(password: String, kdf: Kdf) throws -> UpdateKdfResponse {
makeUpdateKdfPassword = password
makeUpdateKdfKdf = kdf
return try makeUpdateKdfResult.get()
}

func makeUpdatePassword(newPassword: String) throws -> UpdatePasswordResponse {
updatePasswordNewPassword = newPassword
return try updatePasswordResult.get()
}

func updatePassword(newPassword: String) throws -> BitwardenSdk.UpdatePasswordResponse {
updatePasswordNewPassword = newPassword
return try updatePasswordResult.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ extension CipherDetailsResponseModel {
init(cipher: BitwardenSdk.Cipher) throws {
guard let id = cipher.id else { throw DataMappingError.invalidData }
self.init(
archivedDate: cipher.archivedDate,
attachments: cipher.attachments?.map(AttachmentResponseModel.init),
card: cipher.card.map(CipherCardModel.init),
collectionIds: cipher.collectionIds,
Expand Down Expand Up @@ -353,7 +354,8 @@ extension BitwardenSdk.Cipher {
passwordHistory: model.passwordHistory?.map(PasswordHistory.init),
creationDate: model.creationDate,
deletedDate: model.deletedDate,
revisionDate: model.revisionDate
revisionDate: model.revisionDate,
archivedDate: model.archivedDate
)
}
}
Expand Down Expand Up @@ -432,7 +434,8 @@ extension BitwardenSdk.CipherView: @retroactive Identifiable, Fido2UserVerifiabl
passwordHistory: nil,
creationDate: timeProvider.presentTime,
deletedDate: nil,
revisionDate: timeProvider.presentTime
revisionDate: timeProvider.presentTime,
archivedDate: nil
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ class CipherViewTests: BitwardenTestCase {
passwordHistory: nil,
creationDate: timeProvider.presentTime,
deletedDate: nil,
revisionDate: timeProvider.presentTime
revisionDate: timeProvider.presentTime,
archivedDate: nil
)
)
}
Expand Down Expand Up @@ -258,7 +259,8 @@ class CipherViewTests: BitwardenTestCase {
passwordHistory: nil,
creationDate: timeProvider.presentTime,
deletedDate: nil,
revisionDate: timeProvider.presentTime
revisionDate: timeProvider.presentTime,
archivedDate: nil
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ extension CipherListView {
creationDate: cipher.creationDate,
deletedDate: cipher.deletedDate,
revisionDate: cipher.revisionDate,
archivedDate: cipher.archivedDate,
copyableFields: [],
localData: nil
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ extension CipherListView {
creationDate: Date = Date(),
deletedDate: Date? = nil,
revisionDate: Date = Date(),
archivedDate: Date? = nil,
copyableFields: [CopyableCipherFields] = [],
localData: LocalDataView? = nil
) -> CipherListView {
Expand All @@ -45,6 +46,7 @@ extension CipherListView {
creationDate: creationDate,
deletedDate: deletedDate,
revisionDate: revisionDate,
archivedDate: archivedDate,
copyableFields: copyableFields,
localData: localData
)
Expand All @@ -70,6 +72,7 @@ extension CipherListView {
creationDate: Date = Date(),
deletedDate: Date? = nil,
revisionDate: Date = Date(),
archivedDate: Date? = nil,
copyableFields: [CopyableCipherFields] = [],
localData: LocalDataView? = nil
) -> CipherListView {
Expand All @@ -93,6 +96,7 @@ extension CipherListView {
creationDate: creationDate,
deletedDate: deletedDate,
revisionDate: revisionDate,
archivedDate: archivedDate,
copyableFields: copyableFields,
localData: localData
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import Networking
struct CipherDetailsResponseModel: JSONResponse, Equatable {
// MARK: Properties

/// The date the cipher was archived.
let archivedDate: Date?

/// The cipher's list of attachments.
let attachments: [AttachmentResponseModel]?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Foundation

extension CipherDetailsResponseModel {
static func fixture(
archivedDate: Date? = nil,
attachments: [AttachmentResponseModel]? = nil,
card: CipherCardModel? = nil,
collectionIds: [String] = [],
Expand Down Expand Up @@ -31,6 +32,7 @@ extension CipherDetailsResponseModel {
viewPassword: Bool = false
) -> CipherDetailsResponseModel {
self.init(
archivedDate: archivedDate,
attachments: attachments,
card: card,
collectionIds: collectionIds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class CipherAPIServiceTests: XCTestCase { // swiftlint:disable:this type_body_le
XCTAssertEqual(
response,
CipherDetailsResponseModel(
archivedDate: nil,
attachments: nil,
card: nil,
collectionIds: nil,
Expand Down Expand Up @@ -101,6 +102,7 @@ class CipherAPIServiceTests: XCTestCase { // swiftlint:disable:this type_body_le
XCTAssertEqual(
response,
CipherDetailsResponseModel(
archivedDate: nil,
attachments: nil,
card: nil,
collectionIds: nil,
Expand Down Expand Up @@ -221,6 +223,7 @@ class CipherAPIServiceTests: XCTestCase { // swiftlint:disable:this type_body_le
SaveAttachmentResponse(
attachmentId: "1",
cipherResponse: CipherDetailsResponseModel(
archivedDate: nil,
attachments: [
.init(
fileName: "2.q4Pl+Pz7D3sxr1VEKuwke",
Expand Down Expand Up @@ -287,6 +290,7 @@ class CipherAPIServiceTests: XCTestCase { // swiftlint:disable:this type_body_le
XCTAssertEqual(
response,
CipherDetailsResponseModel(
archivedDate: nil,
attachments: nil,
card: nil,
collectionIds: nil,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ extension CipherListView {
creationDate: cipher.creationDate,
deletedDate: cipher.deletedDate,
revisionDate: cipher.revisionDate,
archivedDate: cipher.archivedDate,
copyableFields: [],
localData: cipher.localData.map(LocalDataView.init)
)
Expand Down Expand Up @@ -138,7 +139,8 @@ extension Cipher {
passwordHistory: cipherView.passwordHistory?.map(PasswordHistory.init),
creationDate: cipherView.creationDate,
deletedDate: cipherView.deletedDate,
revisionDate: cipherView.revisionDate
revisionDate: cipherView.revisionDate,
archivedDate: cipherView.archivedDate
)
}
}
Expand Down Expand Up @@ -171,7 +173,8 @@ extension CipherView {
passwordHistory: cipher.passwordHistory?.map(PasswordHistoryView.init),
creationDate: cipher.creationDate,
deletedDate: cipher.deletedDate,
revisionDate: cipher.revisionDate
revisionDate: cipher.revisionDate,
archivedDate: cipher.archivedDate
)
}
}
Expand Down
Loading