Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
--global committed Jan 24, 2025
1 parent 23cbc06 commit b6688e1
Show file tree
Hide file tree
Showing 16 changed files with 93 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { NgModule } from "@angular/core";

import { CipherFormConfigService, DefaultCipherFormConfigService } from "@bitwarden/vault";

import { LooseComponentsModule } from "../../../shared";
import { SharedModule } from "../../../shared/shared.module";
import { ReportsSharedModule } from "../../../tools/reports";
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 { OrganizationReportingRoutingModule } from "./organization-reporting-routing.module";
import { ReportsHomeComponent } from "./reports-home.component";
Expand All @@ -20,14 +15,5 @@ import { ReportsHomeComponent } from "./reports-home.component";
LooseComponentsModule,
],
declarations: [ReportsHomeComponent],
providers: [
// {
// provide: CipherFormConfigService,
// useClass: AdminConsoleCipherFormConfigService,
// },
// AdminConsoleCipherFormConfigService,
// RoutedVaultFilterService,
// RoutedVaultFilterBridgeService,
],
})
export class OrganizationReportingModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,22 @@ import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vau

// eslint-disable-next-line no-restricted-imports
import { InactiveTwoFactorReportComponent as BaseInactiveTwoFactorReportComponent } from "../../../tools/reports/pages/inactive-two-factor-report.component";
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";

