From c0b97ec21fea4cf599d19801325e046796e0a5fc Mon Sep 17 00:00:00 2001 From: Thomas Rittson Date: Mon, 28 Oct 2024 11:10:54 +1000 Subject: [PATCH] WIP updating callers --- apps/cli/src/commands/get.command.ts | 19 ++++++++++++------- apps/cli/src/commands/list.command.ts | 8 +++++++- apps/cli/src/oss-serve-configurator.ts | 2 +- apps/cli/src/tools/send/send.program.ts | 1 - apps/cli/src/vault.program.ts | 2 +- .../vault/app/vault/collections.component.ts | 3 --- .../unsecured-websites-report.component.ts | 3 +++ ...nsecured-websites-report.component.spec.ts | 10 ++++++++++ .../unsecured-websites-report.component.ts | 10 +++++++++- .../add-edit-v2.component.spec.ts | 2 +- .../bulk-share-dialog.component.ts | 13 +++++++------ .../services/vault-filter.service.spec.ts | 3 ++- .../services/vault-filter.service.ts | 10 ++++++++-- .../vault/individual-vault/vault.component.ts | 4 +++- .../individual-vault/view.component.spec.ts | 4 ++++ .../vault-filter/vault-filter.service.ts | 3 +++ 16 files changed, 71 insertions(+), 26 deletions(-) diff --git a/apps/cli/src/commands/get.command.ts b/apps/cli/src/commands/get.command.ts index fc014534e0..38df5dd9a7 100644 --- a/apps/cli/src/commands/get.command.ts +++ b/apps/cli/src/commands/get.command.ts @@ -21,11 +21,10 @@ import { LoginExport } from "@bitwarden/common/models/export/login.export"; import { SecureNoteExport } from "@bitwarden/common/models/export/secure-note.export"; import { ErrorResponse } from "@bitwarden/common/models/response/error.response"; import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service"; -import { StateService } from "@bitwarden/common/platform/abstractions/state.service"; import { Utils } from "@bitwarden/common/platform/misc/utils"; import { EncString } from "@bitwarden/common/platform/models/domain/enc-string"; import { SendType } from "@bitwarden/common/tools/send/enums/send-type"; -import { OrganizationId } from "@bitwarden/common/types/guid"; +import { CollectionId, OrganizationId } from "@bitwarden/common/types/guid"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction"; import { TotpService } from "@bitwarden/common/vault/abstractions/totp.service"; @@ -48,6 +47,7 @@ import { CollectionResponse } from "../vault/models/collection.response"; import { FolderResponse } from "../vault/models/folder.response"; import { DownloadCommand } from "./download.command"; +import { getUserId } from "@bitwarden/common/auth/services/account.service"; export class GetCommand extends DownloadCommand { constructor( @@ -58,7 +58,6 @@ export class GetCommand extends DownloadCommand { private auditService: AuditService, private keyService: KeyService, encryptService: EncryptService, - private stateService: StateService, private searchService: SearchService, private apiService: ApiService, private organizationService: OrganizationService, @@ -95,7 +94,7 @@ export class GetCommand extends DownloadCommand { case "folder": return await this.getFolder(id); case "collection": - return await this.getCollection(id); + return await this.getCollection(id as CollectionId); case "org-collection": return await this.getOrganizationCollection(id, normalizedOptions); case "organization": @@ -406,10 +405,14 @@ export class GetCommand extends DownloadCommand { return Response.success(res); } - private async getCollection(id: string) { + private async getCollection(id: CollectionId) { + const activeUserId$ = this.accountService.activeAccount$.pipe(getUserId); + let decCollection: CollectionView = null; if (Utils.isGuid(id)) { - const collection = await this.collectionService.get(id); + const collection = ( + await firstValueFrom(this.collectionService.encryptedCollections$(activeUserId$)) + ).find((c) => c.id === id); if (collection != null) { const orgKeys = await firstValueFrom(this.keyService.activeUserOrgKeys$); decCollection = await collection.decrypt( @@ -417,7 +420,9 @@ export class GetCommand extends DownloadCommand { ); } } else if (id.trim() !== "") { - let collections = await this.collectionService.getAllDecrypted(); + let collections = await firstValueFrom( + this.collectionService.decryptedCollections$(activeUserId$), + ); collections = CliUtils.searchCollections(collections, id); if (collections.length > 1) { return Response.multipleResults(collections.map((c) => c.id)); diff --git a/apps/cli/src/commands/list.command.ts b/apps/cli/src/commands/list.command.ts index 9cb36f7149..8adc918729 100644 --- a/apps/cli/src/commands/list.command.ts +++ b/apps/cli/src/commands/list.command.ts @@ -12,6 +12,8 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service"; import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service"; import { SearchService } from "@bitwarden/common/abstractions/search.service"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; +import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; +import { getUserId } from "@bitwarden/common/auth/services/account.service"; import { EventType } from "@bitwarden/common/enums"; import { ListResponse as ApiListResponse } from "@bitwarden/common/models/response/list.response"; import { Utils } from "@bitwarden/common/platform/misc/utils"; @@ -38,6 +40,7 @@ export class ListCommand { private organizationUserApiService: OrganizationUserApiService, private apiService: ApiService, private eventCollectionService: EventCollectionService, + private accountService: AccountService, ) {} async run(object: string, cmdOptions: Record): Promise { @@ -146,7 +149,10 @@ export class ListCommand { } private async listCollections(options: Options) { - let collections = await this.collectionService.getAllDecrypted(); + const activeUserId$ = this.accountService.activeAccount$.pipe(getUserId); + let collections = await firstValueFrom( + this.collectionService.decryptedCollections$(activeUserId$), + ); if (options.organizationId != null) { collections = collections.filter((c) => { diff --git a/apps/cli/src/oss-serve-configurator.ts b/apps/cli/src/oss-serve-configurator.ts index a25357f6f6..2b87d8bf44 100644 --- a/apps/cli/src/oss-serve-configurator.ts +++ b/apps/cli/src/oss-serve-configurator.ts @@ -58,7 +58,6 @@ export class OssServeConfigurator { this.serviceContainer.auditService, this.serviceContainer.keyService, this.serviceContainer.encryptService, - this.serviceContainer.stateService, this.serviceContainer.searchService, this.serviceContainer.apiService, this.serviceContainer.organizationService, @@ -75,6 +74,7 @@ export class OssServeConfigurator { this.serviceContainer.organizationUserApiService, this.serviceContainer.apiService, this.serviceContainer.eventCollectionService, + this.serviceContainer.accountService, ); this.createCommand = new CreateCommand( this.serviceContainer.cipherService, diff --git a/apps/cli/src/tools/send/send.program.ts b/apps/cli/src/tools/send/send.program.ts index 60e78137e7..d70b810221 100644 --- a/apps/cli/src/tools/send/send.program.ts +++ b/apps/cli/src/tools/send/send.program.ts @@ -144,7 +144,6 @@ export class SendProgram extends BaseProgram { this.serviceContainer.auditService, this.serviceContainer.keyService, this.serviceContainer.encryptService, - this.serviceContainer.stateService, this.serviceContainer.searchService, this.serviceContainer.apiService, this.serviceContainer.organizationService, diff --git a/apps/cli/src/vault.program.ts b/apps/cli/src/vault.program.ts index 4d3215944e..08f0fc087d 100644 --- a/apps/cli/src/vault.program.ts +++ b/apps/cli/src/vault.program.ts @@ -111,6 +111,7 @@ export class VaultProgram extends BaseProgram { this.serviceContainer.organizationUserApiService, this.serviceContainer.apiService, this.serviceContainer.eventCollectionService, + this.serviceContainer.accountService, ); const response = await command.run(object, cmd); @@ -179,7 +180,6 @@ export class VaultProgram extends BaseProgram { this.serviceContainer.auditService, this.serviceContainer.keyService, this.serviceContainer.encryptService, - this.serviceContainer.stateService, this.serviceContainer.searchService, this.serviceContainer.apiService, this.serviceContainer.organizationService, diff --git a/apps/desktop/src/vault/app/vault/collections.component.ts b/apps/desktop/src/vault/app/vault/collections.component.ts index e7684c3c07..a30fb1e2ed 100644 --- a/apps/desktop/src/vault/app/vault/collections.component.ts +++ b/apps/desktop/src/vault/app/vault/collections.component.ts @@ -5,7 +5,6 @@ import { CollectionsComponent as BaseCollectionsComponent } from "@bitwarden/ang import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; -import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { ToastService } from "@bitwarden/components"; @@ -21,7 +20,6 @@ export class CollectionsComponent extends BaseCollectionsComponent { collectionService: CollectionService, platformUtilsService: PlatformUtilsService, organizationService: OrganizationService, - logService: LogService, accountService: AccountService, toastService: ToastService, ) { @@ -31,7 +29,6 @@ export class CollectionsComponent extends BaseCollectionsComponent { i18nService, cipherService, organizationService, - logService, accountService, toastService, ); diff --git a/apps/web/src/app/admin-console/organizations/tools/unsecured-websites-report.component.ts b/apps/web/src/app/admin-console/organizations/tools/unsecured-websites-report.component.ts index 990cf50540..f1a8e087ce 100644 --- a/apps/web/src/app/admin-console/organizations/tools/unsecured-websites-report.component.ts +++ b/apps/web/src/app/admin-console/organizations/tools/unsecured-websites-report.component.ts @@ -4,6 +4,7 @@ import { ActivatedRoute } from "@angular/router"; import { CollectionService } from "@bitwarden/admin-console/common"; import { ModalService } from "@bitwarden/angular/services/modal.service"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; +import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; @@ -31,6 +32,7 @@ export class UnsecuredWebsitesReportComponent i18nService: I18nService, syncService: SyncService, collectionService: CollectionService, + accountService: AccountService, ) { super( cipherService, @@ -40,6 +42,7 @@ export class UnsecuredWebsitesReportComponent i18nService, syncService, collectionService, + accountService, ); } diff --git a/apps/web/src/app/tools/reports/pages/unsecured-websites-report.component.spec.ts b/apps/web/src/app/tools/reports/pages/unsecured-websites-report.component.spec.ts index 5f66814fdf..fe97a254b0 100644 --- a/apps/web/src/app/tools/reports/pages/unsecured-websites-report.component.spec.ts +++ b/apps/web/src/app/tools/reports/pages/unsecured-websites-report.component.spec.ts @@ -7,7 +7,10 @@ import { CollectionService } from "@bitwarden/admin-console/common"; import { I18nPipe } from "@bitwarden/angular/platform/pipes/i18n.pipe"; import { ModalService } from "@bitwarden/angular/services/modal.service"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; +import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; +import { FakeAccountService, mockAccountServiceWith } from "@bitwarden/common/spec"; +import { UserId } from "@bitwarden/common/types/guid"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; import { PasswordRepromptService } from "@bitwarden/vault"; @@ -21,12 +24,15 @@ describe("UnsecuredWebsitesReportComponent", () => { let organizationService: MockProxy; let syncServiceMock: MockProxy; let collectionService: MockProxy; + let accountService: FakeAccountService; beforeEach(() => { organizationService = mock(); organizationService.organizations$ = of([]); syncServiceMock = mock(); collectionService = mock(); + collectionService.encryptedCollections$.mockReturnValue(of([])); + accountService = mockAccountServiceWith("UserId" as UserId); // FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling. // eslint-disable-next-line @typescript-eslint/no-floating-promises TestBed.configureTestingModule({ @@ -60,6 +66,10 @@ describe("UnsecuredWebsitesReportComponent", () => { provide: CollectionService, useValue: collectionService, }, + { + provide: AccountService, + useValue: accountService, + }, ], schemas: [], }).compileComponents(); diff --git a/apps/web/src/app/tools/reports/pages/unsecured-websites-report.component.ts b/apps/web/src/app/tools/reports/pages/unsecured-websites-report.component.ts index 6a1ba1f633..f4be7b1303 100644 --- a/apps/web/src/app/tools/reports/pages/unsecured-websites-report.component.ts +++ b/apps/web/src/app/tools/reports/pages/unsecured-websites-report.component.ts @@ -1,8 +1,11 @@ import { Component, OnInit } from "@angular/core"; +import { firstValueFrom } from "rxjs"; import { CollectionService, Collection } from "@bitwarden/admin-console/common"; import { ModalService } from "@bitwarden/angular/services/modal.service"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; +import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; +import { getUserId } from "@bitwarden/common/auth/services/account.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; @@ -19,6 +22,8 @@ import { CipherReportComponent } from "./cipher-report.component"; export class UnsecuredWebsitesReportComponent extends CipherReportComponent implements OnInit { disabled = true; + private activeUserId$ = this.accountService.activeAccount$.pipe(getUserId); + constructor( protected cipherService: CipherService, protected organizationService: OrganizationService, @@ -27,6 +32,7 @@ export class UnsecuredWebsitesReportComponent extends CipherReportComponent impl i18nService: I18nService, syncService: SyncService, private collectionService: CollectionService, + private accountService: AccountService, ) { super( cipherService, @@ -44,7 +50,9 @@ export class UnsecuredWebsitesReportComponent extends CipherReportComponent impl async setCiphers() { const allCiphers = await this.getAllCiphers(); - const allCollections = await this.collectionService.getAll(); + const allCollections = await firstValueFrom( + this.collectionService.encryptedCollections$(this.activeUserId$), + ); this.filterStatus = [0]; const unsecuredCiphers = allCiphers.filter((c) => { diff --git a/apps/web/src/app/vault/individual-vault/add-edit-v2.component.spec.ts b/apps/web/src/app/vault/individual-vault/add-edit-v2.component.spec.ts index 6c12623523..b72179f2db 100644 --- a/apps/web/src/app/vault/individual-vault/add-edit-v2.component.spec.ts +++ b/apps/web/src/app/vault/individual-vault/add-edit-v2.component.spec.ts @@ -66,7 +66,7 @@ describe("AddEditComponentV2", () => { folderService = mock(); folderService.folderViews$ = of([]); collectionService = mock(); - collectionService.decryptedCollections$ = of([]); + collectionService.decryptedCollections$.mockReturnValue(of([])); const mockDefaultCipherFormConfigService = { buildConfig: jest.fn().mockResolvedValue({ diff --git a/apps/web/src/app/vault/individual-vault/bulk-action-dialogs/bulk-share-dialog/bulk-share-dialog.component.ts b/apps/web/src/app/vault/individual-vault/bulk-action-dialogs/bulk-share-dialog/bulk-share-dialog.component.ts index edfc617c70..5a4efaaf41 100644 --- a/apps/web/src/app/vault/individual-vault/bulk-action-dialogs/bulk-share-dialog/bulk-share-dialog.component.ts +++ b/apps/web/src/app/vault/individual-vault/bulk-action-dialogs/bulk-share-dialog/bulk-share-dialog.component.ts @@ -1,11 +1,12 @@ import { DialogConfig, DialogRef, DIALOG_DATA } from "@angular/cdk/dialog"; import { Component, Inject, OnDestroy, OnInit } from "@angular/core"; -import { firstValueFrom, map } from "rxjs"; +import { firstValueFrom } from "rxjs"; import { CollectionService, CollectionView } from "@bitwarden/admin-console/common"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; +import { getUserId } from "@bitwarden/common/auth/services/account.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; @@ -52,6 +53,7 @@ export class BulkShareDialogComponent implements OnInit, OnDestroy { shareableCiphers: CipherView[] = []; private writeableCollections: CollectionView[] = []; + private activeUserId$ = this.accountService.activeAccount$.pipe(getUserId); constructor( @Inject(DIALOG_DATA) params: BulkShareDialogParams, @@ -73,7 +75,9 @@ export class BulkShareDialogComponent implements OnInit, OnDestroy { (c) => !c.hasOldAttachments && c.organizationId == null, ); this.nonShareableCount = this.ciphers.length - this.shareableCiphers.length; - const allCollections = await this.collectionService.getAllDecrypted(); + const allCollections = await firstValueFrom( + this.collectionService.decryptedCollections$(this.activeUserId$), + ); this.writeableCollections = allCollections.filter((c) => !c.readOnly); this.organizations = await this.organizationService.getAll(); if (this.organizationId == null && this.organizations.length > 0) { @@ -100,14 +104,11 @@ export class BulkShareDialogComponent implements OnInit, OnDestroy { submit = async () => { const checkedCollectionIds = this.collections.filter(isChecked).map((c) => c.id); try { - const activeUserId = await firstValueFrom( - this.accountService.activeAccount$.pipe(map((a) => a?.id)), - ); await this.cipherService.shareManyWithServer( this.shareableCiphers, this.organizationId, checkedCollectionIds, - activeUserId, + await firstValueFrom(this.activeUserId$), ); const orgName = this.organizations.find((o) => o.id === this.organizationId)?.name ?? diff --git a/apps/web/src/app/vault/individual-vault/vault-filter/services/vault-filter.service.spec.ts b/apps/web/src/app/vault/individual-vault/vault-filter/services/vault-filter.service.spec.ts index 0386a20adb..8d05a3b385 100644 --- a/apps/web/src/app/vault/individual-vault/vault-filter/services/vault-filter.service.spec.ts +++ b/apps/web/src/app/vault/individual-vault/vault-filter/services/vault-filter.service.spec.ts @@ -64,7 +64,7 @@ describe("vault filter service", () => { organizationService.memberOrganizations$ = organizations; folderService.folderViews$ = folderViews; - collectionService.decryptedCollections$ = collectionViews; + collectionService.decryptedCollections$.mockReturnValue(collectionViews); policyService.policyAppliesToActiveUser$ .calledWith(PolicyType.PersonalOwnership) .mockReturnValue(personalOwnershipPolicy); @@ -81,6 +81,7 @@ describe("vault filter service", () => { i18nService, stateProvider, collectionService, + accountService, ); collapsedGroupingsState = stateProvider.activeUser.getFake(COLLAPSED_GROUPINGS); }); diff --git a/apps/web/src/app/vault/individual-vault/vault-filter/services/vault-filter.service.ts b/apps/web/src/app/vault/individual-vault/vault-filter/services/vault-filter.service.ts index 043ba2dcd2..b35a89c67e 100644 --- a/apps/web/src/app/vault/individual-vault/vault-filter/services/vault-filter.service.ts +++ b/apps/web/src/app/vault/individual-vault/vault-filter/services/vault-filter.service.ts @@ -19,6 +19,8 @@ import { OrganizationService } from "@bitwarden/common/admin-console/abstraction import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction"; import { PolicyType } from "@bitwarden/common/admin-console/enums"; import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; +import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; +import { getUserId } from "@bitwarden/common/auth/services/account.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { ActiveUserState, StateProvider } from "@bitwarden/common/platform/state"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; @@ -43,6 +45,8 @@ const NestingDelimiter = "/"; @Injectable() export class VaultFilterService implements VaultFilterServiceAbstraction { + private activeUserId$ = this.accountService.activeAccount$.pipe(getUserId); + organizationTree$: Observable> = combineLatest([ this.organizationService.memberOrganizations$, this.policyService.policyAppliesToActiveUser$(PolicyType.SingleOrg), @@ -65,8 +69,9 @@ export class VaultFilterService implements VaultFilterServiceAbstraction { map((folders) => this.buildFolderTree(folders)), ); - filteredCollections$: Observable = - this.collectionService.decryptedCollections$.pipe( + filteredCollections$: Observable = this.collectionService + .decryptedCollections$(this.activeUserId$) + .pipe( combineLatestWith(this._organizationFilter), switchMap(([collections, org]) => { return this.filterCollections(collections, org); @@ -93,6 +98,7 @@ export class VaultFilterService implements VaultFilterServiceAbstraction { protected i18nService: I18nService, protected stateProvider: StateProvider, protected collectionService: CollectionService, + protected accountService: AccountService, ) {} async getCollectionNodeFromTree(id: string) { diff --git a/apps/web/src/app/vault/individual-vault/vault.component.ts b/apps/web/src/app/vault/individual-vault/vault.component.ts index f7f6f6d2c3..fcee0b6b21 100644 --- a/apps/web/src/app/vault/individual-vault/vault.component.ts +++ b/apps/web/src/app/vault/individual-vault/vault.component.ts @@ -120,6 +120,7 @@ import { FolderFilter, OrganizationFilter } from "./vault-filter/shared/models/v import { VaultFilterModule } from "./vault-filter/vault-filter.module"; import { VaultHeaderComponent } from "./vault-header/vault-header.component"; import { VaultOnboardingComponent } from "./vault-onboarding/vault-onboarding.component"; +import { getUserId } from "@bitwarden/common/auth/services/account.service"; const BroadcasterSubscriptionId = "VaultComponent"; const SearchTextDebounceInterval = 200; @@ -178,6 +179,7 @@ export class VaultComponent implements OnInit, OnDestroy { private refresh$ = new BehaviorSubject(null); private destroy$ = new Subject(); private extensionRefreshEnabled: boolean; + private activeUserId$ = this.accountService.activeAccount$.pipe(getUserId); private vaultItemDialogRef?: DialogRef | undefined; @@ -268,7 +270,7 @@ export class VaultComponent implements OnInit, OnDestroy { }); const filter$ = this.routedVaultFilterService.filter$; - const allCollections$ = this.collectionService.decryptedCollections$; + const allCollections$ = this.collectionService.decryptedCollections$(this.activeUserId$); const nestedCollections$ = allCollections$.pipe( map((collections) => getNestedCollectionTree(collections)), ); diff --git a/apps/web/src/app/vault/individual-vault/view.component.spec.ts b/apps/web/src/app/vault/individual-vault/view.component.spec.ts index b26c55d46e..bde9f564c4 100644 --- a/apps/web/src/app/vault/individual-vault/view.component.spec.ts +++ b/apps/web/src/app/vault/individual-vault/view.component.spec.ts @@ -5,11 +5,14 @@ import { mock } from "jest-mock-extended"; import { CollectionService } from "@bitwarden/admin-console/common"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; +import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service"; import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service"; +import { mockAccountServiceWith } from "@bitwarden/common/spec"; +import { UserId } from "@bitwarden/common/types/guid"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; @@ -63,6 +66,7 @@ describe("ViewComponent", () => { useValue: mock(), }, { provide: ConfigService, useValue: mock() }, + { provide: AccountService, useValue: mockAccountServiceWith("UserId" as UserId) }, { provide: CipherAuthorizationService, useValue: { diff --git a/apps/web/src/app/vault/org-vault/vault-filter/vault-filter.service.ts b/apps/web/src/app/vault/org-vault/vault-filter/vault-filter.service.ts index c4ac9d73df..e2d713649f 100644 --- a/apps/web/src/app/vault/org-vault/vault-filter/vault-filter.service.ts +++ b/apps/web/src/app/vault/org-vault/vault-filter/vault-filter.service.ts @@ -4,6 +4,7 @@ import { map, Observable, ReplaySubject, Subject } from "rxjs"; import { CollectionAdminView, CollectionService } from "@bitwarden/admin-console/common"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction"; +import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { StateProvider } from "@bitwarden/common/platform/state"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; @@ -32,6 +33,7 @@ export class VaultFilterService extends BaseVaultFilterService implements OnDest i18nService: I18nService, stateProvider: StateProvider, collectionService: CollectionService, + accountService: AccountService, ) { super( organizationService, @@ -41,6 +43,7 @@ export class VaultFilterService extends BaseVaultFilterService implements OnDest i18nService, stateProvider, collectionService, + accountService, ); }