-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented basic Test Specs and Vault
- Loading branch information
1 parent
9ab5766
commit 5ff6808
Showing
4 changed files
with
118 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"shared_folders": [], | ||
"records": [ | ||
{ | ||
"title": "Username Test", | ||
"$type": "login", | ||
"schema": [ | ||
"$login::1", | ||
"$password::1", | ||
"$url::1", | ||
"$fileRef::1", | ||
"$oneTimeCode::1" | ||
], | ||
"login": "username2", | ||
"password": "password2", | ||
"login_url": "https://example.org/" | ||
}, | ||
{ | ||
"title": "Folder Test", | ||
"$type": "login", | ||
"schema": [ | ||
"$login::1", | ||
"$password::1", | ||
"$url::1", | ||
"$fileRef::1", | ||
"$oneTimeCode::1" | ||
], | ||
"login": "username1", | ||
"password": "password1", | ||
"login_url": "https://example.org/", | ||
"folders": [ | ||
{ | ||
"folder": "Foo \\Bar " | ||
} | ||
] | ||
}, | ||
{ | ||
"title": "Sub Folder Entry Test", | ||
"$type": "login", | ||
"schema": [ | ||
"$login::1", | ||
"$password::1", | ||
"$url::1", | ||
"$fileRef::1", | ||
"$oneTimeCode::1" | ||
], | ||
"login": "username3", | ||
"password": "password3", | ||
"login_url": "https://example.org/", | ||
"folders": [ | ||
{ | ||
"folder": "Foo \\Bar " | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const path = require("path"); | ||
const KeeperSecurityImporter = require("../../../dist/importers/KeeperSecurityImporter.js"); | ||
const { Entry, Group, Vault } = require("buttercup"); | ||
|
||
const EXAMPLE_VAULT = path.resolve(__dirname, "../../resources/keeper.json"); | ||
|
||
describe("KeeperSecurityImporter", function () { | ||
beforeEach(function () { | ||
return KeeperSecurityImporter.loadFromFile(EXAMPLE_VAULT) | ||
.then((importer) => importer.export()) | ||
.then((vault) => { | ||
this.vault = vault; | ||
}); | ||
}); | ||
|
||
it("creates a vault instance", function () { | ||
expect(this.vault).to.be.an.instanceOf(Vault); | ||
}); | ||
|
||
it("contains expected groups", function () { | ||
// I'd prefer to use the function 'getGroups' however, this seems to be missing groups in the _groups structure? | ||
const groups = this.vault._groups.map((g) => g.getTitle()); | ||
expect(groups).to.have.lengthOf(3); | ||
expect(groups).to.contain("Foo"); | ||
expect(groups).to.contain("Bar"); | ||
}); | ||
|
||
it("imports login properties", function () { | ||
const [entry] = this.vault.findEntriesByProperty( | ||
"title", | ||
"Item with login" | ||
); | ||
expect(entry).to.be.an.instanceOf(Entry); | ||
expect(entry.getProperty("username")).to.equal("username1"); | ||
expect(entry.getProperty("password")).to.equal("password1"); | ||
}); | ||
|
||
it("imports URLs", function () { | ||
const [entry] = this.vault.findEntriesByProperty( | ||
"title", | ||
"Item with login uri" | ||
); | ||
expect(entry).to.be.an.instanceOf(Entry); | ||
expect(entry.getProperty("URL")).to.equal("https://example.org/"); | ||
// @todo should be a website | ||
}); | ||
}); |