1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-09 13:10:17 +00:00

Fix remaining changes

This commit is contained in:
Bernd Schoolmann
2025-04-24 22:03:14 +02:00
parent 9f88d68231
commit 58f4fdd153
7 changed files with 19 additions and 13 deletions

View File

@@ -127,7 +127,7 @@ describe("LocalBackedSessionStorage", () => {
describe("save", () => {
const encString = makeEncString("encrypted");
beforeEach(() => {
encryptService.encrypt.mockResolvedValue(encString);
encryptService.encryptString.mockResolvedValue(encString);
});
it("logs a warning when saving the same value twice and in a dev environment", async () => {
@@ -157,7 +157,10 @@ describe("LocalBackedSessionStorage", () => {
it("encrypts and saves the value to local storage", async () => {
await sut.save("test", "value");
expect(encryptService.encrypt).toHaveBeenCalledWith(JSON.stringify("value"), sessionKey);
expect(encryptService.encryptString).toHaveBeenCalledWith(
JSON.stringify("value"),
sessionKey,
);
expect(localStorage.internalStore["session_test"]).toEqual(encString.encryptedString);
});

View File

@@ -95,7 +95,7 @@ describe("AcceptOrganizationInviteService", () => {
encryptService.wrapDecapsulationKey.mockResolvedValue({
encryptedString: "string",
} as EncString);
encryptService.encrypt.mockResolvedValue({ encryptedString: "string" } as EncString);
encryptService.encryptString.mockResolvedValue({ encryptedString: "string" } as EncString);
const invite = createOrgInvite({ initOrganization: true });
const result = await sut.validateAndAcceptInvite(invite);

View File

@@ -93,7 +93,7 @@ export class ProjectService {
): Promise<ProjectRequest> {
const orgKey = await this.getOrganizationKey(organizationId);
const request = new ProjectRequest();
request.name = await this.encryptService.encryptStringprojectView.name, orgKey);
request.name = await this.encryptService.encryptString(projectView.name, orgKey);
return request;
}

View File

@@ -166,9 +166,9 @@ export class SecretService {
const orgKey = await this.getOrganizationKey(organizationId);
const request = new SecretRequest();
const [key, value, note] = await Promise.all([
this.encryptService.encrypt(secretView.name, orgKey),
this.encryptService.encrypt(secretView.value, orgKey),
this.encryptService.encrypt(secretView.note, orgKey),
this.encryptService.encryptString(secretView.name, orgKey),
this.encryptService.encryptString(secretView.value, orgKey),
this.encryptService.encryptString(secretView.note, orgKey),
]);
request.key = key.encryptedString;
request.value = value.encryptedString;

View File

@@ -130,7 +130,10 @@ export class ServiceAccountService {
serviceAccountView: ServiceAccountView,
) {
const request = new ServiceAccountRequest();
request.name = await this.encryptService.encryptStringserviceAccountView.name, organizationKey);
request.name = await this.encryptService.encryptString(
serviceAccountView.name,
organizationKey,
);
return request;
}

View File

@@ -106,12 +106,10 @@ describe("DefaultvNextCollectionService", () => {
expect(encryptService.decryptString).toHaveBeenCalledWith(
expect.objectContaining(new EncString(collection1.name)),
orgKey1,
expect.any(String),
);
expect(encryptService.decryptString).toHaveBeenCalledWith(
expect.objectContaining(new EncString(collection2.name)),
orgKey2,
expect.any(String),
);
});

View File

@@ -58,7 +58,9 @@ function setupUserKeyValidation(
cipher.notes = mockEnc("EncryptedString");
cipher.key = mockEnc("EncKey");
cipherService.getAll.mockResolvedValue([cipher]);
encryptService.decryptFileData.mockResolvedValue(makeStaticByteArray(64));
encryptService.unwrapSymmetricKey.mockResolvedValue(
new SymmetricCryptoKey(makeStaticByteArray(64)),
);
(window as any).bitwardenContainerService = new ContainerService(keyService, encryptService);
}
@@ -279,7 +281,7 @@ describe("regenerateIfNeeded", () => {
};
setupVerificationResponse(mockVerificationResponse, sdkService);
setupUserKeyValidation(cipherService, keyService, encryptService);
encryptService.decryptFileData.mockRejectedValue(new Error("error"));
encryptService.unwrapSymmetricKey.mockRejectedValue(new Error("error"));
await sut.regenerateIfNeeded(userId);
@@ -328,7 +330,7 @@ describe("regenerateIfNeeded", () => {
};
setupVerificationResponse(mockVerificationResponse, sdkService);
setupUserKeyValidation(cipherService, keyService, encryptService);
encryptService.decryptFileData.mockRejectedValue(new Error("error"));
encryptService.unwrapSymmetricKey.mockRejectedValue(new Error("error"));
await sut.regenerateIfNeeded(userId);