mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 13:23:34 +00:00
[PM-21001] Move tools usage of encrypt service (#14540)
* Add new encrypt service functions * Undo changes * Cleanup * Fix build * Fix comments * Move tools usage of encrypt service
This commit is contained in:
@@ -59,7 +59,7 @@ describe("CriticalAppsService", () => {
|
||||
{ id: "id2", organizationId: "org1", uri: "https://example.org" },
|
||||
] as PasswordHealthReportApplicationsResponse[];
|
||||
|
||||
encryptService.encrypt.mockResolvedValue(new EncString("encryptedUrlName"));
|
||||
encryptService.encryptString.mockResolvedValue(new EncString("encryptedUrlName"));
|
||||
criticalAppsApiService.saveCriticalApps.mockReturnValue(of(response));
|
||||
|
||||
// act
|
||||
@@ -67,7 +67,7 @@ describe("CriticalAppsService", () => {
|
||||
|
||||
// expectations
|
||||
expect(keyService.getOrgKey).toHaveBeenCalledWith("org1");
|
||||
expect(encryptService.encrypt).toHaveBeenCalledTimes(2);
|
||||
expect(encryptService.encryptString).toHaveBeenCalledTimes(2);
|
||||
expect(criticalAppsApiService.saveCriticalApps).toHaveBeenCalledWith(request);
|
||||
});
|
||||
|
||||
@@ -95,7 +95,7 @@ describe("CriticalAppsService", () => {
|
||||
{ id: "id1", organizationId: "org1", uri: "test" },
|
||||
] as PasswordHealthReportApplicationsResponse[];
|
||||
|
||||
encryptService.encrypt.mockResolvedValue(new EncString("encryptedUrlName"));
|
||||
encryptService.encryptString.mockResolvedValue(new EncString("encryptedUrlName"));
|
||||
criticalAppsApiService.saveCriticalApps.mockReturnValue(of(response));
|
||||
|
||||
// act
|
||||
@@ -103,7 +103,7 @@ describe("CriticalAppsService", () => {
|
||||
|
||||
// expectations
|
||||
expect(keyService.getOrgKey).toHaveBeenCalledWith("org1");
|
||||
expect(encryptService.encrypt).toHaveBeenCalledTimes(1);
|
||||
expect(encryptService.encryptString).toHaveBeenCalledTimes(1);
|
||||
expect(criticalAppsApiService.saveCriticalApps).toHaveBeenCalledWith(request);
|
||||
});
|
||||
|
||||
@@ -114,7 +114,7 @@ describe("CriticalAppsService", () => {
|
||||
{ id: "id2", organizationId: "org1", uri: "https://example.org" },
|
||||
] as PasswordHealthReportApplicationsResponse[];
|
||||
|
||||
encryptService.decryptToUtf8.mockResolvedValue("https://example.com");
|
||||
encryptService.decryptString.mockResolvedValue("https://example.com");
|
||||
criticalAppsApiService.getCriticalApps.mockReturnValue(of(response));
|
||||
|
||||
const mockRandomBytes = new Uint8Array(64) as CsprngArray;
|
||||
@@ -125,7 +125,7 @@ describe("CriticalAppsService", () => {
|
||||
flush();
|
||||
|
||||
expect(keyService.getOrgKey).toHaveBeenCalledWith(orgId.toString());
|
||||
expect(encryptService.decryptToUtf8).toHaveBeenCalledTimes(2);
|
||||
expect(encryptService.decryptString).toHaveBeenCalledTimes(2);
|
||||
expect(criticalAppsApiService.getCriticalApps).toHaveBeenCalledWith(orgId);
|
||||
}));
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ export class CriticalAppsService {
|
||||
// add the new entries to the criticalAppsList
|
||||
const updatedList = [...this.criticalAppsList.value];
|
||||
for (const responseItem of dbResponse) {
|
||||
const decryptedUrl = await this.encryptService.decryptToUtf8(
|
||||
const decryptedUrl = await this.encryptService.decryptString(
|
||||
new EncString(responseItem.uri),
|
||||
key,
|
||||
);
|
||||
@@ -138,7 +138,7 @@ export class CriticalAppsService {
|
||||
|
||||
const results = response.map(async (r: PasswordHealthReportApplicationsResponse) => {
|
||||
const encrypted = new EncString(r.uri);
|
||||
const uri = await this.encryptService.decryptToUtf8(encrypted, key);
|
||||
const uri = await this.encryptService.decryptString(encrypted, key);
|
||||
return { id: r.id, organizationId: r.organizationId, uri: uri };
|
||||
});
|
||||
return forkJoin(results);
|
||||
@@ -164,7 +164,7 @@ export class CriticalAppsService {
|
||||
newEntries: string[],
|
||||
): Promise<PasswordHealthReportApplicationsRequest[]> {
|
||||
const criticalAppsPromises = newEntries.map(async (url) => {
|
||||
const encryptedUrlName = await this.encryptService.encrypt(url, key);
|
||||
const encryptedUrlName = await this.encryptService.encryptString(url, key);
|
||||
return {
|
||||
organizationId: orgId,
|
||||
url: encryptedUrlName?.encryptedString?.toString() ?? "",
|
||||
|
||||
Reference in New Issue
Block a user