2 * Copyright 2012 Red Hat Inc.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation; either version 2.1 of the licence or (at
7 * your option) any later version.
9 * See the included COPYING file for more information.
12 const Mock = imports.gi.MockService;
13 const Secret = imports.gi.Secret;
14 const GLib = imports.gi.GLib;
16 const JsUnit = imports.jsUnit;
17 const assertEquals = JsUnit.assertEquals;
18 const assertRaises = JsUnit.assertRaises;
19 const assertTrue = JsUnit.assertTrue;
21 Mock.start("mock-service-normal.py");
23 const STORE_SCHEMA = new Secret.Schema("org.mock.Schema",
24 Secret.SchemaFlags.NONE,
26 "number": Secret.SchemaAttributeType.INTEGER,
27 "string": Secret.SchemaAttributeType.STRING,
28 "even": Secret.SchemaAttributeType.BOOLEAN,
34 var attributes = { "number": "1", "string": "one", "even": "false" };
36 var password = Secret.password_lookup_sync (STORE_SCHEMA, attributes, null);
37 assertEquals("111", password);
39 var deleted = Secret.password_clear_sync (STORE_SCHEMA, attributes, null);
40 assertEquals(true, deleted);
42 var password = Secret.password_lookup_sync (STORE_SCHEMA, attributes, null);
43 assertEquals(null, password);
45 var deleted = Secret.password_clear_sync (STORE_SCHEMA, attributes, null);
46 assertEquals(false, deleted);
51 var attributes = { "number": "2", "string": "two", "even": "true" };
53 var password = Secret.password_lookup_sync (STORE_SCHEMA, attributes, null);
54 assertEquals("222", password);
56 var loop = new GLib.MainLoop(null, false);
58 Secret.password_clear (STORE_SCHEMA, attributes,
59 null, function(source, result) {
61 var deleted = Secret.password_clear_finish(result);
62 assertEquals(true, deleted);
67 var password = Secret.password_lookup_sync (STORE_SCHEMA, attributes, null);
68 assertEquals(null, password);
70 Secret.password_clear (STORE_SCHEMA, attributes,
71 null, function(source, result) {
73 var deleted = Secret.password_clear_finish(result);
74 assertEquals(false, deleted);
79 var password = Secret.password_lookup_sync (STORE_SCHEMA, attributes, null);
80 assertEquals(null, password);
82 Secret.Service.disconnect();