diff options
Diffstat (limited to 'tests/glibext/secstorage.py')
-rw-r--r-- | tests/glibext/secstorage.py | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/tests/glibext/secstorage.py b/tests/glibext/secstorage.py index 248b3e3..5b8f680 100644 --- a/tests/glibext/secstorage.py +++ b/tests/glibext/secstorage.py @@ -22,8 +22,6 @@ class TestSecretStorage(ChrysalideTestCase): subprocess.run([ 'glib-compile-schemas', path ]) - os.environ['GSETTINGS_SCHEMA_DIR'] = path + ':' + os.environ['GSETTINGS_SCHEMA_DIR'] - @classmethod def tearDownClass(cls): @@ -32,8 +30,6 @@ class TestSecretStorage(ChrysalideTestCase): cls.log('Removing compiled GSettings schema...') - os.environ['GSETTINGS_SCHEMA_DIR'] = ':'.join(os.environ['GSETTINGS_SCHEMA_DIR'].split(':')[1:]) - path = os.path.dirname(os.path.realpath(__file__)) filename = os.path.join(path, 'gschemas.compiled') @@ -42,10 +38,24 @@ class TestSecretStorage(ChrysalideTestCase): os.remove(filename) + def _get_settings(self, sid): + """Provide local GSettings instance.""" + + path = os.path.dirname(os.path.realpath(__file__)) + + source = Gio.SettingsSchemaSource.new_from_directory(path, None, True) + + schema = Gio.SettingsSchemaSource.lookup(source, sid, False) + + settings = Gio.Settings.new_full(schema, None, None) + + return settings + + def testMasterKeyDefinition(self): """Check for cryptographic parameters for secret storage.""" - settings = Gio.Settings.new('re.chrysalide.tests.secstorage') + settings = self._get_settings('re.chrysalide.tests.secstorage') storage = SecretStorage(settings) @@ -67,7 +77,7 @@ class TestSecretStorage(ChrysalideTestCase): def testMasterKeyCreation(self): """Create and update cryptographic parameters for secret storage.""" - settings = Gio.Settings.new('re.chrysalide.tests.secstorage') + settings = self._get_settings('re.chrysalide.tests.secstorage') storage = SecretStorage(settings) @@ -101,9 +111,9 @@ class TestSecretStorage(ChrysalideTestCase): def testDataEncryption(self): - """Create and update cryptographic parameters for secret storage.""" + """Encrypt and decrypt data with the secret storage.""" - settings = Gio.Settings.new('re.chrysalide.tests.secstorage') + settings = self._get_settings('re.chrysalide.tests.secstorage') storage = SecretStorage(settings) |