4 # Copyright 2012 Red Hat Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Lesser General Public License as published
8 # by the Free Software Foundation; either version 2.1 of the licence or (at
9 # your option) any later version.
11 # See the included COPYING file for more information.
16 from gi.repository import MockService as Mock
17 from gi.repository import SecretUnstable, Secret, GLib
19 EXAMPLE_SCHEMA = Secret.Schema.new('org.mock.type.Store',
20 Secret.SchemaFlags.NONE,
22 'number': Secret.SchemaAttributeType.INTEGER,
23 'string': Secret.SchemaAttributeType.STRING,
24 'even': Secret.SchemaAttributeType.BOOLEAN,
34 class TestStore(unittest.TestCase):
36 Mock.start("mock-service-normal.py")
39 SecretUnstable.Service.disconnect()
42 def testSynchronous(self):
43 service = SecretUnstable.Service.get_sync(SecretUnstable.ServiceFlags.NONE, None);
44 path = service.read_alias_dbus_path_sync("default", None);
46 # Just running this without error is good enough for us to test the unstable gir
47 self.assertNotEqual(path, None);
49 def testValueGet(self):
50 Secret.password_store_sync(EXAMPLE_SCHEMA, attributes, Secret.COLLECTION_DEFAULT,
51 'the label', 'the password', None)
53 service = SecretUnstable.Service.get_sync(SecretUnstable.ServiceFlags.NONE, None)
54 items = service.search_sync(EXAMPLE_SCHEMA, { 'even': 'true' },
55 SecretUnstable.SearchFlags.ALL | SecretUnstable.SearchFlags.LOAD_SECRETS,
59 item_secret = item.get_secret()
60 self.assertEqual(item_secret.get(), "the password")
62 if __name__ == '__main__':