mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-05 23:53:21 +00:00
* Unpackage-ify jslib * Adjust .tsconfig path for root and apply to jslib * Rebuild package-lock.json * Disable husky in CI * Revert an incorrect find/replace * Add jslib/shared/.eslintrc rules to root eslintrc * Revert package.json change to ignore spec files when linting * Ensure custom matcher gets imported in jslib tests * Fix small workflow bugs from merging * Try and get CI builds moving again * Always sign and notorize builds in CI * Revert erroneous verion bump
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import { PasswordHistoryData } from "@/jslib/common/src/models/data/passwordHistoryData";
|
|
import { Password } from "@/jslib/common/src/models/domain/password";
|
|
|
|
import { mockEnc } from "../utils";
|
|
|
|
describe("Password", () => {
|
|
let data: PasswordHistoryData;
|
|
|
|
beforeEach(() => {
|
|
data = {
|
|
password: "encPassword",
|
|
lastUsedDate: "2022-01-31T12:00:00.000Z",
|
|
};
|
|
});
|
|
|
|
it("Convert from empty", () => {
|
|
const data = new PasswordHistoryData();
|
|
const password = new Password(data);
|
|
|
|
expect(password).toMatchObject({
|
|
password: null,
|
|
});
|
|
});
|
|
|
|
it("Convert", () => {
|
|
const password = new Password(data);
|
|
|
|
expect(password).toEqual({
|
|
password: { encryptedString: "encPassword", encryptionType: 0 },
|
|
lastUsedDate: new Date("2022-01-31T12:00:00.000Z"),
|
|
});
|
|
});
|
|
|
|
it("toPasswordHistoryData", () => {
|
|
const password = new Password(data);
|
|
expect(password.toPasswordHistoryData()).toEqual(data);
|
|
});
|
|
|
|
it("Decrypt", async () => {
|
|
const password = new Password();
|
|
password.password = mockEnc("password");
|
|
password.lastUsedDate = new Date("2022-01-31T12:00:00.000Z");
|
|
|
|
const view = await password.decrypt(null);
|
|
|
|
expect(view).toEqual({
|
|
password: "password",
|
|
lastUsedDate: new Date("2022-01-31T12:00:00.000Z"),
|
|
});
|
|
});
|
|
});
|