mirror of
https://github.com/bitwarden/browser
synced 2026-01-20 01:13:48 +00:00
* Created mappings for client domain object to SDK * Add abstract decrypt observable * Added todo for future consideration * Added implementation to cipher service * Added adapter and unit tests * Created cipher encryption abstraction and service * Register cipher encryption service * Added tests for the cipher encryption service * changed signature * Updated feature flag name * added new function to be used for decrypting ciphers * Added new encryptedKey field * added new function to be used for decrypting ciphers * Manually set fields * Added encrypted key in attachment view * Fixed test * Updated references to use decrypt with feature flag * Added dependency * updated package.json * lint fix * fixed tests * Fixed small mapping issues * Fixed test * Added function to decrypt fido2 key value * Added function to decrypt fido2 key value and updated test * updated to use sdk function without prociding the key * updated localdata sdk type change * decrypt attachment content using sdk * Fixed dependency issues * updated package.json * Refactored service to handle getting decrypted buffer using the legacy and sdk implementations * updated services and component to use refactored version * Updated decryptCiphersWithSdk to use decryptManyLegacy for batch decryption, ensuring the SDK is only called once per batch * Fixed merge conflicts * Fixed merge conflicts * Fixed merge conflicts * Fixed lint issues * Moved getDecryptedAttachmentBuffer to cipher service * Moved getDecryptedAttachmentBuffer to cipher service * ensure CipherView properties are null instead of undefined * Fixed test * ensure AttachmentView properties are null instead of undefined * Linked ticket in comment * removed unused orgKey
67 lines
1.4 KiB
TypeScript
67 lines
1.4 KiB
TypeScript
import { SecureNoteType } from "../../enums";
|
|
import { SecureNoteData } from "../data/secure-note.data";
|
|
|
|
import { SecureNote } from "./secure-note";
|
|
|
|
describe("SecureNote", () => {
|
|
let data: SecureNoteData;
|
|
|
|
beforeEach(() => {
|
|
data = {
|
|
type: SecureNoteType.Generic,
|
|
};
|
|
});
|
|
|
|
it("Convert from empty", () => {
|
|
const data = new SecureNoteData();
|
|
const secureNote = new SecureNote(data);
|
|
|
|
expect(secureNote).toEqual({
|
|
type: undefined,
|
|
});
|
|
});
|
|
|
|
it("Convert", () => {
|
|
const secureNote = new SecureNote(data);
|
|
|
|
expect(secureNote).toEqual({
|
|
type: 0,
|
|
});
|
|
});
|
|
|
|
it("toSecureNoteData", () => {
|
|
const secureNote = new SecureNote(data);
|
|
expect(secureNote.toSecureNoteData()).toEqual(data);
|
|
});
|
|
|
|
it("Decrypt", async () => {
|
|
const secureNote = new SecureNote();
|
|
secureNote.type = SecureNoteType.Generic;
|
|
|
|
const view = await secureNote.decrypt(null);
|
|
|
|
expect(view).toEqual({
|
|
type: 0,
|
|
});
|
|
});
|
|
|
|
describe("fromJSON", () => {
|
|
it("returns null if object is null", () => {
|
|
expect(SecureNote.fromJSON(null)).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe("toSdkSecureNote", () => {
|
|
it("returns the correct SDK SecureNote object", () => {
|
|
const secureNote = new SecureNote();
|
|
secureNote.type = SecureNoteType.Generic;
|
|
|
|
const sdkSecureNote = secureNote.toSdkSecureNote();
|
|
|
|
expect(sdkSecureNote).toEqual({
|
|
type: 0,
|
|
});
|
|
});
|
|
});
|
|
});
|