Add web interface and tests
This commit is contained in:
1
test/decrypted.json
Normal file
1
test/decrypted.json
Normal file
File diff suppressed because one or more lines are too long
@ -1,11 +1,9 @@
|
||||
import { resolve } from "path";
|
||||
import { describe, it, beforeEach } from "mocha";
|
||||
import { expect } from "chai";
|
||||
// import { fs, vol } from "memfs"
|
||||
|
||||
import type { Vault } from "../src/index";
|
||||
import { OnePassword } from "../src/index";
|
||||
// import adapter from "../src/adapters/node";
|
||||
import type { Vault } from "../packages/opvault.js/index";
|
||||
import { OnePassword } from "../packages/opvault.js/index";
|
||||
|
||||
describe("OnePassword", () => {
|
||||
const freddy = resolve(__dirname, "../freddy-2013-12-04.opvault");
|
||||
@ -49,9 +47,44 @@ describe("OnePassword", () => {
|
||||
await vault.unlock("freddy");
|
||||
});
|
||||
|
||||
it("reads overviews", () => {
|
||||
const overviews = vault.overviews.values();
|
||||
expect(overviews).to.have.lengthOf(29);
|
||||
it("reads notes", async () => {
|
||||
const item = (await vault.getItem({
|
||||
title: "A note with some attachments",
|
||||
}))!;
|
||||
expect(item).to.exist;
|
||||
expect(item.uuid).to.equal("F2DB5DA3FCA64372A751E0E85C67A538");
|
||||
expect(item.attachments).to.have.lengthOf(2);
|
||||
expect(item.details).to.deep.equal({
|
||||
notesPlain: "This note has two attachments.",
|
||||
});
|
||||
expect(item.overview).to.deep.equal({
|
||||
title: "A note with some attachments",
|
||||
ps: 0,
|
||||
ainfo: "This note has two attachments.",
|
||||
});
|
||||
});
|
||||
|
||||
it("decrypts items", async () => {
|
||||
const decrypted = require("./decrypted.json");
|
||||
expect(vault.isLocked).to.be.false;
|
||||
for (const [uuid, item] of Object.entries<any>(decrypted)) {
|
||||
const actual = await vault.getItem(uuid);
|
||||
expect(actual).to.exist;
|
||||
expect(actual!.overview).to.deep.equal(item.overview);
|
||||
expect(actual!.details).to.deep.equal(item.itemDetails);
|
||||
expect(actual!.attachments).to.have.lengthOf(item.attachments.length);
|
||||
for (const [i, attachment] of actual!.attachments.entries()) {
|
||||
const expected = item.attachments[i];
|
||||
await attachment.unlock();
|
||||
expect(attachment.metadata).to.deep.equal(expected.metadata);
|
||||
expect(attachment.file.toString("base64")).to.deep.equal(
|
||||
expected.file
|
||||
);
|
||||
expect(attachment.icon.toString("base64")).to.deep.equal(
|
||||
expected.icon
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -64,7 +97,8 @@ describe("OnePassword", () => {
|
||||
|
||||
vault.lock();
|
||||
expect(vault.isLocked).to.be.true;
|
||||
expect(() => vault.overviews.values()).to.throw();
|
||||
expect(vault.getItem("F2DB5DA3FCA64372A751E0E85C67A538")).to.eventually
|
||||
.throw;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { describe, it } from "mocha";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { WeakValueMap } from "../src/weakMap";
|
||||
import { WeakValueMap } from "../packages/opvault.js/weakMap";
|
||||
|
||||
declare const gc: () => void;
|
||||
|
||||
|
Reference in New Issue
Block a user