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": "9", "string": "nine", "even": "false" };
36 var password = Secret.password_lookup_sync (STORE_SCHEMA, attributes, null);
37 assertEquals(null, password);
39 var stored = Secret.password_store_sync (STORE_SCHEMA, attributes, Secret.COLLECTION_DEFAULT,
40 "The number nine", "999", null);
41 assertEquals(true, stored);
43 var password = Secret.password_lookup_sync (STORE_SCHEMA, attributes, null);
44 assertEquals("999", password);
49 var attributes = { "number": "888", "string": "eight", "even": "true" };
51 var password = Secret.password_lookup_sync (STORE_SCHEMA, attributes, null);
52 assertEquals(null, password);
54 var loop = new GLib.MainLoop(null, false);
56 Secret.password_store (STORE_SCHEMA, attributes, null, "The number eight", "888",
57 null, function(source, result) {
59 var stored = Secret.password_store_finish(result);
60 assertEquals(true, stored);
65 var password = Secret.password_lookup_sync (STORE_SCHEMA, attributes, null);
66 assertEquals("888", password);
68 Secret.Service.disconnect();