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 @@ -603,7 +603,8 @@ final class AuthenticatorSyncServiceTests: BitwardenTestCase { // swiftlint:disa
/// The sync service should handle multiple vaults being sync'd at the same time.
///
@MainActor
func test_determineSyncForUserId_unlockMultipleVaults() async throws { // swiftlint:disable:this function_body_length
func test_determineSyncForUserId_unlockMultipleVaults() async throws {
// swiftlint:disable:previous function_body_length
setupInitialState()
cipherDataStore.cipherSubjectByUserId["2"] = CurrentValueSubject<[Cipher], Error>([])
await subject.start()
Expand Down Expand Up @@ -959,7 +960,9 @@ final class AuthenticatorSyncServiceTests: BitwardenTestCase { // swiftlint:disa
XCTAssertEqual(items.first?.id, "1234")
XCTAssertNotNil(authenticatorClientService.mockCrypto.initializeUserCryptoRequest)
XCTAssertNotNil(authenticatorClientService.mockCrypto.initializeOrgCryptoRequest)
XCTAssertEqual(authenticatorClientService.mockCrypto.initializeOrgCryptoRequest?.organizationKeys, ["org-1": "key-org-1"])
XCTAssertEqual(
authenticatorClientService.mockCrypto.initializeOrgCryptoRequest?.organizationKeys, ["org-1": "key-org-1"]
)
XCTAssertTrue(authenticatorClientService.userClientArray.isEmpty)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ actor DefaultClientService: ClientService {
return clientBuilder.buildClient()
}
}

/// Configures a new SDK client.
/// - Parameters:
/// - client: The SDK client to configure.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class ClientServiceTests: BitwardenTestCase { // swiftlint:disable:this ty
configService = MockConfigService()
errorReporter = MockErrorReporter()
sdkRepositoryFactory = MockSdkRepositoryFactory()
sdkRepositoryFactory.makeCipherRepositoryUserIdReturnValue = MockSdkCipherRepository()
sdkRepositoryFactory.makeCipherRepositoryReturnValue = MockSdkCipherRepository()
stateService = MockStateService()
subject = DefaultClientService(
clientBuilder: clientBuilder,
Expand Down Expand Up @@ -227,7 +227,7 @@ final class ClientServiceTests: BitwardenTestCase { // swiftlint:disable:this ty
let auth = try await subject.auth()
let client = try XCTUnwrap(clientBuilder.clients.first)
XCTAssertIdentical(auth, client.authClient)
XCTAssertTrue(sdkRepositoryFactory.makeCipherRepositoryUserIdCalled)
XCTAssertTrue(sdkRepositoryFactory.makeCipherRepositoryCalled)
XCTAssertNotNil(client.platformClient.stateMock.registerCipherRepositoryReceivedStore)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,51 @@ extension MockVaultListPreparedDataBuilder {
func setUpCallOrderHelper() -> MockCallOrderHelper {
let helper = MockCallOrderHelper()

addCipherDecryptionFailureCipherClosure = { _ -> VaultListPreparedDataBuilder in
addCipherDecryptionFailureClosure = { _ -> VaultListPreparedDataBuilder in
helper.recordCall("addCipherDecryptionFailure")
return self
}
addFavoriteItemCipherClosure = { _ -> VaultListPreparedDataBuilder in
addFavoriteItemClosure = { _ -> VaultListPreparedDataBuilder in
helper.recordCall("addFavoriteItem")
return self
}
addFolderItemCipherFilterFoldersClosure = { _, _, _ -> VaultListPreparedDataBuilder in
addFolderItemClosure = { _, _, _ -> VaultListPreparedDataBuilder in
helper.recordCall("addFolderItem")
return self
}
addItemForGroupWithClosure = { _, _ -> VaultListPreparedDataBuilder in
addItemClosure = { _, _ -> VaultListPreparedDataBuilder in
helper.recordCall("addItemForGroup")
return self
}
addNoFolderItemCipherClosure = { _ -> VaultListPreparedDataBuilder in
addNoFolderItemClosure = { _ -> VaultListPreparedDataBuilder in
helper.recordCall("addNoFolderItem")
return self
}
incrementCipherTypeCountCipherClosure = { _ -> VaultListPreparedDataBuilder in
incrementCipherTypeCountClosure = { _ -> VaultListPreparedDataBuilder in
helper.recordCall("incrementCipherTypeCount")
return self
}
incrementCipherDeletedCountClosure = { () -> VaultListPreparedDataBuilder in
helper.recordCall("incrementCipherDeletedCount")
return self
}
incrementCollectionCountCipherClosure = { _ -> VaultListPreparedDataBuilder in
incrementCollectionCountClosure = { _ -> VaultListPreparedDataBuilder in
helper.recordCall("incrementCollectionCount")
return self
}
incrementTOTPCountCipherClosure = { _ async -> VaultListPreparedDataBuilder in
incrementTOTPCountClosure = { _ async -> VaultListPreparedDataBuilder in
helper.recordCall("incrementTOTPCount")
return self
}
prepareCollectionsCollectionsFilterTypeClosure = { _, _ -> VaultListPreparedDataBuilder in
prepareCollectionsClosure = { _, _ -> VaultListPreparedDataBuilder in
helper.recordCall("prepareCollections")
return self
}
prepareFoldersFoldersFilterTypeClosure = { _, _ -> VaultListPreparedDataBuilder in
prepareFoldersClosure = { _, _ -> VaultListPreparedDataBuilder in
helper.recordCall("prepareFolders")
return self
}
prepareRestrictItemsPolicyOrganizationsRestrictedOrganizationIdsClosure = { _ -> VaultListPreparedDataBuilder in
prepareRestrictItemsPolicyOrganizationsClosure = { _ -> VaultListPreparedDataBuilder in
helper.recordCall("prepareRestrictItemsPolicyOrganizations")
return self
}
Expand All @@ -61,17 +61,17 @@ extension MockVaultListPreparedDataBuilder {
}

func setUpFluentReturn() {
addCipherDecryptionFailureCipherReturnValue = self
addFavoriteItemCipherReturnValue = self
addFolderItemCipherFilterFoldersReturnValue = self
addItemForGroupWithReturnValue = self
addNoFolderItemCipherReturnValue = self
incrementCipherTypeCountCipherReturnValue = self
addCipherDecryptionFailureReturnValue = self
addFavoriteItemReturnValue = self
addFolderItemReturnValue = self
addItemReturnValue = self
addNoFolderItemReturnValue = self
incrementCipherTypeCountReturnValue = self
incrementCipherDeletedCountReturnValue = self
incrementCollectionCountCipherReturnValue = self
incrementTOTPCountCipherReturnValue = self
prepareCollectionsCollectionsFilterTypeReturnValue = self
prepareFoldersFoldersFilterTypeReturnValue = self
prepareRestrictItemsPolicyOrganizationsRestrictedOrganizationIdsReturnValue = self
incrementCollectionCountReturnValue = self
incrementTOTPCountReturnValue = self
prepareCollectionsReturnValue = self
prepareFoldersReturnValue = self
prepareRestrictItemsPolicyOrganizationsReturnValue = self
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ extension MockVaultListSectionsBuilder {
helper.recordCall("addTypesSection")
return self
}
addFoldersSectionNestedFolderIdClosure = { (_: String?) throws -> VaultListSectionsBuilder in
addFoldersSectionClosure = { (_: String?) throws -> VaultListSectionsBuilder in
helper.recordCall("addFoldersSection")
return self
}
addCollectionsSectionNestedCollectionIdClosure = { (_: String?) throws -> VaultListSectionsBuilder in
addCollectionsSectionClosure = { (_: String?) throws -> VaultListSectionsBuilder in
helper.recordCall("addCollectionsSection")
return self
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class MainVaultListDirectorStrategyTests: BitwardenTestCase {
vaultListSectionsBuilder = MockVaultListSectionsBuilder()
mockCallOrderHelper = vaultListSectionsBuilder.setUpCallOrderHelper()
vaultListSectionsBuilderFactory = MockVaultListSectionsBuilderFactory()
vaultListSectionsBuilderFactory.makeWithDataReturnValue = vaultListSectionsBuilder
vaultListSectionsBuilderFactory.makeReturnValue = vaultListSectionsBuilder

subject = MainVaultListDirectorStrategy(
builderFactory: vaultListSectionsBuilderFactory,
Expand Down Expand Up @@ -74,7 +74,7 @@ class MainVaultListDirectorStrategyTests: BitwardenTestCase {
collectionService.collectionsSubject.value = []
folderService.foldersSubject.value = []

vaultListDataPreparator.prepareDataFromCollectionsFoldersFilterReturnValue = nil
vaultListDataPreparator.prepareDataReturnValue = nil

var iteratorPublisher = try await subject.build(filter: VaultListFilter()).makeAsyncIterator()
let vaultListData = try await iteratorPublisher.next()
Expand All @@ -88,7 +88,7 @@ class MainVaultListDirectorStrategyTests: BitwardenTestCase {
collectionService.collectionsSubject.value = []
folderService.foldersSubject.value = []

vaultListDataPreparator.prepareDataFromCollectionsFoldersFilterReturnValue = VaultListPreparedData()
vaultListDataPreparator.prepareDataReturnValue = VaultListPreparedData()

vaultListSectionsBuilder.buildReturnValue = VaultListData(
sections: [
Expand Down Expand Up @@ -125,7 +125,7 @@ class MainVaultListDirectorStrategyTests: BitwardenTestCase {
collectionService.collectionsSubject.value = []
folderService.foldersSubject.value = []

vaultListDataPreparator.prepareDataFromCollectionsFoldersFilterReturnValue = VaultListPreparedData()
vaultListDataPreparator.prepareDataReturnValue = VaultListPreparedData()

vaultListSectionsBuilder.buildReturnValue = VaultListData(
sections: [
Expand Down Expand Up @@ -162,7 +162,7 @@ class MainVaultListDirectorStrategyTests: BitwardenTestCase {
collectionService.collectionsSubject.value = []
folderService.foldersSubject.value = []

vaultListDataPreparator.prepareDataFromCollectionsFoldersFilterReturnValue = VaultListPreparedData()
vaultListDataPreparator.prepareDataReturnValue = VaultListPreparedData()

vaultListSectionsBuilder.buildReturnValue = VaultListData(
sections: [
Expand Down Expand Up @@ -198,7 +198,7 @@ class MainVaultListDirectorStrategyTests: BitwardenTestCase {
collectionService.collectionsSubject.value = []
folderService.foldersSubject.value = []

vaultListDataPreparator.prepareDataFromCollectionsFoldersFilterReturnValue = VaultListPreparedData()
vaultListDataPreparator.prepareDataReturnValue = VaultListPreparedData()

vaultListSectionsBuilder.buildReturnValue = VaultListData(
sections: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class MainVaultListGroupDirectorStrategyTests: BitwardenTestCase {
vaultListSectionsBuilder = MockVaultListSectionsBuilder()
mockCallOrderHelper = vaultListSectionsBuilder.setUpCallOrderHelper()
vaultListSectionsBuilderFactory = MockVaultListSectionsBuilderFactory()
vaultListSectionsBuilderFactory.makeWithDataReturnValue = vaultListSectionsBuilder
vaultListSectionsBuilderFactory.makeReturnValue = vaultListSectionsBuilder

subject = MainVaultListGroupDirectorStrategy(
builderFactory: vaultListSectionsBuilderFactory,
Expand Down Expand Up @@ -74,7 +74,7 @@ class MainVaultListGroupDirectorStrategyTests: BitwardenTestCase {
collectionService.collectionsSubject.value = []
folderService.foldersSubject.value = []

vaultListDataPreparator.prepareGroupDataFromCollectionsFoldersFilterReturnValue = nil
vaultListDataPreparator.prepareGroupDataReturnValue = nil

var iteratorPublisher = try await subject.build(filter: VaultListFilter()).makeAsyncIterator()
let vaultListData = try await iteratorPublisher.next()
Expand All @@ -88,7 +88,7 @@ class MainVaultListGroupDirectorStrategyTests: BitwardenTestCase {
collectionService.collectionsSubject.value = []
folderService.foldersSubject.value = []

vaultListDataPreparator.prepareGroupDataFromCollectionsFoldersFilterReturnValue = VaultListPreparedData()
vaultListDataPreparator.prepareGroupDataReturnValue = VaultListPreparedData()

vaultListSectionsBuilder.buildReturnValue = VaultListData(
sections: [
Expand Down Expand Up @@ -118,7 +118,7 @@ class MainVaultListGroupDirectorStrategyTests: BitwardenTestCase {
collectionService.collectionsSubject.value = []
folderService.foldersSubject.value = []

vaultListDataPreparator.prepareGroupDataFromCollectionsFoldersFilterReturnValue = VaultListPreparedData()
vaultListDataPreparator.prepareGroupDataReturnValue = VaultListPreparedData()

vaultListSectionsBuilder.buildReturnValue = VaultListData(
sections: [
Expand Down Expand Up @@ -149,7 +149,7 @@ class MainVaultListGroupDirectorStrategyTests: BitwardenTestCase {
collectionService.collectionsSubject.value = []
folderService.foldersSubject.value = []

vaultListDataPreparator.prepareGroupDataFromCollectionsFoldersFilterReturnValue = VaultListPreparedData()
vaultListDataPreparator.prepareGroupDataReturnValue = VaultListPreparedData()

vaultListSectionsBuilder.buildReturnValue = VaultListData(
sections: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ protocol VaultListPreparedDataBuilder { // sourcery: AutoMockable
/// Prepares folders to the prepared data that then can be used for filtering.
func prepareFolders(folders: [Folder], filterType: VaultFilterType) -> VaultListPreparedDataBuilder
/// Prepares the sections with restricted organization IDs.
@discardableResult
func prepareRestrictItemsPolicyOrganizations(restrictedOrganizationIds: [String]) -> VaultListPreparedDataBuilder
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ class DefaultVaultListSectionsBuilder: VaultListSectionsBuilder {
}

func addFoldersSection(nestedFolderId: String? = nil) async throws -> VaultListSectionsBuilder {
// swiftlint:disable:previous function_body_length
guard !preparedData.folders.isEmpty else {
return self
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class VaultRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_b
stateService = MockStateService()

vaultListDirectorStrategy = MockVaultListDirectorStrategy()
vaultListDirectorStrategyFactory.makeFilterReturnValue = vaultListDirectorStrategy
vaultListDirectorStrategyFactory.makeReturnValue = vaultListDirectorStrategy

subject = DefaultVaultRepository(
cipherService: cipherService,
Expand Down Expand Up @@ -238,7 +238,7 @@ class VaultRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_b
.setFailureType(to: Error.self)
.eraseToAnyPublisher()

vaultListDirectorStrategy.buildFilterReturnValue = AsyncThrowingPublisher(publisher)
vaultListDirectorStrategy.buildReturnValue = AsyncThrowingPublisher(publisher)

var iterator = try await subject.ciphersAutofillPublisher(
availableFido2CredentialsPublisher: MockFido2UserInterfaceHelper()
Expand All @@ -251,9 +251,9 @@ class VaultRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_b
let vaultListData = try await iterator.next()
let sections = try XCTUnwrap(vaultListData?.sections)

XCTAssertTrue(vaultListDirectorStrategyFactory.makeFilterCalled)
XCTAssertNotNil(vaultListDirectorStrategyFactory.makeFilterReceivedFilter)
XCTAssertTrue(vaultListDirectorStrategy.buildFilterCalled)
XCTAssertTrue(vaultListDirectorStrategyFactory.makeCalled)
XCTAssertNotNil(vaultListDirectorStrategyFactory.makeReceivedFilter)
XCTAssertTrue(vaultListDirectorStrategy.buildCalled)
XCTAssertEqual(sections.count, 1)
XCTAssertEqual(sections[safeIndex: 0]?.id, "1")
XCTAssertEqual(sections[safeIndex: 0]?.name, "TestingSection")
Expand Down Expand Up @@ -2830,16 +2830,16 @@ class VaultRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_b
.setFailureType(to: Error.self)
.eraseToAnyPublisher()

vaultListDirectorStrategy.buildFilterReturnValue = AsyncThrowingPublisher(publisher)
vaultListDirectorStrategy.buildReturnValue = AsyncThrowingPublisher(publisher)

let filter = VaultListFilter(addTOTPGroup: true)
var iterator = try await subject.vaultListPublisher(filter: filter).makeAsyncIterator()
let vaultListData = try await iterator.next()
let sections = try XCTUnwrap(vaultListData?.sections)

XCTAssertTrue(vaultListDirectorStrategyFactory.makeFilterCalled)
XCTAssertNotNil(vaultListDirectorStrategyFactory.makeFilterReceivedFilter)
XCTAssertTrue(vaultListDirectorStrategy.buildFilterCalled)
XCTAssertTrue(vaultListDirectorStrategyFactory.makeCalled)
XCTAssertNotNil(vaultListDirectorStrategyFactory.makeReceivedFilter)
XCTAssertTrue(vaultListDirectorStrategy.buildCalled)
XCTAssertEqual(sections.count, 1)
XCTAssertEqual(sections[safeIndex: 0]?.id, "1")
XCTAssertEqual(sections[safeIndex: 0]?.name, "TestingSection")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ final class ExportVaultServiceTests: BitwardenTestCase { // swiftlint:disable:th
)
}

/// `exportVaultFileContents(format:)` still applies login/secureNote filter when using CSV export with restrictedTypes
/// `exportVaultFileContents(format:)` still applies login/secureNote filter when using CSV export
/// with restrictedTypes.
///
func test_fileContent_restrictedTypes_csvWithRestrictions() async throws {
clientService.mockExporters.exportVaultResult = .success("success")
Expand Down
2 changes: 1 addition & 1 deletion BitwardenShared/Core/Vault/Services/SyncService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class DefaultSyncService: SyncService {
return true
}

if isPeriodic && lastSyncTime.addingTimeInterval(Constants.minimumSyncInterval) >= timeProvider.presentTime {
if isPeriodic, lastSyncTime.addingTimeInterval(Constants.minimumSyncInterval) >= timeProvider.presentTime {
return false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ struct BitwardenMenuField<
includeLineSpacing: false
)
.foregroundColor(isEnabled
? SharedAsset.Colors.textSecondary.swiftUIColor
: SharedAsset.Colors.buttonFilledDisabledForeground.swiftUIColor
? SharedAsset.Colors.textSecondary.swiftUIColor
: SharedAsset.Colors.buttonFilledDisabledForeground.swiftUIColor
)
.onSizeChanged { size in
titleWidth = size.width
Expand Down
Loading