@Component({
selector: "app-inactive-two-factor-report",
templateUrl: "../../../tools/reports/pages/inactive-two-factor-report.component.html",
providers: [
{
provide: CipherFormConfigService,
useClass: AdminConsoleCipherFormConfigService,
},
AdminConsoleCipherFormConfigService,
RoutedVaultFilterService,
RoutedVaultFilterBridgeService,
],
})
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
export class InactiveTwoFactorReportComponent
Expand All @@ -41,7 +52,7 @@ export class InactiveTwoFactorReportComponent
i18nService: I18nService,
syncService: SyncService,
cipherFormConfigService: CipherFormConfigService,
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService,
) {
super(
cipherService,
Expand All @@ -53,7 +64,7 @@ export class InactiveTwoFactorReportComponent
i18nService,
syncService,
cipherFormConfigService,
adminConsoleCipherFormConfigService
adminConsoleCipherFormConfigService,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,22 @@ import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vau

// eslint-disable-next-line no-restricted-imports
import { ReusedPasswordsReportComponent as BaseReusedPasswordsReportComponent } from "../../../tools/reports/pages/reused-passwords-report.component";
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";

@Component({
selector: "app-reused-passwords-report",
templateUrl: "../../../tools/reports/pages/reused-passwords-report.component.html",
providers: [
{
provide: CipherFormConfigService,
useClass: AdminConsoleCipherFormConfigService,
},
AdminConsoleCipherFormConfigService,
RoutedVaultFilterService,
RoutedVaultFilterBridgeService,
],
})
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
export class ReusedPasswordsReportComponent
Expand All @@ -42,7 +53,7 @@ export class ReusedPasswordsReportComponent
i18nService: I18nService,
syncService: SyncService,
cipherFormConfigService: CipherFormConfigService,
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService,
) {
super(
cipherService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,22 @@ import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vau

// eslint-disable-next-line no-restricted-imports
import { UnsecuredWebsitesReportComponent as BaseUnsecuredWebsitesReportComponent } from "../../../tools/reports/pages/unsecured-websites-report.component";
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";

@Component({
selector: "app-unsecured-websites-report",
templateUrl: "../../../tools/reports/pages/unsecured-websites-report.component.html",
providers: [
{
provide: CipherFormConfigService,
useClass: AdminConsoleCipherFormConfigService,
},
AdminConsoleCipherFormConfigService,
RoutedVaultFilterService,
RoutedVaultFilterBridgeService,
],
})
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
export class UnsecuredWebsitesReportComponent
Expand All @@ -41,7 +52,7 @@ export class UnsecuredWebsitesReportComponent
syncService: SyncService,
collectionService: CollectionService,
cipherFormConfigService: CipherFormConfigService,
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService,
) {
super(
cipherService,
Expand All @@ -53,7 +64,7 @@ export class UnsecuredWebsitesReportComponent
syncService,
collectionService,
cipherFormConfigService,
adminConsoleCipherFormConfigService
adminConsoleCipherFormConfigService,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,22 @@ import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vau

// eslint-disable-next-line no-restricted-imports
import { WeakPasswordsReportComponent as BaseWeakPasswordsReportComponent } from "../../../tools/reports/pages/weak-passwords-report.component";
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";

@Component({
selector: "app-weak-passwords-report",
templateUrl: "../../../tools/reports/pages/weak-passwords-report.component.html",
providers: [
{
provide: CipherFormConfigService,
useClass: AdminConsoleCipherFormConfigService,
},
AdminConsoleCipherFormConfigService,
RoutedVaultFilterService,
RoutedVaultFilterBridgeService,
],
})
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
export class WeakPasswordsReportComponent
Expand All @@ -44,7 +55,7 @@ export class WeakPasswordsReportComponent
syncService: SyncService,
cipherFormConfigService: CipherFormConfigService,
protected accountService: AccountService,
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService,
) {
super(
cipherService,
Expand All @@ -56,7 +67,7 @@ export class WeakPasswordsReportComponent
i18nService,
syncService,
cipherFormConfigService,
adminConsoleCipherFormConfigService
adminConsoleCipherFormConfigService,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,13 @@ export class CipherReportComponent implements OnDestroy {
return;
}

console.error("here");

if (this.organization) {
const adminCipherFormConfig = await this.adminConsoleCipherFormConfigService.buildConfig(
"edit",
cipher.id as CipherId,
cipher.type,
);

console.error("failed");
await this.openVaultItemDialog("view", adminCipherFormConfig);
} else {
const cipherFormConfig = await this.cipherFormConfigService.buildConfig(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { DialogService } from "@bitwarden/components";
import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";

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 { CipherReportComponent } from "./cipher-report.component";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { DialogService } from "@bitwarden/components";
import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";

import { CipherReportComponent } from "./cipher-report.component";
import { AdminConsoleCipherFormConfigService } from "../../../vault/org-vault/services/admin-console-cipher-form-config.service";

import { CipherReportComponent } from "./cipher-report.component";

@Component({
selector: "app-inactive-two-factor-report",
templateUrl: "inactive-two-factor-report.component.html",
Expand All @@ -36,8 +37,7 @@ export class InactiveTwoFactorReportComponent extends CipherReportComponent impl
i18nService: I18nService,
syncService: SyncService,
cipherFormConfigService: CipherFormConfigService,
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService

adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService,
) {
super(
cipherService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { DialogService } from "@bitwarden/components";
import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";

import { CipherReportComponent } from "./cipher-report.component";
import { AdminConsoleCipherFormConfigService } from "../../../vault/org-vault/services/admin-console-cipher-form-config.service";

import { CipherReportComponent } from "./cipher-report.component";

@Component({
selector: "app-reused-passwords-report",
templateUrl: "reused-passwords-report.component.html",
Expand All @@ -32,8 +33,7 @@ export class ReusedPasswordsReportComponent extends CipherReportComponent implem
i18nService: I18nService,
syncService: SyncService,
cipherFormConfigService: CipherFormConfigService,
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService

adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService,
) {
super(
cipherService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.serv
import { DialogService } from "@bitwarden/components";
import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";

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 { CipherReportComponent } from "./cipher-report.component";
import { cipherData } from "./reports-ciphers.mock";
import { UnsecuredWebsitesReportComponent } from "./unsecured-websites-report.component";

Expand All @@ -26,15 +30,24 @@ describe("UnsecuredWebsitesReportComponent", () => {
let syncServiceMock: MockProxy<SyncService>;
let collectionService: MockProxy<CollectionService>;
let accountService: FakeAccountService;
let cipherReportComponentMock: MockProxy<CipherReportComponent>;
let cipherFormConfigServiceMock: MockProxy<CipherFormConfigService>;
let routedVaultFilterServiceMock: MockProxy<RoutedVaultFilterService>;
let adminConsoleCipherFormConfigServiceMock: MockProxy<AdminConsoleCipherFormConfigService>;

const userId = Utils.newGuid() as UserId;

beforeEach(() => {
let cipherFormConfigServiceMock: MockProxy<CipherFormConfigService>;
organizationService = mock<OrganizationService>();
organizationService.organizations$.mockReturnValue(of([]));
syncServiceMock = mock<SyncService>();
collectionService = mock<CollectionService>();
accountService = mockAccountServiceWith(userId);
cipherReportComponentMock = mock<CipherReportComponent>();
cipherFormConfigServiceMock = mock<CipherFormConfigService>();
routedVaultFilterServiceMock = mock<RoutedVaultFilterService>();
adminConsoleCipherFormConfigServiceMock = mock<AdminConsoleCipherFormConfigService>();

// 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({
Expand Down Expand Up @@ -76,6 +89,15 @@ describe("UnsecuredWebsitesReportComponent", () => {
provide: CipherFormConfigService,
useValue: cipherFormConfigServiceMock,
},
{
provide: CipherReportComponent,
useClass: cipherReportComponentMock,
},
{ provide: RoutedVaultFilterService, useValue: routedVaultFilterServiceMock },
{
provide: AdminConsoleCipherFormConfigService,
useClass: adminConsoleCipherFormConfigServiceMock, // Ensure this service is provided
},
],
schemas: [],
}).compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { DialogService } from "@bitwarden/components";
import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";

import { CipherReportComponent } from "./cipher-report.component";
import { AdminConsoleCipherFormConfigService } from "../../../vault/org-vault/services/admin-console-cipher-form-config.service";

import { CipherReportComponent } from "./cipher-report.component";

@Component({
selector: "app-unsecured-websites-report",
templateUrl: "unsecured-websites-report.component.html",
Expand All @@ -31,7 +32,7 @@ export class UnsecuredWebsitesReportComponent extends CipherReportComponent impl
syncService: SyncService,
private collectionService: CollectionService,
cipherFormConfigService: CipherFormConfigService,
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService,
) {
super(
cipherService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { CipherType } from "@bitwarden/common/vault/enums";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { BadgeVariant , DialogService } from "@bitwarden/components";
import { BadgeVariant, DialogService } from "@bitwarden/components";
import { CipherFormConfigService, PasswordRepromptService } from "@bitwarden/vault";

import { CipherReportComponent } from "./cipher-report.component";
import { AdminConsoleCipherFormConfigService } from "../../../vault/org-vault/services/admin-console-cipher-form-config.service";

import { CipherReportComponent } from "./cipher-report.component";

type ReportScore = { label: string; badgeVariant: BadgeVariant };
type ReportResult = CipherView & { score: number; reportValue: ReportScore };

Expand All @@ -39,7 +40,7 @@ export class WeakPasswordsReportComponent extends CipherReportComponent implemen
i18nService: I18nService,
syncService: SyncService,
cipherFormConfigService: CipherFormConfigService,
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService
adminConsoleCipherFormConfigService: AdminConsoleCipherFormConfigService,
) {
super(
cipherService,
Expand All @@ -50,7 +51,7 @@ export class WeakPasswordsReportComponent extends CipherReportComponent implemen
i18nService,
syncService,
cipherFormConfigService,
adminConsoleCipherFormConfigService
adminConsoleCipherFormConfigService,
);
}

Expand Down
5 changes: 4 additions & 1 deletion apps/web/src/app/tools/reports/reports.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import { WeakPasswordsReportComponent } from "./pages/weak-passwords-report.comp
import { ReportsLayoutComponent } from "./reports-layout.component";
import { ReportsRoutingModule } from "./reports-routing.module";
import { ReportsSharedModule } from "./shared";

import { AdminConsoleCipherFormConfigService } from "../../vault/org-vault/services/admin-console-cipher-form-config.service";

Check failure on line 22 in apps/web/src/app/tools/reports/reports.module.ts

View workflow job for this annotation

GitHub Actions / Lint

`../../vault/org-vault/services/admin-console-cipher-form-config.service` import should occur before import of `./pages/breach-report.component`
import { RoutedVaultFilterService } from "../../vault/individual-vault/vault-filter/services/routed-vault-filter.service";

Check failure on line 23 in apps/web/src/app/tools/reports/reports.module.ts

View workflow job for this annotation

GitHub Actions / Lint

`../../vault/individual-vault/vault-filter/services/routed-vault-filter.service` import should occur before import of `./pages/breach-report.component`
import { RoutedVaultFilterBridgeService } from "../../vault/individual-vault/vault-filter/services/routed-vault-filter-bridge.service";

Check failure on line 24 in apps/web/src/app/tools/reports/reports.module.ts

View workflow job for this annotation

GitHub Actions / Lint

`../../vault/individual-vault/vault-filter/services/routed-vault-filter-bridge.service` import should occur before import of `./pages/breach-report.component`

@NgModule({
imports: [
Expand Down Expand Up @@ -47,7 +49,8 @@ import { RoutedVaultFilterService } from "../../vault/individual-vault/vault-fil
useClass: DefaultCipherFormConfigService,
},
RoutedVaultFilterService,
AdminConsoleCipherFormConfigService
AdminConsoleCipherFormConfigService,
RoutedVaultFilterBridgeService,
],
})
export class ReportsModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export class RoutedVaultFilterService implements OnDestroy {
filter$: Observable<RoutedVaultFilterModel>;

constructor(activatedRoute: ActivatedRoute) {
console.log("constructor for routed vault filter service {0} {1} ", activatedRoute.paramMap, activatedRoute.queryParamMap);
this.filter$ = combineLatest([activatedRoute.paramMap, activatedRoute.queryParamMap]).pipe(
map(([params, queryParams]) => {
const unsafeType = queryParams.get("type");
Expand Down
Loading

0 comments on commit b6688e1

Please sign in to comment.