Fix collection creation bugs in mock service
authorStef Walter <stefw@gnome.org>
Wed, 14 Nov 2012 09:35:13 +0000 (10:35 +0100)
committerStef Walter <stefw@gnome.org>
Wed, 14 Nov 2012 10:11:23 +0000 (11:11 +0100)
 * Guarantee that collections have unique paths
 * Set the alias of new collections correctly

https://bugzilla.gnome.org/show_bug.cgi?id=688165

libsecret/tests/mock/service.py

index d5a4976..2d6b580 100644 (file)
@@ -315,7 +315,7 @@ class SecretCollection(dbus.service.Object):
        def __init__(self, service, identifier=None, label="Collection", locked=False,
                     confirm=False, master=None):
                if identifier is None:
-                       identifier = label
+                       identifier = next_identifier(label)
                identifier = encode_identifier(identifier)
                self.service = service
                self.identifier = identifier
@@ -627,6 +627,8 @@ class SecretService(dbus.service.Object):
                service = self
                def prompt_callback():
                        collection = SecretCollection(service, None, label, locked=False, confirm=True)
+                       if alias:
+                               collection.add_alias(alias)
                        return dbus.ObjectPath(collection.path, variant_level=1)
                prompt = SecretPrompt(self, sender, dismiss=False, action=prompt_callback)
                return (dbus.ObjectPath("/"), dbus.ObjectPath(prompt.path))