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": "1", "string": "one", "even": "false" };
26 var password = Secret.password_lookup_sync (STORE_SCHEMA, attributes, null);
27 assertEquals("111", password);
29 var deleted = Secret.password_remove_sync (STORE_SCHEMA, attributes, null);
30 assertEquals(true, deleted);
32 var password = Secret.password_lookup_sync (STORE_SCHEMA, attributes, null);
33 assertEquals(null, password);
35 var deleted = Secret.password_remove_sync (STORE_SCHEMA, attributes, null);
36 assertEquals(false, deleted);
40 var attributes = { "number": "2", "string": "two", "even": "true" };
42 var password = Secret.password_lookup_sync (STORE_SCHEMA, attributes, null);
43 assertEquals("222", password);
45 var loop = new GLib.MainLoop.new(null, false);
47 Secret.password_remove (STORE_SCHEMA, attributes,
48 null, function(source, result) {
50 var deleted = Secret.password_remove_finish(result);
51 assertEquals(true, deleted);
56 var password = Secret.password_lookup_sync (STORE_SCHEMA, attributes, null);
57 assertEquals(null, password);
59 Secret.password_remove (STORE_SCHEMA, attributes,
60 null, function(source, result) {
62 var deleted = Secret.password_remove_finish(result);
63 assertEquals(false, deleted);