mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-14 10:26:19 +01:00
[PM-14813] - Implement server API to user member cipher details instead of mock data (#11978)
* use cipher details data * fix failing tests * fix failing tests
This commit is contained in:
parent
379efb1326
commit
0b11596f08
@ -4,7 +4,11 @@ import { mock, MockProxy } from "jest-mock-extended";
|
|||||||
import { of } from "rxjs";
|
import { of } from "rxjs";
|
||||||
|
|
||||||
// eslint-disable-next-line no-restricted-imports
|
// eslint-disable-next-line no-restricted-imports
|
||||||
import { PasswordHealthService } from "@bitwarden/bit-common/tools/reports/risk-insights";
|
import {
|
||||||
|
MemberCipherDetailsApiService,
|
||||||
|
PasswordHealthService,
|
||||||
|
} from "@bitwarden/bit-common/tools/reports/risk-insights";
|
||||||
|
import { ApiService } from "@bitwarden/common/abstractions/api.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 { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
@ -46,6 +50,14 @@ describe("PasswordHealthMembersUriComponent", () => {
|
|||||||
url: of([]),
|
url: of([]),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
provide: MemberCipherDetailsApiService,
|
||||||
|
useValue: mock<MemberCipherDetailsApiService>(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
provide: ApiService,
|
||||||
|
useValue: mock<ApiService>(),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
});
|
});
|
||||||
|
@ -6,7 +6,10 @@ import { map } from "rxjs";
|
|||||||
|
|
||||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||||
// eslint-disable-next-line no-restricted-imports
|
// eslint-disable-next-line no-restricted-imports
|
||||||
import { PasswordHealthService } from "@bitwarden/bit-common/tools/reports/risk-insights";
|
import {
|
||||||
|
MemberCipherDetailsApiService,
|
||||||
|
PasswordHealthService,
|
||||||
|
} from "@bitwarden/bit-common/tools/reports/risk-insights";
|
||||||
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 { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||||
@ -25,8 +28,6 @@ import {
|
|||||||
// eslint-disable-next-line no-restricted-imports
|
// eslint-disable-next-line no-restricted-imports
|
||||||
import { HeaderModule } from "../../layouts/header/header.module";
|
import { HeaderModule } from "../../layouts/header/header.module";
|
||||||
// eslint-disable-next-line no-restricted-imports
|
// eslint-disable-next-line no-restricted-imports
|
||||||
import { OrganizationBadgeModule } from "../../vault/individual-vault/organization-badge/organization-badge.module";
|
|
||||||
// eslint-disable-next-line no-restricted-imports
|
|
||||||
import { PipesModule } from "../../vault/individual-vault/pipes/pipes.module";
|
import { PipesModule } from "../../vault/individual-vault/pipes/pipes.module";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -35,7 +36,6 @@ import { PipesModule } from "../../vault/individual-vault/pipes/pipes.module";
|
|||||||
templateUrl: "password-health-members-uri.component.html",
|
templateUrl: "password-health-members-uri.component.html",
|
||||||
imports: [
|
imports: [
|
||||||
BadgeModule,
|
BadgeModule,
|
||||||
OrganizationBadgeModule,
|
|
||||||
CommonModule,
|
CommonModule,
|
||||||
ContainerComponent,
|
ContainerComponent,
|
||||||
PipesModule,
|
PipesModule,
|
||||||
@ -43,7 +43,7 @@ import { PipesModule } from "../../vault/individual-vault/pipes/pipes.module";
|
|||||||
HeaderModule,
|
HeaderModule,
|
||||||
TableModule,
|
TableModule,
|
||||||
],
|
],
|
||||||
providers: [PasswordHealthService],
|
providers: [PasswordHealthService, MemberCipherDetailsApiService],
|
||||||
})
|
})
|
||||||
export class PasswordHealthMembersURIComponent implements OnInit {
|
export class PasswordHealthMembersURIComponent implements OnInit {
|
||||||
passwordStrengthMap = new Map<string, [string, BadgeVariant]>();
|
passwordStrengthMap = new Map<string, [string, BadgeVariant]>();
|
||||||
@ -74,6 +74,7 @@ export class PasswordHealthMembersURIComponent implements OnInit {
|
|||||||
protected auditService: AuditService,
|
protected auditService: AuditService,
|
||||||
protected i18nService: I18nService,
|
protected i18nService: I18nService,
|
||||||
protected activatedRoute: ActivatedRoute,
|
protected activatedRoute: ActivatedRoute,
|
||||||
|
protected memberCipherDetailsApiService: MemberCipherDetailsApiService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@ -93,6 +94,7 @@ export class PasswordHealthMembersURIComponent implements OnInit {
|
|||||||
this.passwordStrengthService,
|
this.passwordStrengthService,
|
||||||
this.auditService,
|
this.auditService,
|
||||||
this.cipherService,
|
this.cipherService,
|
||||||
|
this.memberCipherDetailsApiService,
|
||||||
organizationId,
|
organizationId,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -5,7 +5,10 @@ import { ActivatedRoute } from "@angular/router";
|
|||||||
import { debounceTime, map } from "rxjs";
|
import { debounceTime, map } from "rxjs";
|
||||||
|
|
||||||
// eslint-disable-next-line no-restricted-imports
|
// eslint-disable-next-line no-restricted-imports
|
||||||
import { PasswordHealthService } from "@bitwarden/bit-common/tools/reports/risk-insights";
|
import {
|
||||||
|
MemberCipherDetailsApiService,
|
||||||
|
PasswordHealthService,
|
||||||
|
} from "@bitwarden/bit-common/tools/reports/risk-insights";
|
||||||
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
||||||
@ -18,12 +21,10 @@ import {
|
|||||||
TableModule,
|
TableModule,
|
||||||
ToastService,
|
ToastService,
|
||||||
} from "@bitwarden/components";
|
} from "@bitwarden/components";
|
||||||
import { CardComponent } from "@bitwarden/tools-card";
|
|
||||||
|
|
||||||
import { HeaderModule } from "../../layouts/header/header.module";
|
import { HeaderModule } from "../../layouts/header/header.module";
|
||||||
// eslint-disable-next-line no-restricted-imports
|
// eslint-disable-next-line no-restricted-imports
|
||||||
import { SharedModule } from "../../shared";
|
import { SharedModule } from "../../shared";
|
||||||
import { OrganizationBadgeModule } from "../../vault/individual-vault/organization-badge/organization-badge.module";
|
|
||||||
// eslint-disable-next-line no-restricted-imports
|
// eslint-disable-next-line no-restricted-imports
|
||||||
import { PipesModule } from "../../vault/individual-vault/pipes/pipes.module";
|
import { PipesModule } from "../../vault/individual-vault/pipes/pipes.module";
|
||||||
|
|
||||||
@ -31,17 +32,8 @@ import { PipesModule } from "../../vault/individual-vault/pipes/pipes.module";
|
|||||||
standalone: true,
|
standalone: true,
|
||||||
selector: "tools-password-health-members",
|
selector: "tools-password-health-members",
|
||||||
templateUrl: "password-health-members.component.html",
|
templateUrl: "password-health-members.component.html",
|
||||||
imports: [
|
imports: [PipesModule, HeaderModule, SearchModule, FormsModule, SharedModule, TableModule],
|
||||||
CardComponent,
|
providers: [PasswordHealthService, MemberCipherDetailsApiService],
|
||||||
OrganizationBadgeModule,
|
|
||||||
PipesModule,
|
|
||||||
HeaderModule,
|
|
||||||
SearchModule,
|
|
||||||
FormsModule,
|
|
||||||
SharedModule,
|
|
||||||
TableModule,
|
|
||||||
],
|
|
||||||
providers: [PasswordHealthService],
|
|
||||||
})
|
})
|
||||||
export class PasswordHealthMembersComponent implements OnInit {
|
export class PasswordHealthMembersComponent implements OnInit {
|
||||||
passwordStrengthMap = new Map<string, [string, BadgeVariant]>();
|
passwordStrengthMap = new Map<string, [string, BadgeVariant]>();
|
||||||
@ -69,6 +61,7 @@ export class PasswordHealthMembersComponent implements OnInit {
|
|||||||
protected i18nService: I18nService,
|
protected i18nService: I18nService,
|
||||||
protected activatedRoute: ActivatedRoute,
|
protected activatedRoute: ActivatedRoute,
|
||||||
protected toastService: ToastService,
|
protected toastService: ToastService,
|
||||||
|
protected memberCipherDetailsApiService: MemberCipherDetailsApiService,
|
||||||
) {
|
) {
|
||||||
this.searchControl.valueChanges
|
this.searchControl.valueChanges
|
||||||
.pipe(debounceTime(200), takeUntilDestroyed())
|
.pipe(debounceTime(200), takeUntilDestroyed())
|
||||||
@ -92,6 +85,7 @@ export class PasswordHealthMembersComponent implements OnInit {
|
|||||||
this.passwordStrengthService,
|
this.passwordStrengthService,
|
||||||
this.auditService,
|
this.auditService,
|
||||||
this.cipherService,
|
this.cipherService,
|
||||||
|
this.memberCipherDetailsApiService,
|
||||||
organizationId,
|
organizationId,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -4,7 +4,11 @@ import { mock } from "jest-mock-extended";
|
|||||||
import { of } from "rxjs";
|
import { of } from "rxjs";
|
||||||
|
|
||||||
// eslint-disable-next-line no-restricted-imports
|
// eslint-disable-next-line no-restricted-imports
|
||||||
import { PasswordHealthService } from "@bitwarden/bit-common/tools/reports/risk-insights";
|
import {
|
||||||
|
MemberCipherDetailsApiService,
|
||||||
|
PasswordHealthService,
|
||||||
|
} from "@bitwarden/bit-common/tools/reports/risk-insights";
|
||||||
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
||||||
@ -30,6 +34,8 @@ describe("PasswordHealthComponent", () => {
|
|||||||
{ provide: CipherService, useValue: mock<CipherService>() },
|
{ provide: CipherService, useValue: mock<CipherService>() },
|
||||||
{ provide: I18nService, useValue: mock<I18nService>() },
|
{ provide: I18nService, useValue: mock<I18nService>() },
|
||||||
{ provide: AuditService, useValue: mock<AuditService>() },
|
{ provide: AuditService, useValue: mock<AuditService>() },
|
||||||
|
{ provide: ApiService, useValue: mock<ApiService>() },
|
||||||
|
{ provide: MemberCipherDetailsApiService, useValue: mock<MemberCipherDetailsApiService>() },
|
||||||
{
|
{
|
||||||
provide: PasswordStrengthServiceAbstraction,
|
provide: PasswordStrengthServiceAbstraction,
|
||||||
useValue: mock<PasswordStrengthServiceAbstraction>(),
|
useValue: mock<PasswordStrengthServiceAbstraction>(),
|
||||||
|
@ -6,7 +6,10 @@ import { map } from "rxjs";
|
|||||||
|
|
||||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||||
// eslint-disable-next-line no-restricted-imports
|
// eslint-disable-next-line no-restricted-imports
|
||||||
import { PasswordHealthService } from "@bitwarden/bit-common/tools/reports/risk-insights";
|
import {
|
||||||
|
MemberCipherDetailsApiService,
|
||||||
|
PasswordHealthService,
|
||||||
|
} from "@bitwarden/bit-common/tools/reports/risk-insights";
|
||||||
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
||||||
@ -41,7 +44,7 @@ import { PipesModule } from "../../vault/individual-vault/pipes/pipes.module";
|
|||||||
HeaderModule,
|
HeaderModule,
|
||||||
TableModule,
|
TableModule,
|
||||||
],
|
],
|
||||||
providers: [PasswordHealthService],
|
providers: [PasswordHealthService, MemberCipherDetailsApiService],
|
||||||
})
|
})
|
||||||
export class PasswordHealthComponent implements OnInit {
|
export class PasswordHealthComponent implements OnInit {
|
||||||
passwordStrengthMap = new Map<string, [string, BadgeVariant]>();
|
passwordStrengthMap = new Map<string, [string, BadgeVariant]>();
|
||||||
@ -62,6 +65,7 @@ export class PasswordHealthComponent implements OnInit {
|
|||||||
protected auditService: AuditService,
|
protected auditService: AuditService,
|
||||||
protected i18nService: I18nService,
|
protected i18nService: I18nService,
|
||||||
protected activatedRoute: ActivatedRoute,
|
protected activatedRoute: ActivatedRoute,
|
||||||
|
protected memberCipherDetailsApiService: MemberCipherDetailsApiService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@ -81,6 +85,7 @@ export class PasswordHealthComponent implements OnInit {
|
|||||||
this.passwordStrengthService,
|
this.passwordStrengthService,
|
||||||
this.auditService,
|
this.auditService,
|
||||||
this.cipherService,
|
this.cipherService,
|
||||||
|
this.memberCipherDetailsApiService,
|
||||||
organizationId,
|
organizationId,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -4,8 +4,7 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
|||||||
|
|
||||||
import { MemberCipherDetailsApiService } from "./member-cipher-details-api.service";
|
import { MemberCipherDetailsApiService } from "./member-cipher-details-api.service";
|
||||||
|
|
||||||
const mockMemberCipherDetails: any = {
|
export const mockMemberCipherDetails: any = [
|
||||||
data: [
|
|
||||||
{
|
{
|
||||||
userName: "David Brent",
|
userName: "David Brent",
|
||||||
email: "david.brent@wernhamhogg.uk",
|
email: "david.brent@wernhamhogg.uk",
|
||||||
@ -70,8 +69,7 @@ const mockMemberCipherDetails: any = {
|
|||||||
"cbea34a8-bde4-46ad-9d19-b05001228xy4",
|
"cbea34a8-bde4-46ad-9d19-b05001228xy4",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
];
|
||||||
};
|
|
||||||
|
|
||||||
describe("Member Cipher Details API Service", () => {
|
describe("Member Cipher Details API Service", () => {
|
||||||
let memberCipherDetailsApiService: MemberCipherDetailsApiService;
|
let memberCipherDetailsApiService: MemberCipherDetailsApiService;
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
|
import { Injectable } from "@angular/core";
|
||||||
|
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { ListResponse } from "@bitwarden/common/models/response/list.response";
|
|
||||||
|
|
||||||
import { MemberCipherDetailsResponse } from "../response/member-cipher-details.response";
|
import { MemberCipherDetailsResponse } from "../response/member-cipher-details.response";
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
export class MemberCipherDetailsApiService {
|
export class MemberCipherDetailsApiService {
|
||||||
constructor(private apiService: ApiService) {}
|
constructor(private apiService: ApiService) {}
|
||||||
|
|
||||||
@ -21,7 +23,6 @@ export class MemberCipherDetailsApiService {
|
|||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
const listResponse = new ListResponse(response, MemberCipherDetailsResponse);
|
return response;
|
||||||
return listResponse.data.map((r) => new MemberCipherDetailsResponse(r));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,17 @@ import { TestBed } from "@angular/core/testing";
|
|||||||
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
||||||
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
||||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||||
import { CipherData } from "@bitwarden/common/vault/models/data/cipher.data";
|
|
||||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||||
|
|
||||||
import { mockCiphers } from "./ciphers.mock";
|
import { mockCiphers } from "./ciphers.mock";
|
||||||
|
import { MemberCipherDetailsApiService } from "./member-cipher-details-api.service";
|
||||||
|
import { mockMemberCipherDetails } from "./member-cipher-details-api.service.spec";
|
||||||
import { PasswordHealthService } from "./password-health.service";
|
import { PasswordHealthService } from "./password-health.service";
|
||||||
|
|
||||||
describe("PasswordHealthService", () => {
|
describe("PasswordHealthService", () => {
|
||||||
let service: PasswordHealthService;
|
let service: PasswordHealthService;
|
||||||
let cipherService: CipherService;
|
let cipherService: CipherService;
|
||||||
|
let memberCipherDetailsApiService: MemberCipherDetailsApiService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
@ -35,7 +37,13 @@ describe("PasswordHealthService", () => {
|
|||||||
{
|
{
|
||||||
provide: CipherService,
|
provide: CipherService,
|
||||||
useValue: {
|
useValue: {
|
||||||
getAllFromApiForOrganization: jest.fn().mockResolvedValue(CipherData),
|
getAllFromApiForOrganization: jest.fn().mockResolvedValue(mockCiphers),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
provide: MemberCipherDetailsApiService,
|
||||||
|
useValue: {
|
||||||
|
getMemberCipherDetails: jest.fn().mockResolvedValue(mockMemberCipherDetails),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ provide: "organizationId", useValue: "org1" },
|
{ provide: "organizationId", useValue: "org1" },
|
||||||
@ -44,6 +52,7 @@ describe("PasswordHealthService", () => {
|
|||||||
|
|
||||||
service = TestBed.inject(PasswordHealthService);
|
service = TestBed.inject(PasswordHealthService);
|
||||||
cipherService = TestBed.inject(CipherService);
|
cipherService = TestBed.inject(CipherService);
|
||||||
|
memberCipherDetailsApiService = TestBed.inject(MemberCipherDetailsApiService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be created", () => {
|
it("should be created", () => {
|
||||||
@ -68,6 +77,10 @@ describe("PasswordHealthService", () => {
|
|||||||
expect(cipherService.getAllFromApiForOrganization).toHaveBeenCalledWith("org1");
|
expect(cipherService.getAllFromApiForOrganization).toHaveBeenCalledWith("org1");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should fetch member cipher details", () => {
|
||||||
|
expect(memberCipherDetailsApiService.getMemberCipherDetails).toHaveBeenCalledWith("org1");
|
||||||
|
});
|
||||||
|
|
||||||
it("should populate reportCiphers with ciphers that have issues", () => {
|
it("should populate reportCiphers with ciphers that have issues", () => {
|
||||||
expect(service.reportCiphers.length).toBeGreaterThan(0);
|
expect(service.reportCiphers.length).toBeGreaterThan(0);
|
||||||
});
|
});
|
||||||
@ -99,12 +112,12 @@ describe("PasswordHealthService", () => {
|
|||||||
|
|
||||||
it("should calculate total members per cipher", () => {
|
it("should calculate total members per cipher", () => {
|
||||||
expect(service.totalMembersMap.size).toBeGreaterThan(0);
|
expect(service.totalMembersMap.size).toBeGreaterThan(0);
|
||||||
expect(service.totalMembersMap.get("cbea34a8-bde4-46ad-9d19-b05001228ab1")).toBe(3);
|
expect(service.totalMembersMap.get("cbea34a8-bde4-46ad-9d19-b05001228ab1")).toBe(2);
|
||||||
expect(service.totalMembersMap.get("cbea34a8-bde4-46ad-9d19-b05001228ab2")).toBe(5);
|
expect(service.totalMembersMap.get("cbea34a8-bde4-46ad-9d19-b05001228ab2")).toBe(4);
|
||||||
expect(service.totalMembersMap.get("cbea34a8-bde4-46ad-9d19-b05001228cd3")).toBe(6);
|
expect(service.totalMembersMap.get("cbea34a8-bde4-46ad-9d19-b05001228cd3")).toBe(5);
|
||||||
expect(service.totalMembersMap.get("cbea34a8-bde4-46ad-9d19-b05001227nm5")).toBe(4);
|
expect(service.totalMembersMap.get("cbea34a8-bde4-46ad-9d19-b05001227nm5")).toBe(4);
|
||||||
expect(service.totalMembersMap.get("cbea34a8-bde4-46ad-9d19-b05001227nm7")).toBe(1);
|
expect(service.totalMembersMap.get("cbea34a8-bde4-46ad-9d19-b05001227nm7")).toBe(1);
|
||||||
expect(service.totalMembersMap.get("cbea34a8-bde4-46ad-9d19-b05001228xy4")).toBe(7);
|
expect(service.totalMembersMap.get("cbea34a8-bde4-46ad-9d19-b05001228xy4")).toBe(6);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
import { Inject, Injectable } from "@angular/core";
|
import { Inject, Injectable } from "@angular/core";
|
||||||
|
|
||||||
// eslint-disable-next-line no-restricted-imports
|
|
||||||
import { mockCiphers } from "@bitwarden/bit-common/tools/reports/risk-insights/services/ciphers.mock";
|
|
||||||
// eslint-disable-next-line no-restricted-imports
|
|
||||||
import { mockMemberCipherDetailsResponse } from "@bitwarden/bit-common/tools/reports/risk-insights/services/member-cipher-details-response.mock";
|
|
||||||
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
||||||
@ -12,6 +8,8 @@ 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 } from "@bitwarden/components";
|
||||||
|
|
||||||
|
import { MemberCipherDetailsApiService } from "./member-cipher-details-api.service";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PasswordHealthService {
|
export class PasswordHealthService {
|
||||||
reportCiphers: CipherView[] = [];
|
reportCiphers: CipherView[] = [];
|
||||||
@ -30,21 +28,23 @@ export class PasswordHealthService {
|
|||||||
private passwordStrengthService: PasswordStrengthServiceAbstraction,
|
private passwordStrengthService: PasswordStrengthServiceAbstraction,
|
||||||
private auditService: AuditService,
|
private auditService: AuditService,
|
||||||
private cipherService: CipherService,
|
private cipherService: CipherService,
|
||||||
|
private memberCipherDetailsApiService: MemberCipherDetailsApiService,
|
||||||
@Inject("organizationId") private organizationId: string,
|
@Inject("organizationId") private organizationId: string,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async generateReport() {
|
async generateReport() {
|
||||||
let allCiphers = await this.cipherService.getAllFromApiForOrganization(this.organizationId);
|
const allCiphers = await this.cipherService.getAllFromApiForOrganization(this.organizationId);
|
||||||
// TODO remove when actual user member data is available
|
|
||||||
allCiphers = mockCiphers;
|
|
||||||
allCiphers.forEach(async (cipher) => {
|
allCiphers.forEach(async (cipher) => {
|
||||||
this.findWeakPassword(cipher);
|
this.findWeakPassword(cipher);
|
||||||
this.findReusedPassword(cipher);
|
this.findReusedPassword(cipher);
|
||||||
await this.findExposedPassword(cipher);
|
await this.findExposedPassword(cipher);
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO - fetch actual user member when data is available
|
const memberCipherDetails = await this.memberCipherDetailsApiService.getMemberCipherDetails(
|
||||||
mockMemberCipherDetailsResponse.data.forEach((user) => {
|
this.organizationId,
|
||||||
|
);
|
||||||
|
|
||||||
|
memberCipherDetails.forEach((user) => {
|
||||||
user.cipherIds.forEach((cipherId: string) => {
|
user.cipherIds.forEach((cipherId: string) => {
|
||||||
if (this.totalMembersMap.has(cipherId)) {
|
if (this.totalMembersMap.has(cipherId)) {
|
||||||
this.totalMembersMap.set(cipherId, (this.totalMembersMap.get(cipherId) || 0) + 1);
|
this.totalMembersMap.set(cipherId, (this.totalMembersMap.get(cipherId) || 0) + 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user