1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 16:23:44 +00:00

[PM-12985] - Updating reports to use new modal for view/edit cipher (#12383)

* Updating reports to use new modal for view/edit cipher

* updating the location of the DefaultCipherFormCOnfigService

* Test fixes

* test fixes

* Adding back useful code and trying to fix inactive-two-factor-report.component.spec.ts issue

* suggested changes

* trying to fix tests

* test fix

* fixing reports

* Fix import path

* Remove unnecessary change

* Revert "Remove unnecessary change"

This reverts commit 9a19dc99ed.

* PM-16995- Provide missing CipherFormConfigService

* after merge fixes

* more fixes

* WIP

* wip: fix for exposed passwords

* WIP

* fixing tests

* removing uneeded change

* lint fixes

* lint fix

* fixing admin console permissions

* merge fix

---------

Co-authored-by: --global <>
Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
Co-authored-by: bnagawiecki <107435978+bnagawiecki@users.noreply.github.com>
Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com>
This commit is contained in:
cd-bitwarden
2025-02-21 08:45:30 -05:00
committed by GitHub
parent 05f25f305c
commit 1d04227884
19 changed files with 331 additions and 101 deletions

View File

@@ -1,24 +1,40 @@
// FIXME: Update this file to be type safe and remove this and next line // FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore // @ts-strict-ignore
import { DialogRef } from "@angular/cdk/dialog";
import { Directive, ViewChild, ViewContainerRef, OnDestroy } from "@angular/core"; import { Directive, ViewChild, ViewContainerRef, OnDestroy } from "@angular/core";
import { BehaviorSubject, Observable, Subject, firstValueFrom, switchMap, takeUntil } from "rxjs"; import {
BehaviorSubject,
lastValueFrom,
Observable,
Subject,
firstValueFrom,
switchMap,
takeUntil,
} from "rxjs";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { getUserId } from "@bitwarden/common/auth/services/account.service"; import { getUserId } from "@bitwarden/common/auth/services/account.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { OrganizationId } from "@bitwarden/common/types/guid"; import { CipherId, CollectionId, OrganizationId } from "@bitwarden/common/types/guid";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { CipherRepromptType } from "@bitwarden/common/vault/enums/cipher-reprompt-type"; import { CipherRepromptType } from "@bitwarden/common/vault/enums/cipher-reprompt-type";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { TableDataSource } from "@bitwarden/components"; import { TableDataSource, DialogService } from "@bitwarden/components";
import { PasswordRepromptService } from "@bitwarden/vault"; import {
CipherFormConfig,
CipherFormConfigService,
PasswordRepromptService,
} from "@bitwarden/vault";
import { AddEditComponent } from "../../../vault/individual-vault/add-edit.component"; import {
import { AddEditComponent as OrgAddEditComponent } from "../../../vault/org-vault/add-edit.component"; VaultItemDialogComponent,
VaultItemDialogMode,
VaultItemDialogResult,
} from "../../../vault/components/vault-item-dialog/vault-item-dialog.component";
import { AdminConsoleCipherFormConfigService } from "../../../vault/org-vault/services/admin-console-cipher-form-config.service";
@Directive() @Directive()
export class CipherReportComponent implements OnDestroy { export class CipherReportComponent implements OnDestroy {
@@ -41,15 +57,18 @@ export class CipherReportComponent implements OnDestroy {
currentFilterStatus: number | string; currentFilterStatus: number | string;
protected filterOrgStatus$ = new BehaviorSubject<number | string>(0); protected filterOrgStatus$ = new BehaviorSubject<number | string>(0);
private destroyed$: Subject<void> = new Subject(); private destroyed$: Subject<void> = new Subject();
private vaultItemDialogRef?: DialogRef<VaultItemDialogResult> | undefined;
constructor( constructor(
protected cipherService: CipherService, protected cipherService: CipherService,
private modalService: ModalService, private dialogService: DialogService,
protected passwordRepromptService: PasswordRepromptService, protected passwordRepromptService: PasswordRepromptService,
protected organizationService: OrganizationService, protected organizationService: OrganizationService,
protected accountService: AccountService, protected accountService: AccountService,
protected i18nService: I18nService, protected i18nService: I18nService,
private syncService: SyncService, private syncService: SyncService,
private cipherFormConfigService: CipherFormConfigService,
private adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService,
) { ) {
this.organizations$ = this.accountService.activeAccount$.pipe( this.organizations$ = this.accountService.activeAccount$.pipe(
getUserId, getUserId,
@@ -134,43 +153,63 @@ export class CipherReportComponent implements OnDestroy {
this.loading = false; this.loading = false;
this.hasLoaded = true; this.hasLoaded = true;
} }
async selectCipher(cipher: CipherView) { async selectCipher(cipher: CipherView) {
if (!(await this.repromptCipher(cipher))) { if (!(await this.repromptCipher(cipher))) {
return; return;
} }
const type = this.organization != null ? OrgAddEditComponent : AddEditComponent; if (this.organization) {
const adminCipherFormConfig = await this.adminConsoleCipherFormConfigService.buildConfig(
"edit",
cipher.id as CipherId,
cipher.type,
);
const [modal, childComponent] = await this.modalService.openViewRef( await this.openVaultItemDialog("view", adminCipherFormConfig, cipher);
type, } else {
this.cipherAddEditModalRef, const cipherFormConfig = await this.cipherFormConfigService.buildConfig(
(comp: OrgAddEditComponent | AddEditComponent) => { "edit",
if (this.organization != null) { cipher.id as CipherId,
(comp as OrgAddEditComponent).organization = this.organization; cipher.type,
comp.organizationId = this.organization.id; );
} await this.openVaultItemDialog("view", cipherFormConfig, cipher);
}
}
comp.cipherId = cipher == null ? null : cipher.id; /**
// eslint-disable-next-line rxjs/no-async-subscribe * Open the combined view / edit dialog for a cipher.
comp.onSavedCipher.subscribe(async () => { * @param mode - Starting mode of the dialog.
modal.close(); * @param formConfig - Configuration for the form when editing/adding a cipher.
await this.load(); * @param activeCollectionId - The active collection ID.
}); */
// eslint-disable-next-line rxjs/no-async-subscribe async openVaultItemDialog(
comp.onDeletedCipher.subscribe(async () => { mode: VaultItemDialogMode,
modal.close(); formConfig: CipherFormConfig,
await this.load(); cipher: CipherView,
}); activeCollectionId?: CollectionId,
// eslint-disable-next-line rxjs/no-async-subscribe ) {
comp.onRestoredCipher.subscribe(async () => { const disableForm = cipher ? !cipher.edit && !this.organization.canEditAllCiphers : false;
modal.close();
await this.load();
});
},
);
return childComponent; this.vaultItemDialogRef = VaultItemDialogComponent.open(this.dialogService, {
mode,
formConfig,
activeCollectionId,
disableForm,
});
const result = await lastValueFrom(this.vaultItemDialogRef.closed);
this.vaultItemDialogRef = undefined;
// When the dialog is closed for a premium upgrade, return early as the user
// should be navigated to the subscription settings elsewhere
if (result === VaultItemDialogResult.PremiumUpgrade) {
return;
}
// If the dialog was closed by deleting the cipher, refresh the report.
if (result === VaultItemDialogResult.Deleted || result === VaultItemDialogResult.Saved) {
await this.load();
}
} }
protected async setCiphers() { protected async setCiphers() {

View File

@@ -4,7 +4,6 @@ import { mock, MockProxy } from "jest-mock-extended";
import { of } from "rxjs"; import { of } from "rxjs";
import { I18nPipe } from "@bitwarden/angular/platform/pipes/i18n.pipe"; import { I18nPipe } from "@bitwarden/angular/platform/pipes/i18n.pipe";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { AuditService } from "@bitwarden/common/abstractions/audit.service"; import { AuditService } from "@bitwarden/common/abstractions/audit.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
@@ -14,7 +13,10 @@ import { FakeAccountService, mockAccountServiceWith } from "@bitwarden/common/sp
import { UserId } from "@bitwarden/common/types/guid"; import { UserId } from "@bitwarden/common/types/guid";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { PasswordRepromptService } from "@bitwarden/vault"; import { DialogService } from "@bitwarden/components";
import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";
import { AdminConsoleCipherFormConfigService } from "../../../vault/org-vault/services/admin-console-cipher-form-config.service";
import { ExposedPasswordsReportComponent } from "./exposed-passwords-report.component"; import { ExposedPasswordsReportComponent } from "./exposed-passwords-report.component";
import { cipherData } from "./reports-ciphers.mock"; import { cipherData } from "./reports-ciphers.mock";
@@ -25,10 +27,12 @@ describe("ExposedPasswordsReportComponent", () => {
let auditService: MockProxy<AuditService>; let auditService: MockProxy<AuditService>;
let organizationService: MockProxy<OrganizationService>; let organizationService: MockProxy<OrganizationService>;
let syncServiceMock: MockProxy<SyncService>; let syncServiceMock: MockProxy<SyncService>;
let adminConsoleCipherFormConfigServiceMock: MockProxy<AdminConsoleCipherFormConfigService>;
const userId = Utils.newGuid() as UserId; const userId = Utils.newGuid() as UserId;
const accountService: FakeAccountService = mockAccountServiceWith(userId); const accountService: FakeAccountService = mockAccountServiceWith(userId);
beforeEach(() => { beforeEach(() => {
let cipherFormConfigServiceMock: MockProxy<CipherFormConfigService>;
syncServiceMock = mock<SyncService>(); syncServiceMock = mock<SyncService>();
auditService = mock<AuditService>(); auditService = mock<AuditService>();
organizationService = mock<OrganizationService>(); organizationService = mock<OrganizationService>();
@@ -55,8 +59,8 @@ describe("ExposedPasswordsReportComponent", () => {
useValue: accountService, useValue: accountService,
}, },
{ {
provide: ModalService, provide: DialogService,
useValue: mock<ModalService>(), useValue: mock<DialogService>(),
}, },
{ {
provide: PasswordRepromptService, provide: PasswordRepromptService,
@@ -70,6 +74,14 @@ describe("ExposedPasswordsReportComponent", () => {
provide: I18nService, provide: I18nService,
useValue: mock<I18nService>(), useValue: mock<I18nService>(),
}, },
{
provide: CipherFormConfigService,
useValue: cipherFormConfigServiceMock,
},
{
provide: AdminConsoleCipherFormConfigService,
useValue: adminConsoleCipherFormConfigServiceMock,
},
], ],
schemas: [], schemas: [],
}).compileComponents(); }).compileComponents();

View File

@@ -1,6 +1,5 @@
import { Component, OnInit } from "@angular/core"; import { Component, OnInit } from "@angular/core";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { AuditService } from "@bitwarden/common/abstractions/audit.service"; import { AuditService } from "@bitwarden/common/abstractions/audit.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
@@ -9,7 +8,10 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { CipherType } from "@bitwarden/common/vault/enums"; import { CipherType } from "@bitwarden/common/vault/enums";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { PasswordRepromptService } from "@bitwarden/vault"; import { DialogService } from "@bitwarden/components";
import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";
import { AdminConsoleCipherFormConfigService } from "../../../vault/org-vault/services/admin-console-cipher-form-config.service";
import { CipherReportComponent } from "./cipher-report.component"; import { CipherReportComponent } from "./cipher-report.component";
@@ -26,20 +28,24 @@ export class ExposedPasswordsReportComponent extends CipherReportComponent imple
protected cipherService: CipherService, protected cipherService: CipherService,
protected auditService: AuditService, protected auditService: AuditService,
protected organizationService: OrganizationService, protected organizationService: OrganizationService,
dialogService: DialogService,
accountService: AccountService, accountService: AccountService,
modalService: ModalService,
passwordRepromptService: PasswordRepromptService, passwordRepromptService: PasswordRepromptService,
i18nService: I18nService, i18nService: I18nService,
syncService: SyncService, syncService: SyncService,
cipherFormConfigService: CipherFormConfigService,
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService,
) { ) {
super( super(
cipherService, cipherService,
modalService, dialogService,
passwordRepromptService, passwordRepromptService,
organizationService, organizationService,
accountService, accountService,
i18nService, i18nService,
syncService, syncService,
cipherFormConfigService,
adminConsoleCipherFormConfigService,
); );
} }

View File

@@ -4,7 +4,6 @@ import { MockProxy, mock } from "jest-mock-extended";
import { of } from "rxjs"; import { of } from "rxjs";
import { I18nPipe } from "@bitwarden/angular/platform/pipes/i18n.pipe"; 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 { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
@@ -14,7 +13,10 @@ import { FakeAccountService, mockAccountServiceWith } from "@bitwarden/common/sp
import { UserId } from "@bitwarden/common/types/guid"; import { UserId } from "@bitwarden/common/types/guid";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { PasswordRepromptService } from "@bitwarden/vault"; import { DialogService } from "@bitwarden/components";
import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";
import { AdminConsoleCipherFormConfigService } from "../../../vault/org-vault/services/admin-console-cipher-form-config.service";
import { InactiveTwoFactorReportComponent } from "./inactive-two-factor-report.component"; import { InactiveTwoFactorReportComponent } from "./inactive-two-factor-report.component";
import { cipherData } from "./reports-ciphers.mock"; import { cipherData } from "./reports-ciphers.mock";
@@ -24,10 +26,12 @@ describe("InactiveTwoFactorReportComponent", () => {
let fixture: ComponentFixture<InactiveTwoFactorReportComponent>; let fixture: ComponentFixture<InactiveTwoFactorReportComponent>;
let organizationService: MockProxy<OrganizationService>; let organizationService: MockProxy<OrganizationService>;
let syncServiceMock: MockProxy<SyncService>; let syncServiceMock: MockProxy<SyncService>;
let adminConsoleCipherFormConfigServiceMock: MockProxy<AdminConsoleCipherFormConfigService>;
const userId = Utils.newGuid() as UserId; const userId = Utils.newGuid() as UserId;
const accountService: FakeAccountService = mockAccountServiceWith(userId); const accountService: FakeAccountService = mockAccountServiceWith(userId);
beforeEach(() => { beforeEach(() => {
let cipherFormConfigServiceMock: MockProxy<CipherFormConfigService>;
organizationService = mock<OrganizationService>(); organizationService = mock<OrganizationService>();
organizationService.organizations$.mockReturnValue(of([])); organizationService.organizations$.mockReturnValue(of([]));
syncServiceMock = mock<SyncService>(); syncServiceMock = mock<SyncService>();
@@ -49,8 +53,8 @@ describe("InactiveTwoFactorReportComponent", () => {
useValue: accountService, useValue: accountService,
}, },
{ {
provide: ModalService, provide: DialogService,
useValue: mock<ModalService>(), useValue: mock<DialogService>(),
}, },
{ {
provide: LogService, provide: LogService,
@@ -68,6 +72,14 @@ describe("InactiveTwoFactorReportComponent", () => {
provide: I18nService, provide: I18nService,
useValue: mock<I18nService>(), useValue: mock<I18nService>(),
}, },
{
provide: CipherFormConfigService,
useValue: cipherFormConfigServiceMock,
},
{
provide: AdminConsoleCipherFormConfigService,
useValue: adminConsoleCipherFormConfigServiceMock,
},
], ],
schemas: [], schemas: [],
}).compileComponents(); }).compileComponents();

View File

@@ -2,7 +2,6 @@
// @ts-strict-ignore // @ts-strict-ignore
import { Component, OnInit } from "@angular/core"; import { Component, OnInit } from "@angular/core";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
@@ -12,7 +11,10 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { CipherType } from "@bitwarden/common/vault/enums"; import { CipherType } from "@bitwarden/common/vault/enums";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { PasswordRepromptService } from "@bitwarden/vault"; import { DialogService } from "@bitwarden/components";
import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";
import { AdminConsoleCipherFormConfigService } from "../../../vault/org-vault/services/admin-console-cipher-form-config.service";
import { CipherReportComponent } from "./cipher-report.component"; import { CipherReportComponent } from "./cipher-report.component";
@@ -28,21 +30,25 @@ export class InactiveTwoFactorReportComponent extends CipherReportComponent impl
constructor( constructor(
protected cipherService: CipherService, protected cipherService: CipherService,
protected organizationService: OrganizationService, protected organizationService: OrganizationService,
dialogService: DialogService,
accountService: AccountService, accountService: AccountService,
modalService: ModalService,
private logService: LogService, private logService: LogService,
passwordRepromptService: PasswordRepromptService, passwordRepromptService: PasswordRepromptService,
i18nService: I18nService, i18nService: I18nService,
syncService: SyncService, syncService: SyncService,
cipherFormConfigService: CipherFormConfigService,
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService,
) { ) {
super( super(
cipherService, cipherService,
modalService, dialogService,
passwordRepromptService, passwordRepromptService,
organizationService, organizationService,
accountService, accountService,
i18nService, i18nService,
syncService, syncService,
cipherFormConfigService,
adminConsoleCipherFormConfigService,
); );
} }

View File

@@ -4,7 +4,6 @@ import { Component, OnInit } from "@angular/core";
import { ActivatedRoute } from "@angular/router"; import { ActivatedRoute } from "@angular/router";
import { firstValueFrom } from "rxjs"; import { firstValueFrom } from "rxjs";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { AuditService } from "@bitwarden/common/abstractions/audit.service"; import { AuditService } from "@bitwarden/common/abstractions/audit.service";
import { import {
getOrganizationById, getOrganizationById,
@@ -17,13 +16,27 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { Cipher } from "@bitwarden/common/vault/models/domain/cipher"; import { Cipher } from "@bitwarden/common/vault/models/domain/cipher";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { PasswordRepromptService } from "@bitwarden/vault"; import { DialogService } from "@bitwarden/components";
import { PasswordRepromptService, CipherFormConfigService } from "@bitwarden/vault";
// eslint-disable-next-line no-restricted-imports
import { RoutedVaultFilterBridgeService } from "../../../../vault/individual-vault/vault-filter/services/routed-vault-filter-bridge.service";
import { RoutedVaultFilterService } from "../../../../vault/individual-vault/vault-filter/services/routed-vault-filter.service";
import { AdminConsoleCipherFormConfigService } from "../../../../vault/org-vault/services/admin-console-cipher-form-config.service";
import { ExposedPasswordsReportComponent as BaseExposedPasswordsReportComponent } from "../exposed-passwords-report.component"; import { ExposedPasswordsReportComponent as BaseExposedPasswordsReportComponent } from "../exposed-passwords-report.component";
@Component({ @Component({
selector: "app-org-exposed-passwords-report", selector: "app-org-exposed-passwords-report",
templateUrl: "../exposed-passwords-report.component.html", templateUrl: "../exposed-passwords-report.component.html",
providers: [
{
provide: CipherFormConfigService,
useClass: AdminConsoleCipherFormConfigService,
},
AdminConsoleCipherFormConfigService,
RoutedVaultFilterService,
RoutedVaultFilterBridgeService,
],
}) })
// eslint-disable-next-line rxjs-angular/prefer-takeuntil // eslint-disable-next-line rxjs-angular/prefer-takeuntil
export class ExposedPasswordsReportComponent export class ExposedPasswordsReportComponent
@@ -35,23 +48,27 @@ export class ExposedPasswordsReportComponent
constructor( constructor(
cipherService: CipherService, cipherService: CipherService,
auditService: AuditService, auditService: AuditService,
modalService: ModalService, dialogService: DialogService,
organizationService: OrganizationService, organizationService: OrganizationService,
protected accountService: AccountService, protected accountService: AccountService,
private route: ActivatedRoute, private route: ActivatedRoute,
passwordRepromptService: PasswordRepromptService, passwordRepromptService: PasswordRepromptService,
i18nService: I18nService, i18nService: I18nService,
syncService: SyncService, syncService: SyncService,
cipherFormService: CipherFormConfigService,
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService,
) { ) {
super( super(
cipherService, cipherService,
auditService, auditService,
organizationService, organizationService,
dialogService,
accountService, accountService,
modalService,
passwordRepromptService, passwordRepromptService,
i18nService, i18nService,
syncService, syncService,
cipherFormService,
adminConsoleCipherFormConfigService,
); );
} }

View File

@@ -4,7 +4,6 @@ import { Component, OnInit } from "@angular/core";
import { ActivatedRoute } from "@angular/router"; import { ActivatedRoute } from "@angular/router";
import { firstValueFrom, map } from "rxjs"; import { firstValueFrom, map } from "rxjs";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { import {
getOrganizationById, getOrganizationById,
OrganizationService, OrganizationService,
@@ -15,13 +14,27 @@ import { LogService } from "@bitwarden/common/platform/abstractions/log.service"
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { PasswordRepromptService } from "@bitwarden/vault"; import { DialogService } from "@bitwarden/components";
import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";
// eslint-disable-next-line no-restricted-imports
import { RoutedVaultFilterBridgeService } from "../../../../vault/individual-vault/vault-filter/services/routed-vault-filter-bridge.service";
import { RoutedVaultFilterService } from "../../../../vault/individual-vault/vault-filter/services/routed-vault-filter.service";
import { AdminConsoleCipherFormConfigService } from "../../../../vault/org-vault/services/admin-console-cipher-form-config.service";
import { InactiveTwoFactorReportComponent as BaseInactiveTwoFactorReportComponent } from "../inactive-two-factor-report.component"; import { InactiveTwoFactorReportComponent as BaseInactiveTwoFactorReportComponent } from "../inactive-two-factor-report.component";
@Component({ @Component({
selector: "app-inactive-two-factor-report", selector: "app-inactive-two-factor-report",
templateUrl: "../inactive-two-factor-report.component.html", templateUrl: "../inactive-two-factor-report.component.html",
providers: [
{
provide: CipherFormConfigService,
useClass: AdminConsoleCipherFormConfigService,
},
AdminConsoleCipherFormConfigService,
RoutedVaultFilterService,
RoutedVaultFilterBridgeService,
],
}) })
// eslint-disable-next-line rxjs-angular/prefer-takeuntil // eslint-disable-next-line rxjs-angular/prefer-takeuntil
export class InactiveTwoFactorReportComponent export class InactiveTwoFactorReportComponent
@@ -30,7 +43,7 @@ export class InactiveTwoFactorReportComponent
{ {
constructor( constructor(
cipherService: CipherService, cipherService: CipherService,
modalService: ModalService, dialogService: DialogService,
private route: ActivatedRoute, private route: ActivatedRoute,
logService: LogService, logService: LogService,
passwordRepromptService: PasswordRepromptService, passwordRepromptService: PasswordRepromptService,
@@ -38,16 +51,20 @@ export class InactiveTwoFactorReportComponent
accountService: AccountService, accountService: AccountService,
i18nService: I18nService, i18nService: I18nService,
syncService: SyncService, syncService: SyncService,
cipherFormConfigService: CipherFormConfigService,
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService,
) { ) {
super( super(
cipherService, cipherService,
organizationService, organizationService,
dialogService,
accountService, accountService,
modalService,
logService, logService,
passwordRepromptService, passwordRepromptService,
i18nService, i18nService,
syncService, syncService,
cipherFormConfigService,
adminConsoleCipherFormConfigService,
); );
} }

View File

@@ -4,7 +4,6 @@ import { Component, OnInit } from "@angular/core";
import { ActivatedRoute } from "@angular/router"; import { ActivatedRoute } from "@angular/router";
import { firstValueFrom } from "rxjs"; import { firstValueFrom } from "rxjs";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { import {
getOrganizationById, getOrganizationById,
OrganizationService, OrganizationService,
@@ -16,13 +15,27 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { Cipher } from "@bitwarden/common/vault/models/domain/cipher"; import { Cipher } from "@bitwarden/common/vault/models/domain/cipher";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { PasswordRepromptService } from "@bitwarden/vault"; import { DialogService } from "@bitwarden/components";
import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";
// eslint-disable-next-line no-restricted-imports
import { RoutedVaultFilterBridgeService } from "../../../../vault/individual-vault/vault-filter/services/routed-vault-filter-bridge.service";
import { RoutedVaultFilterService } from "../../../../vault/individual-vault/vault-filter/services/routed-vault-filter.service";
import { AdminConsoleCipherFormConfigService } from "../../../../vault/org-vault/services/admin-console-cipher-form-config.service";
import { ReusedPasswordsReportComponent as BaseReusedPasswordsReportComponent } from "../reused-passwords-report.component"; import { ReusedPasswordsReportComponent as BaseReusedPasswordsReportComponent } from "../reused-passwords-report.component";
@Component({ @Component({
selector: "app-reused-passwords-report", selector: "app-reused-passwords-report",
templateUrl: "../reused-passwords-report.component.html", templateUrl: "../reused-passwords-report.component.html",
providers: [
{
provide: CipherFormConfigService,
useClass: AdminConsoleCipherFormConfigService,
},
AdminConsoleCipherFormConfigService,
RoutedVaultFilterService,
RoutedVaultFilterBridgeService,
],
}) })
// eslint-disable-next-line rxjs-angular/prefer-takeuntil // eslint-disable-next-line rxjs-angular/prefer-takeuntil
export class ReusedPasswordsReportComponent export class ReusedPasswordsReportComponent
@@ -33,22 +46,26 @@ export class ReusedPasswordsReportComponent
constructor( constructor(
cipherService: CipherService, cipherService: CipherService,
modalService: ModalService, dialogService: DialogService,
private route: ActivatedRoute, private route: ActivatedRoute,
organizationService: OrganizationService, organizationService: OrganizationService,
protected accountService: AccountService, protected accountService: AccountService,
passwordRepromptService: PasswordRepromptService, passwordRepromptService: PasswordRepromptService,
i18nService: I18nService, i18nService: I18nService,
syncService: SyncService, syncService: SyncService,
cipherFormConfigService: CipherFormConfigService,
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService,
) { ) {
super( super(
cipherService, cipherService,
organizationService, organizationService,
dialogService,
accountService, accountService,
modalService,
passwordRepromptService, passwordRepromptService,
i18nService, i18nService,
syncService, syncService,
cipherFormConfigService,
adminConsoleCipherFormConfigService,
); );
} }

View File

@@ -5,7 +5,6 @@ import { ActivatedRoute } from "@angular/router";
import { firstValueFrom, map } from "rxjs"; import { firstValueFrom, map } from "rxjs";
import { CollectionService } from "@bitwarden/admin-console/common"; import { CollectionService } from "@bitwarden/admin-console/common";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { import {
getOrganizationById, getOrganizationById,
OrganizationService, OrganizationService,
@@ -15,13 +14,27 @@ import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.servic
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { PasswordRepromptService } from "@bitwarden/vault"; import { DialogService } from "@bitwarden/components";
import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";
// eslint-disable-next-line no-restricted-imports
import { RoutedVaultFilterBridgeService } from "../../../../vault/individual-vault/vault-filter/services/routed-vault-filter-bridge.service";
import { RoutedVaultFilterService } from "../../../../vault/individual-vault/vault-filter/services/routed-vault-filter.service";
import { AdminConsoleCipherFormConfigService } from "../../../../vault/org-vault/services/admin-console-cipher-form-config.service";
import { UnsecuredWebsitesReportComponent as BaseUnsecuredWebsitesReportComponent } from "../unsecured-websites-report.component"; import { UnsecuredWebsitesReportComponent as BaseUnsecuredWebsitesReportComponent } from "../unsecured-websites-report.component";
@Component({ @Component({
selector: "app-unsecured-websites-report", selector: "app-unsecured-websites-report",
templateUrl: "../unsecured-websites-report.component.html", templateUrl: "../unsecured-websites-report.component.html",
providers: [
{
provide: CipherFormConfigService,
useClass: AdminConsoleCipherFormConfigService,
},
AdminConsoleCipherFormConfigService,
RoutedVaultFilterService,
RoutedVaultFilterBridgeService,
],
}) })
// eslint-disable-next-line rxjs-angular/prefer-takeuntil // eslint-disable-next-line rxjs-angular/prefer-takeuntil
export class UnsecuredWebsitesReportComponent export class UnsecuredWebsitesReportComponent
@@ -30,7 +43,7 @@ export class UnsecuredWebsitesReportComponent
{ {
constructor( constructor(
cipherService: CipherService, cipherService: CipherService,
modalService: ModalService, dialogService: DialogService,
private route: ActivatedRoute, private route: ActivatedRoute,
organizationService: OrganizationService, organizationService: OrganizationService,
protected accountService: AccountService, protected accountService: AccountService,
@@ -38,16 +51,20 @@ export class UnsecuredWebsitesReportComponent
i18nService: I18nService, i18nService: I18nService,
syncService: SyncService, syncService: SyncService,
collectionService: CollectionService, collectionService: CollectionService,
cipherFormConfigService: CipherFormConfigService,
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService,
) { ) {
super( super(
cipherService, cipherService,
organizationService, organizationService,
dialogService,
accountService, accountService,
modalService,
passwordRepromptService, passwordRepromptService,
i18nService, i18nService,
syncService, syncService,
collectionService, collectionService,
cipherFormConfigService,
adminConsoleCipherFormConfigService,
); );
} }

View File

@@ -4,7 +4,6 @@ import { Component, OnInit } from "@angular/core";
import { ActivatedRoute } from "@angular/router"; import { ActivatedRoute } from "@angular/router";
import { firstValueFrom } from "rxjs"; import { firstValueFrom } from "rxjs";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { import {
getOrganizationById, getOrganizationById,
OrganizationService, OrganizationService,
@@ -17,13 +16,27 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { Cipher } from "@bitwarden/common/vault/models/domain/cipher"; import { Cipher } from "@bitwarden/common/vault/models/domain/cipher";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { PasswordRepromptService } from "@bitwarden/vault"; import { DialogService } from "@bitwarden/components";
import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";
// eslint-disable-next-line no-restricted-imports
import { RoutedVaultFilterBridgeService } from "../../../../vault/individual-vault/vault-filter/services/routed-vault-filter-bridge.service";
import { RoutedVaultFilterService } from "../../../../vault/individual-vault/vault-filter/services/routed-vault-filter.service";
import { AdminConsoleCipherFormConfigService } from "../../../../vault/org-vault/services/admin-console-cipher-form-config.service";
import { WeakPasswordsReportComponent as BaseWeakPasswordsReportComponent } from "../weak-passwords-report.component"; import { WeakPasswordsReportComponent as BaseWeakPasswordsReportComponent } from "../weak-passwords-report.component";
@Component({ @Component({
selector: "app-weak-passwords-report", selector: "app-weak-passwords-report",
templateUrl: "../weak-passwords-report.component.html", templateUrl: "../weak-passwords-report.component.html",
providers: [
{
provide: CipherFormConfigService,
useClass: AdminConsoleCipherFormConfigService,
},
AdminConsoleCipherFormConfigService,
RoutedVaultFilterService,
RoutedVaultFilterBridgeService,
],
}) })
// eslint-disable-next-line rxjs-angular/prefer-takeuntil // eslint-disable-next-line rxjs-angular/prefer-takeuntil
export class WeakPasswordsReportComponent export class WeakPasswordsReportComponent
@@ -35,23 +48,27 @@ export class WeakPasswordsReportComponent
constructor( constructor(
cipherService: CipherService, cipherService: CipherService,
passwordStrengthService: PasswordStrengthServiceAbstraction, passwordStrengthService: PasswordStrengthServiceAbstraction,
modalService: ModalService, dialogService: DialogService,
private route: ActivatedRoute, private route: ActivatedRoute,
organizationService: OrganizationService, organizationService: OrganizationService,
passwordRepromptService: PasswordRepromptService, passwordRepromptService: PasswordRepromptService,
i18nService: I18nService, i18nService: I18nService,
syncService: SyncService, syncService: SyncService,
cipherFormConfigService: CipherFormConfigService,
protected accountService: AccountService, protected accountService: AccountService,
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService,
) { ) {
super( super(
cipherService, cipherService,
passwordStrengthService, passwordStrengthService,
organizationService, organizationService,
dialogService,
accountService, accountService,
modalService,
passwordRepromptService, passwordRepromptService,
i18nService, i18nService,
syncService, syncService,
cipherFormConfigService,
adminConsoleCipherFormConfigService,
); );
} }

View File

@@ -4,7 +4,6 @@ import { MockProxy, mock } from "jest-mock-extended";
import { of } from "rxjs"; import { of } from "rxjs";
import { I18nPipe } from "@bitwarden/angular/platform/pipes/i18n.pipe"; 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 { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
@@ -13,7 +12,10 @@ import { FakeAccountService, mockAccountServiceWith } from "@bitwarden/common/sp
import { UserId } from "@bitwarden/common/types/guid"; import { UserId } from "@bitwarden/common/types/guid";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { PasswordRepromptService } from "@bitwarden/vault"; import { DialogService } from "@bitwarden/components";
import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";
import { AdminConsoleCipherFormConfigService } from "../../../vault/org-vault/services/admin-console-cipher-form-config.service";
import { cipherData } from "./reports-ciphers.mock"; import { cipherData } from "./reports-ciphers.mock";
import { ReusedPasswordsReportComponent } from "./reused-passwords-report.component"; import { ReusedPasswordsReportComponent } from "./reused-passwords-report.component";
@@ -23,10 +25,12 @@ describe("ReusedPasswordsReportComponent", () => {
let fixture: ComponentFixture<ReusedPasswordsReportComponent>; let fixture: ComponentFixture<ReusedPasswordsReportComponent>;
let organizationService: MockProxy<OrganizationService>; let organizationService: MockProxy<OrganizationService>;
let syncServiceMock: MockProxy<SyncService>; let syncServiceMock: MockProxy<SyncService>;
let adminConsoleCipherFormConfigServiceMock: MockProxy<AdminConsoleCipherFormConfigService>;
const userId = Utils.newGuid() as UserId; const userId = Utils.newGuid() as UserId;
const accountService: FakeAccountService = mockAccountServiceWith(userId); const accountService: FakeAccountService = mockAccountServiceWith(userId);
beforeEach(() => { beforeEach(() => {
let cipherFormConfigServiceMock: MockProxy<CipherFormConfigService>;
organizationService = mock<OrganizationService>(); organizationService = mock<OrganizationService>();
organizationService.organizations$.mockReturnValue(of([])); organizationService.organizations$.mockReturnValue(of([]));
syncServiceMock = mock<SyncService>(); syncServiceMock = mock<SyncService>();
@@ -48,8 +52,8 @@ describe("ReusedPasswordsReportComponent", () => {
useValue: accountService, useValue: accountService,
}, },
{ {
provide: ModalService, provide: DialogService,
useValue: mock<ModalService>(), useValue: mock<DialogService>(),
}, },
{ {
provide: PasswordRepromptService, provide: PasswordRepromptService,
@@ -63,6 +67,14 @@ describe("ReusedPasswordsReportComponent", () => {
provide: I18nService, provide: I18nService,
useValue: mock<I18nService>(), useValue: mock<I18nService>(),
}, },
{
provide: CipherFormConfigService,
useValue: cipherFormConfigServiceMock,
},
{
provide: AdminConsoleCipherFormConfigService,
useValue: adminConsoleCipherFormConfigServiceMock,
},
], ],
schemas: [], schemas: [],
}).compileComponents(); }).compileComponents();

View File

@@ -2,7 +2,6 @@
// @ts-strict-ignore // @ts-strict-ignore
import { Component, OnInit } from "@angular/core"; import { Component, OnInit } from "@angular/core";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
@@ -10,7 +9,10 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { CipherType } from "@bitwarden/common/vault/enums"; import { CipherType } from "@bitwarden/common/vault/enums";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { PasswordRepromptService } from "@bitwarden/vault"; import { DialogService } from "@bitwarden/components";
import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";
import { AdminConsoleCipherFormConfigService } from "../../../vault/org-vault/services/admin-console-cipher-form-config.service";
import { CipherReportComponent } from "./cipher-report.component"; import { CipherReportComponent } from "./cipher-report.component";
@@ -25,20 +27,24 @@ export class ReusedPasswordsReportComponent extends CipherReportComponent implem
constructor( constructor(
protected cipherService: CipherService, protected cipherService: CipherService,
protected organizationService: OrganizationService, protected organizationService: OrganizationService,
dialogService: DialogService,
accountService: AccountService, accountService: AccountService,
modalService: ModalService,
passwordRepromptService: PasswordRepromptService, passwordRepromptService: PasswordRepromptService,
i18nService: I18nService, i18nService: I18nService,
syncService: SyncService, syncService: SyncService,
cipherFormConfigService: CipherFormConfigService,
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService,
) { ) {
super( super(
cipherService, cipherService,
modalService, dialogService,
passwordRepromptService, passwordRepromptService,
organizationService, organizationService,
accountService, accountService,
i18nService, i18nService,
syncService, syncService,
cipherFormConfigService,
adminConsoleCipherFormConfigService,
); );
} }

View File

@@ -5,7 +5,6 @@ import { of } from "rxjs";
import { CollectionService } from "@bitwarden/admin-console/common"; import { CollectionService } from "@bitwarden/admin-console/common";
import { I18nPipe } from "@bitwarden/angular/platform/pipes/i18n.pipe"; 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 { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
@@ -14,7 +13,10 @@ import { FakeAccountService, mockAccountServiceWith } from "@bitwarden/common/sp
import { UserId } from "@bitwarden/common/types/guid"; import { UserId } from "@bitwarden/common/types/guid";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { PasswordRepromptService } from "@bitwarden/vault"; import { DialogService } from "@bitwarden/components";
import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";
import { AdminConsoleCipherFormConfigService } from "../../../vault/org-vault/services/admin-console-cipher-form-config.service";
import { cipherData } from "./reports-ciphers.mock"; import { cipherData } from "./reports-ciphers.mock";
import { UnsecuredWebsitesReportComponent } from "./unsecured-websites-report.component"; import { UnsecuredWebsitesReportComponent } from "./unsecured-websites-report.component";
@@ -25,14 +27,18 @@ describe("UnsecuredWebsitesReportComponent", () => {
let organizationService: MockProxy<OrganizationService>; let organizationService: MockProxy<OrganizationService>;
let syncServiceMock: MockProxy<SyncService>; let syncServiceMock: MockProxy<SyncService>;
let collectionService: MockProxy<CollectionService>; let collectionService: MockProxy<CollectionService>;
let adminConsoleCipherFormConfigService: MockProxy<AdminConsoleCipherFormConfigService>;
const userId = Utils.newGuid() as UserId; const userId = Utils.newGuid() as UserId;
const accountService: FakeAccountService = mockAccountServiceWith(userId); const accountService: FakeAccountService = mockAccountServiceWith(userId);
beforeEach(() => { beforeEach(() => {
let cipherFormConfigServiceMock: MockProxy<CipherFormConfigService>;
organizationService = mock<OrganizationService>(); organizationService = mock<OrganizationService>();
organizationService.organizations$.mockReturnValue(of([])); organizationService.organizations$.mockReturnValue(of([]));
syncServiceMock = mock<SyncService>(); syncServiceMock = mock<SyncService>();
collectionService = mock<CollectionService>(); collectionService = mock<CollectionService>();
adminConsoleCipherFormConfigService = mock<AdminConsoleCipherFormConfigService>();
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling. // 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 // eslint-disable-next-line @typescript-eslint/no-floating-promises
TestBed.configureTestingModule({ TestBed.configureTestingModule({
@@ -51,8 +57,8 @@ describe("UnsecuredWebsitesReportComponent", () => {
useValue: accountService, useValue: accountService,
}, },
{ {
provide: ModalService, provide: DialogService,
useValue: mock<ModalService>(), useValue: mock<DialogService>(),
}, },
{ {
provide: PasswordRepromptService, provide: PasswordRepromptService,
@@ -70,6 +76,14 @@ describe("UnsecuredWebsitesReportComponent", () => {
provide: CollectionService, provide: CollectionService,
useValue: collectionService, useValue: collectionService,
}, },
{
provide: CipherFormConfigService,
useValue: cipherFormConfigServiceMock,
},
{
provide: AdminConsoleCipherFormConfigService,
useValue: adminConsoleCipherFormConfigService,
},
], ],
schemas: [], schemas: [],
}).compileComponents(); }).compileComponents();

View File

@@ -1,7 +1,6 @@
import { Component, OnInit } from "@angular/core"; import { Component, OnInit } from "@angular/core";
import { CollectionService, Collection } from "@bitwarden/admin-console/common"; 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 { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
@@ -9,7 +8,10 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { CipherType } from "@bitwarden/common/vault/enums"; import { CipherType } from "@bitwarden/common/vault/enums";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { PasswordRepromptService } from "@bitwarden/vault"; import { DialogService } from "@bitwarden/components";
import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";
import { AdminConsoleCipherFormConfigService } from "../../../vault/org-vault/services/admin-console-cipher-form-config.service";
import { CipherReportComponent } from "./cipher-report.component"; import { CipherReportComponent } from "./cipher-report.component";
@@ -23,21 +25,25 @@ export class UnsecuredWebsitesReportComponent extends CipherReportComponent impl
constructor( constructor(
protected cipherService: CipherService, protected cipherService: CipherService,
protected organizationService: OrganizationService, protected organizationService: OrganizationService,
dialogService: DialogService,
accountService: AccountService, accountService: AccountService,
modalService: ModalService,
passwordRepromptService: PasswordRepromptService, passwordRepromptService: PasswordRepromptService,
i18nService: I18nService, i18nService: I18nService,
syncService: SyncService, syncService: SyncService,
private collectionService: CollectionService, private collectionService: CollectionService,
cipherFormConfigService: CipherFormConfigService,
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService,
) { ) {
super( super(
cipherService, cipherService,
modalService, dialogService,
passwordRepromptService, passwordRepromptService,
organizationService, organizationService,
accountService, accountService,
i18nService, i18nService,
syncService, syncService,
cipherFormConfigService,
adminConsoleCipherFormConfigService,
); );
} }

View File

@@ -4,7 +4,6 @@ import { mock, MockProxy } from "jest-mock-extended";
import { of } from "rxjs"; import { of } from "rxjs";
import { I18nPipe } from "@bitwarden/angular/platform/pipes/i18n.pipe"; 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 { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
@@ -14,7 +13,10 @@ import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/pass
import { UserId } from "@bitwarden/common/types/guid"; import { UserId } from "@bitwarden/common/types/guid";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service"; import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { PasswordRepromptService } from "@bitwarden/vault"; import { DialogService } from "@bitwarden/components";
import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";
import { AdminConsoleCipherFormConfigService } from "../../../vault/org-vault/services/admin-console-cipher-form-config.service";
import { cipherData } from "./reports-ciphers.mock"; import { cipherData } from "./reports-ciphers.mock";
import { WeakPasswordsReportComponent } from "./weak-passwords-report.component"; import { WeakPasswordsReportComponent } from "./weak-passwords-report.component";
@@ -25,10 +27,12 @@ describe("WeakPasswordsReportComponent", () => {
let passwordStrengthService: MockProxy<PasswordStrengthServiceAbstraction>; let passwordStrengthService: MockProxy<PasswordStrengthServiceAbstraction>;
let organizationService: MockProxy<OrganizationService>; let organizationService: MockProxy<OrganizationService>;
let syncServiceMock: MockProxy<SyncService>; let syncServiceMock: MockProxy<SyncService>;
let adminConsoleCipherFormConfigServiceMock: MockProxy<AdminConsoleCipherFormConfigService>;
const userId = Utils.newGuid() as UserId; const userId = Utils.newGuid() as UserId;
const accountService: FakeAccountService = mockAccountServiceWith(userId); const accountService: FakeAccountService = mockAccountServiceWith(userId);
beforeEach(() => { beforeEach(() => {
let cipherFormConfigServiceMock: MockProxy<CipherFormConfigService>;
syncServiceMock = mock<SyncService>(); syncServiceMock = mock<SyncService>();
passwordStrengthService = mock<PasswordStrengthServiceAbstraction>(); passwordStrengthService = mock<PasswordStrengthServiceAbstraction>();
organizationService = mock<OrganizationService>(); organizationService = mock<OrganizationService>();
@@ -55,8 +59,8 @@ describe("WeakPasswordsReportComponent", () => {
useValue: accountService, useValue: accountService,
}, },
{ {
provide: ModalService, provide: DialogService,
useValue: mock<ModalService>(), useValue: mock<DialogService>(),
}, },
{ {
provide: PasswordRepromptService, provide: PasswordRepromptService,
@@ -70,6 +74,15 @@ describe("WeakPasswordsReportComponent", () => {
provide: I18nService, provide: I18nService,
useValue: mock<I18nService>(), useValue: mock<I18nService>(),
}, },
{
provide: CipherFormConfigService,
useValue: cipherFormConfigServiceMock,
},
{
provide: AdminConsoleCipherFormConfigService,
useValue: adminConsoleCipherFormConfigServiceMock,
},
], ],
schemas: [], schemas: [],
}).compileComponents(); }).compileComponents();

View File

@@ -2,7 +2,6 @@
// @ts-strict-ignore // @ts-strict-ignore
import { Component, OnInit } from "@angular/core"; import { Component, OnInit } from "@angular/core";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
@@ -12,8 +11,10 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { CipherType } from "@bitwarden/common/vault/enums"; import { CipherType } from "@bitwarden/common/vault/enums";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { BadgeVariant } from "@bitwarden/components"; import { BadgeVariant, DialogService } from "@bitwarden/components";
import { PasswordRepromptService } from "@bitwarden/vault"; import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";
import { AdminConsoleCipherFormConfigService } from "../../../vault/org-vault/services/admin-console-cipher-form-config.service";
import { CipherReportComponent } from "./cipher-report.component"; import { CipherReportComponent } from "./cipher-report.component";
@@ -33,20 +34,24 @@ export class WeakPasswordsReportComponent extends CipherReportComponent implemen
protected cipherService: CipherService, protected cipherService: CipherService,
protected passwordStrengthService: PasswordStrengthServiceAbstraction, protected passwordStrengthService: PasswordStrengthServiceAbstraction,
protected organizationService: OrganizationService, protected organizationService: OrganizationService,
dialogService: DialogService,
protected accountService: AccountService, protected accountService: AccountService,
modalService: ModalService,
passwordRepromptService: PasswordRepromptService, passwordRepromptService: PasswordRepromptService,
i18nService: I18nService, i18nService: I18nService,
syncService: SyncService, syncService: SyncService,
cipherFormConfigService: CipherFormConfigService,
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService,
) { ) {
super( super(
cipherService, cipherService,
modalService, dialogService,
passwordRepromptService, passwordRepromptService,
organizationService, organizationService,
accountService, accountService,
i18nService, i18nService,
syncService, syncService,
cipherFormConfigService,
adminConsoleCipherFormConfigService,
); );
} }

View File

@@ -1,10 +1,15 @@
import { CommonModule } from "@angular/common"; import { CommonModule } from "@angular/common";
import { NgModule } from "@angular/core"; import { NgModule } from "@angular/core";
import { CipherFormConfigService, DefaultCipherFormConfigService } from "@bitwarden/vault";
import { HeaderModule } from "../../layouts/header/header.module"; import { HeaderModule } from "../../layouts/header/header.module";
import { SharedModule } from "../../shared"; import { SharedModule } from "../../shared";
import { OrganizationBadgeModule } from "../../vault/individual-vault/organization-badge/organization-badge.module"; import { OrganizationBadgeModule } from "../../vault/individual-vault/organization-badge/organization-badge.module";
import { PipesModule } from "../../vault/individual-vault/pipes/pipes.module"; import { PipesModule } from "../../vault/individual-vault/pipes/pipes.module";
import { RoutedVaultFilterBridgeService } from "../../vault/individual-vault/vault-filter/services/routed-vault-filter-bridge.service";
import { RoutedVaultFilterService } from "../../vault/individual-vault/vault-filter/services/routed-vault-filter.service";
import { AdminConsoleCipherFormConfigService } from "../../vault/org-vault/services/admin-console-cipher-form-config.service";
import { BreachReportComponent } from "./pages/breach-report.component"; import { BreachReportComponent } from "./pages/breach-report.component";
import { ExposedPasswordsReportComponent } from "./pages/exposed-passwords-report.component"; import { ExposedPasswordsReportComponent } from "./pages/exposed-passwords-report.component";
@@ -37,5 +42,14 @@ import { ReportsSharedModule } from "./shared";
UnsecuredWebsitesReportComponent, UnsecuredWebsitesReportComponent,
WeakPasswordsReportComponent, WeakPasswordsReportComponent,
], ],
providers: [
{
provide: CipherFormConfigService,
useClass: DefaultCipherFormConfigService,
},
RoutedVaultFilterService,
AdminConsoleCipherFormConfigService,
RoutedVaultFilterBridgeService,
],
}) })
export class ReportsModule {} export class ReportsModule {}

View File

@@ -90,7 +90,7 @@ export interface VaultItemDialogParams {
/** /**
* Function to restore a cipher from the trash. * Function to restore a cipher from the trash.
*/ */
restore: (c: CipherView) => Promise<boolean>; restore?: (c: CipherView) => Promise<boolean>;
} }
export enum VaultItemDialogResult { export enum VaultItemDialogResult {
@@ -387,7 +387,7 @@ export class VaultItemDialogComponent implements OnInit, OnDestroy {
} }
restore = async () => { restore = async () => {
await this.params.restore(this.cipher); await this.params.restore?.(this.cipher);
this.dialogRef.close(VaultItemDialogResult.Restored); this.dialogRef.close(VaultItemDialogResult.Restored);
}; };

View File

@@ -8,7 +8,7 @@ import { CipherId } from "@bitwarden/common/types/guid";
import { DialogService } from "@bitwarden/components"; import { DialogService } from "@bitwarden/components";
import { CipherAttachmentsComponent } from "@bitwarden/vault"; import { CipherAttachmentsComponent } from "@bitwarden/vault";
import { SharedModule } from "../../shared"; import { SharedModule } from "../../shared/shared.module";
export interface AttachmentsDialogParams { export interface AttachmentsDialogParams {
cipherId: CipherId; cipherId: CipherId;