Al-HUWAITI Shell
Al-huwaiti


Server : nginx/1.18.0
System : Linux localhost 6.14.3-x86_64-linode168 #1 SMP PREEMPT_DYNAMIC Mon Apr 21 19:47:55 EDT 2025 x86_64
User : www-data ( 33)
PHP Version : 8.0.16
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /usr/lib/python3/dist-packages/keyring/tests/backends/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/lib/python3/dist-packages/keyring/tests/backends/test_kwallet.py
import unittest

from keyring.backends import kwallet
from ..test_backend import BackendBasicTests


@unittest.skipUnless(kwallet.DBusKeyring.viable, "KWallet5 unavailable")
class DBusKWalletTestCase(BackendBasicTests, unittest.TestCase):

    # Remove '@' from service name as this is not supported in service names
    # '@' will cause troubles during migration of kwallet entries
    DIFFICULT_CHARS = BackendBasicTests.DIFFICULT_CHARS.replace('@', '')

    def init_keyring(self):
        return kwallet.DBusKeyring()

    def tearDown(self):
        for item in self.credentials_created:
            # Suppress errors, as only one pre/post migration item will be
            # present
            try:
                self.keyring.delete_password(*item)
            except BaseException:
                pass

        # TODO Remove empty folders created during tests

    def set_password(self, service, username, password, old_format=False):
        # set the password and save the result so the test runner can clean
        #  up after if necessary.
        self.credentials_created.add((service, username))

        if old_format:
            username = username + '@' + service
            service = 'Python'

        super(
            DBusKWalletTestCase,
            self).set_password(
            service,
            username,
            password)

    def check_set_get(self, service, username, password):
        keyring = self.keyring

        # for the non-existent password
        self.assertEqual(keyring.get_password(service, username), None)

        # common usage
        self.set_password(service, username, password, True)
        # re-init keyring to force migration
        self.keyring = keyring = self.init_keyring()
        ret_password = keyring.get_password(service, username)
        self.assertEqual(
            ret_password, password,
            "Incorrect password for username: '%s' "
            "on service: '%s'. '%s' != '%s'"
            % (service, username, ret_password, password))

        # for the empty password
        self.set_password(service, username, "", True)
        # re-init keyring to force migration
        self.keyring = keyring = self.init_keyring()
        ret_password = keyring.get_password(service, username)
        self.assertEqual(
            ret_password, "",
            "Incorrect password for username: '%s' "
            "on service: '%s'. '%s' != '%s'"
            % (service, username, ret_password, ""))
        ret_password = keyring.get_password('Python', username + '@' + service)
        self.assertEqual(
            ret_password, None,
            "Not 'None' password returned for username: '%s' "
            "on service: '%s'. '%s' != '%s'. Passwords from old "
            "folder should be deleted during migration."
            % (service, username, ret_password, None))


@unittest.skipUnless(kwallet.DBusKeyringKWallet4.viable,
                     "KWallet4 unavailable")
class DBusKWallet4TestCase(DBusKWalletTestCase):
    def init_keyring(self):
        return kwallet.DBusKeyringKWallet4()

Al-HUWAITI Shell