mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
[PM-13454] Get hostname for login uri (#11646)
* add uri to raw data * add uri * PM-13454 modify the hostnames to friendly names * PM-13454 removed commented code * add password health service * add spec. fix logic in password reuse * PM-13454 added member count and group by uris * PM-13454 removed moved files * PM-13454 fixed linting errors and failed unit tests * PM-13454 grouping member count * PM-13454 added unit test for totalGroupedMembersMap * PM-13454 removed the grouping - show a flatmap --------- Co-authored-by: jaasen-livefront <jaasen@livefront.com>
This commit is contained in:
@@ -12,6 +12,13 @@ export const mockCiphers: any[] = [
|
||||
organizationUseTotp: false,
|
||||
login: {
|
||||
password: "123",
|
||||
hasUris: true,
|
||||
uris: [
|
||||
{ uri: "www.google.com" },
|
||||
{ uri: "accounts.google.com" },
|
||||
{ uri: "https://www.google.com" },
|
||||
{ uri: "https://www.google.com/login" },
|
||||
],
|
||||
},
|
||||
edit: false,
|
||||
viewPassword: true,
|
||||
|
||||
@@ -64,5 +64,16 @@ export const mockMemberCipherDetailsResponse: { data: any[] } = {
|
||||
"cbea34a8-bde4-46ad-9d19-b05001228xy4",
|
||||
],
|
||||
},
|
||||
{
|
||||
UserName: "Chris Finch Tester",
|
||||
Email: "chris.finch@wernhamhogg.uk",
|
||||
UsesKeyConnector: true,
|
||||
cipherIds: [
|
||||
"cbea34a8-bde4-46ad-9d19-b05001228ab2",
|
||||
"cbea34a8-bde4-46ad-9d19-b05001228cd3",
|
||||
"cbea34a8-bde4-46ad-9d19-b05001228xy4",
|
||||
"cbea34a8-bde4-46ad-9d19-b05001228ab1",
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -99,12 +99,12 @@ describe("PasswordHealthService", () => {
|
||||
|
||||
it("should calculate total members per cipher", () => {
|
||||
expect(service.totalMembersMap.size).toBeGreaterThan(0);
|
||||
expect(service.totalMembersMap.get("cbea34a8-bde4-46ad-9d19-b05001228ab1")).toBe(2);
|
||||
expect(service.totalMembersMap.get("cbea34a8-bde4-46ad-9d19-b05001228ab2")).toBe(4);
|
||||
expect(service.totalMembersMap.get("cbea34a8-bde4-46ad-9d19-b05001228cd3")).toBe(5);
|
||||
expect(service.totalMembersMap.get("cbea34a8-bde4-46ad-9d19-b05001228ab1")).toBe(3);
|
||||
expect(service.totalMembersMap.get("cbea34a8-bde4-46ad-9d19-b05001228ab2")).toBe(5);
|
||||
expect(service.totalMembersMap.get("cbea34a8-bde4-46ad-9d19-b05001228cd3")).toBe(6);
|
||||
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-b05001228xy4")).toBe(6);
|
||||
expect(service.totalMembersMap.get("cbea34a8-bde4-46ad-9d19-b05001228xy4")).toBe(7);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { Inject, Injectable } from "@angular/core";
|
||||
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import { mockCiphers } from "@bitwarden/bit-common/tools/reports/access-intelligence/services/ciphers.mock";
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import { mockMemberCipherDetailsResponse } from "@bitwarden/bit-common/tools/reports/access-intelligence/services/member-cipher-details-response.mock";
|
||||
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
||||
@@ -8,9 +12,6 @@ import { CipherType } from "@bitwarden/common/vault/enums";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
import { BadgeVariant } from "@bitwarden/components";
|
||||
|
||||
import { mockCiphers } from "./ciphers.mock";
|
||||
import { mockMemberCipherDetailsResponse } from "./member-cipher-details-response.mock";
|
||||
|
||||
@Injectable()
|
||||
export class PasswordHealthService {
|
||||
reportCiphers: CipherView[] = [];
|
||||
@@ -157,10 +158,27 @@ export class PasswordHealthService {
|
||||
}
|
||||
}
|
||||
|
||||
private checkForExistingCipher(ciph: CipherView) {
|
||||
checkForExistingCipher(ciph: CipherView) {
|
||||
if (!this.reportCipherIds.includes(ciph.id)) {
|
||||
this.reportCipherIds.push(ciph.id);
|
||||
this.reportCiphers.push(ciph);
|
||||
}
|
||||
}
|
||||
|
||||
groupCiphersByLoginUri(): CipherView[] {
|
||||
const cipherViews: CipherView[] = [];
|
||||
const cipherUris: string[] = [];
|
||||
const ciphers = this.reportCiphers;
|
||||
|
||||
ciphers.forEach((ciph) => {
|
||||
const uris = ciph.login?.uris ?? [];
|
||||
uris.map((u: { uri: string }) => {
|
||||
const uri = Utils.getHostname(u.uri).replace("www.", "");
|
||||
cipherUris.push(uri);
|
||||
cipherViews.push({ ...ciph, hostURI: uri } as CipherView & { hostURI: string });
|
||||
});
|
||||
});
|
||||
|
||||
return cipherViews;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user