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 password = Secret.password_lookup_sync (STORE_SCHEMA, { "number": "1", "even": "false" }, null);
35 assertEquals("111", password);
37 var password = Secret.password_lookup_sync (STORE_SCHEMA, { "number": "5", "even": "true" }, null);
38 assertEquals(null, password);
42 var loop = new GLib.MainLoop(null, false);
44 Secret.password_lookup (STORE_SCHEMA, { "number": "2", "string": "two" },
45 null, function(source, result) {
47 var password = Secret.password_lookup_finish(result);
48 assertEquals("222", password);
53 Secret.password_lookup (STORE_SCHEMA, { "number": "7", "string": "five" },
54 null, function(source, result) {
56 var password = Secret.password_lookup_finish(result);
57 assertEquals(null, password);
62 Secret.Service.disconnect();