How to use the secretstorage.exceptions.ItemNotFoundException function in SecretStorage

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_exceptions.py View on Github external
def test_non_existing_collection(self) -> None:
		self.assertRaises(ItemNotFoundException,
			secretstorage.get_collection_by_alias,
			self.connection, 'non-existing-alias')
github mitya57 / secretstorage / tests / test_collection.py View on Github external
def test_deleting_item_prompt(self) -> None:
		item_path = "/org/freedesktop/secrets/collection/lockone/confirm"
		try:
			item = Item(self.connection, item_path)
		except ItemNotFoundException:
			self.skipTest("This test should only be run with mock-service-lock.")
		item.delete()
github mitya57 / secretstorage / tests / test_exceptions.py View on Github external
def test_double_deleting(self) -> None:
		item = self.collection.create_item('MyItem',
			{'application': 'secretstorage-test'}, b'pa$$word')
		item.delete()
		self.assertRaises(ItemNotFoundException, item.delete)
github mitya57 / secretstorage / secretstorage / collection.py View on Github external
- The first collection in the collections list."""
	try:
		return Collection(connection)
	except ItemNotFoundException:
		pass
	try:
		# GNOME Keyring provides session collection where items
		# are stored in process memory.
		return Collection(connection, SESSION_COLLECTION)
	except ItemNotFoundException:
		pass
	collections = list(get_all_collections(connection))
	if collections:
		return collections[0]
	else:
		raise ItemNotFoundException('No collections found.')
github mitya57 / secretstorage / secretstorage / util.py View on Github external
def send_and_get_reply(self, msg: Message) -> Any:
		try:
			return self._connection.send_and_get_reply(msg)
		except DBusErrorResponse as resp:
			if resp.name in (DBUS_UNKNOWN_METHOD, DBUS_NO_SUCH_OBJECT):
				raise ItemNotFoundException('Item does not exist!') from resp
			elif resp.name in (DBUS_SERVICE_UNKNOWN, DBUS_EXEC_FAILED,
			                   DBUS_NO_REPLY):
				data = resp.data
				if isinstance(data, tuple):
					data = data[0]
				raise SecretServiceNotAvailableException(data) from resp
			raise
github n1nj4sec / pupy / pupy / packages / linux / all / secretstorage / collection.py View on Github external
- The first collection in the collections list."""
    try:
        return Collection(bus)
    except ItemNotFoundException:
        pass
    try:
        # GNOME Keyring provides session collection where items
        # are stored in process memory.
        return Collection(bus, SESSION_COLLECTION)
    except ItemNotFoundException:
        pass
    collections = list(get_all_collections(bus))
    if collections:
        return collections[0]
    else:
        raise ItemNotFoundException('No collections found.')
github n1nj4sec / pupy / pupy / packages / linux / all / secretstorage / util.py View on Github external
def function_out(*args, **kwargs):
            try:
                return function_in(*args, **kwargs)
            except dbus.exceptions.DBusException as e:
                if e.get_dbus_name() == DBUS_UNKNOWN_METHOD:
                    raise ItemNotFoundException('Item does not exist!')
                if e.get_dbus_name() == DBUS_NO_SUCH_OBJECT:
                    raise ItemNotFoundException(e.get_dbus_message())
                if e.get_dbus_name() in (DBUS_NO_REPLY, DBUS_NOT_SUPPORTED):
                    raise SecretServiceNotAvailableException(
                        e.get_dbus_message())
                raise
        return function_out
github n1nj4sec / pupy / pupy / packages / linux / all / secretstorage / collection.py View on Github external
def get_any_collection(bus):
    """Returns any collection, in the following order of preference:

    - The default collection;
    - The "session" collection (usually temporary);
    - The first collection in the collections list."""
    try:
        return Collection(bus)
    except ItemNotFoundException:
        pass
    try:
        # GNOME Keyring provides session collection where items
        # are stored in process memory.
        return Collection(bus, SESSION_COLLECTION)
    except ItemNotFoundException:
        pass
    collections = list(get_all_collections(bus))
    if collections:
        return collections[0]
    else:
        raise ItemNotFoundException('No collections found.')
github n1nj4sec / pupy / pupy / packages / linux / all / secretstorage / util.py View on Github external
def function_out(*args, **kwargs):
            try:
                return function_in(*args, **kwargs)
            except dbus.exceptions.DBusException as e:
                if e.get_dbus_name() == DBUS_UNKNOWN_METHOD:
                    raise ItemNotFoundException('Item does not exist!')
                if e.get_dbus_name() == DBUS_NO_SUCH_OBJECT:
                    raise ItemNotFoundException(e.get_dbus_message())
                if e.get_dbus_name() in (DBUS_NO_REPLY, DBUS_NOT_SUPPORTED):
                    raise SecretServiceNotAvailableException(
                        e.get_dbus_message())
                raise
        return function_out