mirror of
https://gitlab.gnome.org/GNOME/libsecret.git
synced 2024-12-22 20:58:52 +00:00
8417d8c98b
* Handled entirely on the client side. * Schema names are stored in an xdg:schema attribute * Add option to turn of matching on schema names. So that we can lookup items stored by libgnome-keyring and others * Change schema 'identifier' to 'name' * Fix up tests
53 lines
1.4 KiB
JavaScript
53 lines
1.4 KiB
JavaScript
|
|
const Mock = imports.gi.MockService;
|
|
const Secret = imports.gi.Secret;
|
|
const GLib = imports.gi.GLib;
|
|
|
|
const JsUnit = imports.jsUnit;
|
|
const assertEquals = JsUnit.assertEquals;
|
|
const assertRaises = JsUnit.assertRaises;
|
|
const assertTrue = JsUnit.assertTrue;
|
|
|
|
Mock.start("mock-service-normal.py");
|
|
|
|
const STORE_SCHEMA = new Secret.Schema.new("org.mock.Schema",
|
|
Secret.SchemaFlags.NONE,
|
|
{
|
|
"number": Secret.SchemaAttributeType.INTEGER,
|
|
"string": Secret.SchemaAttributeType.STRING,
|
|
"even": Secret.SchemaAttributeType.BOOLEAN,
|
|
}
|
|
);
|
|
|
|
/* Synchronous */
|
|
|
|
var password = Secret.password_lookup_sync (STORE_SCHEMA, { "number": "1", "even": "false" }, null);
|
|
assertEquals("111", password);
|
|
|
|
var password = Secret.password_lookup_sync (STORE_SCHEMA, { "number": "5", "even": "true" }, null);
|
|
assertEquals(null, password);
|
|
|
|
/* Asynchronous */
|
|
|
|
var loop = new GLib.MainLoop.new(null, false);
|
|
|
|
Secret.password_lookup (STORE_SCHEMA, { "number": "2", "string": "two" },
|
|
null, function(source, result) {
|
|
loop.quit();
|
|
var password = Secret.password_lookup_finish(result);
|
|
assertEquals("222", password);
|
|
});
|
|
|
|
loop.run();
|
|
|
|
Secret.password_lookup (STORE_SCHEMA, { "number": "7", "string": "five" },
|
|
null, function(source, result) {
|
|
loop.quit();
|
|
var password = Secret.password_lookup_finish(result);
|
|
assertEquals(null, password);
|
|
});
|
|
|
|
loop.run();
|
|
|
|
Mock.stop();
|