Commits

Jonathan Ballet committed bfdab40

Use an in-memory to launch Gnome keyring tests, to not pollute the user keyring

Previously, tests were creating keys in the default keyring of the user and
weren't cleaned up. Mess ensued.

Now, the in-memory 'session' keyring is automatically cleaned up at logoff,
which is, although not perfect yet (states pre/post test are different), a bit
better.

Comments (0)

Files changed (3)

 * Most of the tests don't require user interaction anymore.
 * Entries stored in Gnome Keyring appears now with a meaningful name if you try
   to browser your keyring (for ex. with Seahorse)
+* Tests from Gnome Keyring no longer pollute the user own keyring.
 
 -----
 0.6.2

keyring/backend.py

 class GnomeKeyring(KeyringBackend):
     """Gnome Keyring"""
 
+    # Name of the keyring to store the passwords in.
+    # Use None for the default keyring.
+    KEYRING_NAME = None
+
     def supported(self):
         try:
             import gnomekeyring
         """
         try:
             gnomekeyring.item_create_sync(
-                None, gnomekeyring.ITEM_NETWORK_PASSWORD,
+                self.KEYRING_NAME, gnomekeyring.ITEM_NETWORK_PASSWORD,
                 "Password for '%s' on '%s'" % (username, service),
                 {'user': username, 'domain': service},
                 password, True)

keyring/tests/test_backend.py

                     DBUS_SESSION_BUS_ADDRESS='1')
 
     def init_keyring(self):
-        return keyring.backend.GnomeKeyring()
+        k = keyring.backend.GnomeKeyring()
+
+        # Store passwords in the session (in-memory) keyring for the tests. This
+        # is going to be automatically cleared when the user logoff.
+        k.KEYRING_NAME = 'session'
+
+        return k
 
     def test_supported(self):
         with ImportBlesser('gnomekeyring'):