How to use SecretStorage - 10 common examples

To help you get started, we’ve selected a few SecretStorage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mitya57 / secretstorage / tests / test_context_manager.py View on Github external
def test_closing_context_manager(self) -> None:
		with closing(dbus_init()) as connection:
			collection = get_any_collection(connection)
			self.assertIsNotNone(collection)
			label = collection.get_label()
			self.assertIsNotNone(label)
github mitya57 / secretstorage / tests / test_collection.py View on Github external
def setUp(self) -> None:
		self.connection = dbus_init()
github mitya57 / secretstorage / tests / cleanup_test_items.py View on Github external
#!/usr/bin/env python3

from contextlib import closing
import secretstorage

with closing(secretstorage.dbus_init()) as connection:
	items = secretstorage.search_items(connection, {'application': 'secretstorage-test'})

	for item in items:
		print('Deleting item with label %r.' % item.get_label())
		item.delete()
github mitya57 / secretstorage / tests / test_exceptions.py View on Github external
def setUp(self) -> None:
		self.connection = secretstorage.dbus_init()
		self.collection = secretstorage.get_any_collection(self.connection)
github mitya57 / secretstorage / tests / test_context_manager.py View on Github external
def test_closing_context_manager(self) -> None:
		with closing(dbus_init()) as connection:
			collection = get_any_collection(connection)
			self.assertIsNotNone(collection)
			label = collection.get_label()
			self.assertIsNotNone(label)
github mitya57 / secretstorage / tests / test_collection.py View on Github external
def setUp(self) -> None:
		self.connection = dbus_init()
		self.collection = get_any_collection(self.connection)
github mitya57 / secretstorage / tests / test_item.py View on Github external
def setUp(self) -> None:
		self.connection = dbus_init()
		self.collection = get_any_collection(self.connection)
		self.created_timestamp = time.time()
		self.item = self.collection.create_item('My item', ATTRIBUTES,
			b'pa$$word')
		self.other_item = self.collection.create_item('My item',
			ATTRIBUTES, b'', content_type='data/null')
github mitya57 / secretstorage / tests / test_unlocking.py View on Github external
def setUp(self) -> None:
		self.connection = dbus_init()
		collection_path = "/org/freedesktop/secrets/collection/english"
		self.collection = Collection(self.connection, collection_path)
github mitya57 / secretstorage / tests / test_unlocking.py View on Github external
def test_lock_unlock(self) -> None:
		self.assertFalse(self.collection.is_locked())
		self.collection.lock()
		self.assertTrue(self.collection.is_locked())
		self.assertRaises(LockedException, self.collection.ensure_not_locked)
		item, = self.collection.search_items({"number": "1"})
		self.assertRaises(LockedException, item.ensure_not_locked)
		self.assertIs(self.collection.unlock(), False)
		self.assertFalse(self.collection.is_locked())
		self.collection.ensure_not_locked()
github mitya57 / secretstorage / tests / test_unlocking.py View on Github external
def test_lock_unlock(self) -> None:
		self.assertFalse(self.collection.is_locked())
		self.collection.lock()
		self.assertTrue(self.collection.is_locked())
		self.assertRaises(LockedException, self.collection.ensure_not_locked)
		item, = self.collection.search_items({"number": "1"})
		self.assertRaises(LockedException, item.ensure_not_locked)
		self.assertIs(self.collection.unlock(), False)
		self.assertFalse(self.collection.is_locked())
		self.collection.ensure_not_locked()