2 const Mock = imports.gi.MockService;
3 const Secret = imports.gi.Secret;
4 const GLib = imports.gi.GLib;
6 const JsUnit = imports.jsUnit;
7 const assertEquals = JsUnit.assertEquals;
8 const assertRaises = JsUnit.assertRaises;
9 const assertTrue = JsUnit.assertTrue;
11 Mock.start("mock-service-normal.py");
13 const STORE_SCHEMA = new Secret.Schema.new("org.mock.Schema",
14 Secret.SchemaFlags.NONE,
16 "number": Secret.SchemaAttributeType.INTEGER,
17 "string": Secret.SchemaAttributeType.STRING,
18 "even": Secret.SchemaAttributeType.BOOLEAN,
24 var attributes = { "number": "9", "string": "nine", "even": "false" };
26 var password = Secret.password_lookup_sync (STORE_SCHEMA, attributes, null);
27 assertEquals(null, password);
29 var stored = Secret.password_store_sync (STORE_SCHEMA, attributes, Secret.COLLECTION_DEFAULT,
30 "The number nine", "999", null);
31 assertEquals(true, stored);
33 var password = Secret.password_lookup_sync (STORE_SCHEMA, attributes, null);
34 assertEquals("999", password);
39 var attributes = { "number": "888", "string": "eight", "even": "true" };
41 var password = Secret.password_lookup_sync (STORE_SCHEMA, attributes, null);
42 assertEquals(null, password);
44 var loop = new GLib.MainLoop.new(null, false);
46 Secret.password_store (STORE_SCHEMA, attributes, null, "The number eight", "888",
47 null, function(source, result) {
49 var stored = Secret.password_store_finish(result);
50 assertEquals(true, stored);
55 var password = Secret.password_lookup_sync (STORE_SCHEMA, attributes, null);
56 assertEquals("888", password);