GithubHelp home page GithubHelp logo

keyrings.alt's Introduction

tests Ruff https://img.shields.io/badge/skeleton-2024-informational https://tidelift.com/badges/package/pypi/keyrings.alt

Alternate keyring backend implementations for use with the keyring package.

Keyrings in this package may have security risks or other implications. These backends were extracted from the main keyring project to make them available for those who wish to employ them, but are discouraged for general production use. Include this module and use its backends at your own risk.

For example, the PlaintextKeyring stores passwords in plain text on the file system, defeating the intended purpose of this library to encourage best practices for security.

For Enterprise

Available as part of the Tidelift Subscription.

This project and the maintainers of thousands of other packages are working with Tidelift to deliver one enterprise subscription that covers all of the open source you use.

Learn more.

keyrings.alt's People

Contributors

abravalheri avatar avasam avatar bhrutledge avatar bswck avatar cclauss avatar darkvertex avatar dependabot[bot] avatar dimitripapadopoulos avatar frispete avatar hugovk avatar jaraco avatar johnthagen avatar joycebrum avatar kolanich avatar layday avatar micahculpepper avatar mindw avatar mitya57 avatar skriems avatar stratakis avatar tcpan avatar thechymera avatar vfazio avatar webknjaz avatar wimglenn avatar zacharyburnett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

keyrings.alt's Issues

pyfs backend seems to be incompatible with fs-2.4.16, even though requirements declare <3

I have fs-2.4.16 installed, and all pyfs tests are skipped. If I remove the "skipif", I get lots of test failures, such as:

_______________________________ TestUnencryptedMemoryPyfilesystemKeyringNoSubDir.test_password_set_get ________________________________

self = <keyrings.alt.pyfs.PlaintextKeyring object at 0x7f14bb08f350>, mode = 'r'

    def _open(self, mode='r'):
        """Open the password file in the specified mode"""
        open_file = None
        writeable = 'w' in mode or 'a' in mode or '+' in mode
        try:
>           open_file = self._get_opener(mode, writeable)

keyrings/alt/pyfs.py:86: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <keyrings.alt.pyfs.PlaintextKeyring object at 0x7f14bb08f350>, mode = 'r', writeable = False

    def _get_opener(self, mode, writeable):
        # NOTE: currently the MemOpener does not split off any filename
        #       which causes errors on close()
        #       so we add a dummy name and open it separately
        if self.filename.startswith('mem://') or self.filename.startswith('ram://'):
>           open_file = fs.opener.fsopendir(self.filename).open('kr.cfg', mode)
E           AttributeError: module 'fs.opener' has no attribute 'fsopendir'

keyrings/alt/pyfs.py:146: AttributeError

During handling of the above exception, another exception occurred:

self = <tests.test_pyfs.TestUnencryptedMemoryPyfilesystemKeyringNoSubDir object at 0x7f14b9fd0650>

    def test_password_set_get(self):
        password = random_string(20)
        username = random_string(20)
        service = random_string(20)
>       self.check_set_get(service, username, password)

/usr/lib/python3.11/site-packages/keyring/testing/backend.py:72: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.11/site-packages/keyring/testing/backend.py:58: in check_set_get
    assert keyring.get_password(service, username) is None
keyrings/alt/pyfs.py:177: in get_password
    password_base64 = self.config.get(service, username).encode()
keyrings/alt/pyfs.py:166: in config
    raw_config.read_file(self._open() or [])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <keyrings.alt.pyfs.PlaintextKeyring object at 0x7f14bb08f350>, mode = 'r'

    def _open(self, mode='r'):
        """Open the password file in the specified mode"""
        open_file = None
        writeable = 'w' in mode or 'a' in mode or '+' in mode
        try:
            open_file = self._get_opener(mode, writeable)
>       except fs.errors.ResourceNotFoundError:
E       AttributeError: module 'fs.errors' has no attribute 'ResourceNotFoundError'

keyrings/alt/pyfs.py:87: AttributeError

So I guess the requirement fs>=0.5,<3 is incorrect since 2.4.x doesn't work. FWICS the tests are also skipped on CI.

Support pyfs 2

There are some incompatibilities with the Python's filesystem abstraction layer (fs).

  • ResourceNotFoundError has been replaced by ResourceNotFound, see #19
  • fs.opener.fsopendir does no longer exist (e.g. fs.opener.fsopendir(self.filename).open('kr.cfg', mode))
  • fs.opener.opener does not exist (e.g. s.opener.opener.parse(self.filename, writeable=writeable)

Warning when PlaintextKeyring backend is used

Users may install this library expecting security by default, but then actually having their secrets stored in plaintext.

I think it would be good to at least have some sort of warning (e.g. via logging) if PlaintextKeyring is used.

File backend uses pycrypto but it's not listed in install requires

In file.py:

from Crypto.Protocol.KDF import PBKDF2

In setup.py:

install_requires=[
    'six',
],

secretstorage, used by keyring, has moved from pycrypto to cryptography.

Better to move to cryptography from pycrypto to standardize on a single dependency. If that's hard to do in the short term, maybe add pycrypto as a requirement in setup.py.

Disclaimer: newbie to this project so I'm not aware of the background reasons for current situation.

ImportError traceback on non-Windows

Is there any way to suppress this ImportError traceback printout? It does not impact the actual import, but it pollutes logs. This is on Debian 8.4 (jessie), Py 3.4.2.

>>> from keyrings.alt.file import EncryptedKeyring
Error initializing plugin Windows (alt) = keyrings.alt.Windows.
Traceback (most recent call last):
File "/home/toyg/sites/skypebot_v2/env/lib/python3.4/site-packages/keyring/backend.py", line 155, in _load_plugins
  init_func = ep.load()
File "/home/toyg/sites/skypebot_v2/env/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2291, in load
  return self.resolve()
File "/home/toyg/sites/skypebot_v2/env/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2297, in resolve
  module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/home/toyg/sites/skypebot_v2/env/lib/python3.4/site-packages/keyrings/alt/Windows.py", line 9, in <module>
  from . import file
ImportError: cannot import name 'file'

Add type annotations

Running mypy on code that uses the latest version of keyrings.alt fails with the error message "module is installed, but missing library stubs or py.typed marker". Please add type annotations to this project and include a py.typed file in the package to indicate typing support to mypy.

Windows tests failing

I've enabled keyrings.alt in Appveyor (see badge in readme), but many of the Windows tests are failing.

Let's either get these tests to pass, or if these failing tests indicate that the Windows backends have been broken for a long time, let's just remove that functionality (as apparently nobody is using it).

PlaintextKeyring leaves file in unreadable state

Hello,

I ran into an issue where the plain text backend can write to a file in such a way that it becomes unreadable by keyring afterwards. I made a virtual environment and wrote a little script to demonstrate.

Test Script

from __future__ import print_function
import sys, platform, os
import pip
import keyring
from keyrings.alt.file import PlaintextKeyring

print("# Information about my System:")
print(sys.version)
print(platform.uname())
print()
print("# Installed Packages:")
for pkg in pip.get_installed_distributions():
    print(pkg)
print()

# Use the plaintext Keyring
k = PlaintextKeyring()
keyring.set_keyring(k)

# Set a password. This works.
print("Setting test password.")
keyring.set_password("test", "username", "password")
print("Password set.")
print("Getting test password.")
p = keyring.get_password("test", "username")
print("Got password: {}".format(p))
print("Current file contents:")
with open (os.path.expanduser("~/.local/share/python_keyring/keyring_pass.cfg")) as f:
    print(f.read())
print()

# Set a password with a username of an empty string.
# This corrupts the file and makes all other passwords unreadable.
print("Setting password with blank username.")
keyring.set_password("invalid", "", "password")
print("Password set.")
print("Getting the 'test' password from earlier")
try:
    keyring.get_password("test", "username")
except Exception as e:
    print("Recovering from exception.")
    print(e)
print("Current file contents:")
with open (os.path.expanduser("~/.local/share/python_keyring/keyring_pass.cfg")) as f:
    print(f.read())

Output

# Information about my System:
2.7.13 (default, Jul 18 2017, 09:17:00)
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)]
('Darwin', 'MQ501VG8WL', '16.7.0', 'Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64', 'x86_64', 'i386')

# Installed Packages:
wheel 0.29.0
six 1.10.0
setuptools 36.3.0
pip 9.0.1
keyrings.alt 2.2
keyring 10.4.0

Setting test password.
Password set.
Getting test password.
Got password: password
Current file contents:
[test]
username =
	cGFzc3dvcmQ=




Setting password with blank username.
Password set.
Getting the 'test' password from earlier
Recovering from exception.
File contains parsing errors: /Users/<username>/.local/share/python_keyring/keyring_pass.cfg
	[line  6]: ' = \n'
	[line  7]: '\tcGFzc3dvcmQ=\n'
Current file contents:
[test]
username =
	cGFzc3dvcmQ=

[invalid]
 =
	cGFzc3dvcmQ=

The Issue

If you set a password with a username of '', you might expect shenanigans. That's not a great username, but hey, maybe someone wants to use that for some odd reason, or maybe some script messed up and failed to get a real username.

The real problem is that setting such a password corrupts the whole password file by making it invalid ini syntax, and thus unparseable by ConfigParser, making future calls to get known good passwords fail.

Proposed Solution

Make set_password raise a ValueError if someone tries to use a username of '' with this backend.

I could put together a PR for this. Does that sound like a good solution?

RegistryKeyring failing intermittently

It seems that the delete sometimes fails even though that same code also succeeds. Maybe there's a race condition in the delete logic... or maybe there's an error on certain values (for system). I can see that the backend is doing simple string interpolation to inject the system name into the registry key. That can't be safe for reserved characters like \.

Improve docstrings to make it clear(er) how to parametrize any given keyring

e.g. looking at

In [5]: f.PlaintextKeyring?
Init signature: f.PlaintextKeyring()
Docstring:      Simple File Keyring with no encryption
File:           /usr/lib/python3/dist-packages/keyrings/alt/file.py
Type:           KeyringBackendMeta
Subclasses:    

it is absolutely not clear how to point it to a specific file "properly". Will go RTFM to see if there is a way besides the ugly way of looking into the code and doing

In [6]: kr = f.PlaintextKeyring(); kr.filename='/tmp/temp-keyring.txt'

In [7]: kr.set_password?
Signature: kr.set_password(service, username, password)
Docstring: Write the password in the file.
File:      /usr/lib/python3/dist-packages/keyrings/alt/file_base.py
Type:      method

In [8]: kr.set_password('theservice', 'user', 'password')


[1]  + 2527953 suspended  ipython3

$> cat /tmp/temp-keyring.txt 
[theservice]
user = 
	cGFzc3dvcmQ=

EncryptedKeyring.keyring_key behaves strange under certain conditions

Hi Jaraco,

I'm facing a strange issue in keyrings.cryptfile that boils down to:

After adapting keyrings.cryptfile to the new keyring test suite by fetching file.py, file_base.py and relevant tests from this project, an incompatibility appeared in behavior: before, it was possible to execute this sequence:

from keyrings.cryptfile.cryptfile import CryptFileKeyring
kr = CryptFileKeyring()
kr.keyring_key = "test"
kr.set_password("foo", "bar", "test_password")

and retrieve it again with:

from keyrings.cryptfile.cryptfile import CryptFileKeyring
kr = CryptFileKeyring()
kr.keyring_key = "test"

print(kr.get_password("foo", "bar"))

Now, the side effect in EncryptedKeyring.keyring_key() of initializing the keyring file isn't performed properly anymore, resulting in a damaged keyring file. It is missing the [keyring_2Dsetting] section. I've attempted to fix the issue here, but now, TestEncryptedFileKeyring::test_wrong_password fails, and I'm not sure, if this is a good enough approach, since this should land in your project one day as well...

What do you think?

Depends on keyring.util.properties, removed in keyring 23.9.0

$ tox
python create: /home/ben/src/forks/keyrings.alt/.tox/python
python develop-inst: /home/ben/src/forks/keyrings.alt
python installed: appdirs==1.4.4,attrs==22.1.0,backports.unittest-mock==1.5,black==22.8.0,cffi==1.15.1,click==8.1.3,coverage==6.4.4,cryptography==37.0.4,docutils==0.19,filelock==3.8.0,flake8==4.0.1,fs==2.4.16,importlib-metadata==4.12.0,iniconfig==1.1.1,jaraco.classes==3.2.2,jaraco.context==4.1.2,jaraco.functools==3.5.1,jeepney==0.8.0,keyring==23.9.0,-e git+https://github.com/jaraco/keyrings.alt.git@010fe59c64ffacbc0f97405d3bf21072d811baf1#egg=keyrings.alt,mccabe==0.6.1,more-itertools==8.14.0,mypy==0.971,mypy-extensions==0.4.3,packaging==21.3,pathspec==0.10.1,pep517==0.13.0,platformdirs==2.5.2,pluggy==1.0.0,py==1.11.0,pycodestyle==2.8.0,pycparser==2.21,pycryptodomex==3.15.0,pyflakes==2.4.0,pyparsing==3.0.9,pytest==7.1.3,pytest-black==0.3.12,pytest-checkdocs==2.7.1,pytest-cov==3.0.0,pytest-enabler==1.3.0,pytest-flake8==1.1.1,pytest-mypy==0.9.1,SecretStorage==3.3.3,six==1.16.0,toml==0.10.2,tomli==2.0.1,typing_extensions==4.3.0,zipp==3.8.1
python run-test-pre: PYTHONHASHSEED='459336002'
python run-test: commands[0] | pytest
============================= test session starts ==============================
platform linux -- Python 3.10.6, pytest-7.1.3, pluggy-1.0.0
cachedir: .tox/python/.pytest_cache
rootdir: /home/ben/src/forks/keyrings.alt, configfile: pytest.ini
plugins: backports.unittest-mock-1.5, enabler-1.3.0, checkdocs-2.7.1, mypy-0.9.1, flake8-1.1.1, cov-3.0.0, black-0.3.12
collected 77 items / 21 errors                                                 

==================================== ERRORS ====================================
____________________ ERROR collecting keyrings/alt/Gnome.py ____________________
keyrings/alt/Gnome.py:11: in <module>
    from keyring.util import properties
E   ImportError: cannot import name 'properties' from 'keyring.util' (/home/ben/src/forks/keyrings.alt/.tox/python/lib/python3.10/site-packages/keyring/util/__init__.py)
___________________ ERROR collecting keyrings/alt/Google.py ____________________
keyrings/alt/Google.py:20: in <module>
    from keyring.util import properties
E   ImportError: cannot import name 'properties' from 'keyring.util' (/home/ben/src/forks/keyrings.alt/.tox/python/lib/python3.10/site-packages/keyring/util/__init__.py)
___________________ ERROR collecting keyrings/alt/Windows.py ___________________
keyrings/alt/Windows.py:5: in <module>
    from keyring.util import properties
E   ImportError: cannot import name 'properties' from 'keyring.util' (/home/ben/src/forks/keyrings.alt/.tox/python/lib/python3.10/site-packages/keyring/util/__init__.py)
____________________ ERROR collecting keyrings/alt/file.py _____________________
keyrings/alt/file.py:9: in <module>
    from keyring.util import properties
E   ImportError: cannot import name 'properties' from 'keyring.util' (/home/ben/src/forks/keyrings.alt/.tox/python/lib/python3.10/site-packages/keyring/util/__init__.py)
__________________ ERROR collecting keyrings/alt/file_base.py __________________
keyrings/alt/file_base.py:10: in <module>
    from keyring.util import platform_, properties
E   ImportError: cannot import name 'properties' from 'keyring.util' (/home/ben/src/forks/keyrings.alt/.tox/python/lib/python3.10/site-packages/keyring/util/__init__.py)
____________________ ERROR collecting keyrings/alt/multi.py ____________________
keyrings/alt/multi.py:3: in <module>
    from keyring.util import properties
E   ImportError: cannot import name 'properties' from 'keyring.util' (/home/ben/src/forks/keyrings.alt/.tox/python/lib/python3.10/site-packages/keyring/util/__init__.py)
____________________ ERROR collecting keyrings/alt/pyfs.py _____________________
keyrings/alt/pyfs.py:7: in <module>
    from keyring.util import platform_, properties
E   ImportError: cannot import name 'properties' from 'keyring.util' (/home/ben/src/forks/keyrings.alt/.tox/python/lib/python3.10/site-packages/keyring/util/__init__.py)
_____________________ ERROR collecting tests/test_Gnome.py _____________________
tests/test_Gnome.py:7: in <module>
    from keyrings.alt import Gnome
keyrings/alt/Gnome.py:11: in <module>
    from keyring.util import properties
E   ImportError: cannot import name 'properties' from 'keyring.util' (/home/ben/src/forks/keyrings.alt/.tox/python/lib/python3.10/site-packages/keyring/util/__init__.py)
_____________________ ERROR collecting tests/test_Gnome.py _____________________
ImportError while importing test module '/home/ben/src/forks/keyrings.alt/tests/test_Gnome.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib64/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_Gnome.py:7: in <module>
    from keyrings.alt import Gnome
keyrings/alt/Gnome.py:11: in <module>
    from keyring.util import properties
E   ImportError: cannot import name 'properties' from 'keyring.util' (/home/ben/src/forks/keyrings.alt/.tox/python/lib/python3.10/site-packages/keyring/util/__init__.py)
____________________ ERROR collecting tests/test_Google.py _____________________
tests/test_Google.py:7: in <module>
    from keyrings.alt import Google
keyrings/alt/Google.py:20: in <module>
    from keyring.util import properties
E   ImportError: cannot import name 'properties' from 'keyring.util' (/home/ben/src/forks/keyrings.alt/.tox/python/lib/python3.10/site-packages/keyring/util/__init__.py)
____________________ ERROR collecting tests/test_Google.py _____________________
ImportError while importing test module '/home/ben/src/forks/keyrings.alt/tests/test_Google.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib64/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_Google.py:7: in <module>
    from keyrings.alt import Google
keyrings/alt/Google.py:20: in <module>
    from keyring.util import properties
E   ImportError: cannot import name 'properties' from 'keyring.util' (/home/ben/src/forks/keyrings.alt/.tox/python/lib/python3.10/site-packages/keyring/util/__init__.py)
____________________ ERROR collecting tests/test_Windows.py ____________________
tests/test_Windows.py:7: in <module>
    from keyrings.alt import Windows
keyrings/alt/Windows.py:5: in <module>
    from keyring.util import properties
E   ImportError: cannot import name 'properties' from 'keyring.util' (/home/ben/src/forks/keyrings.alt/.tox/python/lib/python3.10/site-packages/keyring/util/__init__.py)
____________________ ERROR collecting tests/test_Windows.py ____________________
ImportError while importing test module '/home/ben/src/forks/keyrings.alt/tests/test_Windows.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib64/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_Windows.py:7: in <module>
    from keyrings.alt import Windows
keyrings/alt/Windows.py:5: in <module>
    from keyring.util import properties
E   ImportError: cannot import name 'properties' from 'keyring.util' (/home/ben/src/forks/keyrings.alt/.tox/python/lib/python3.10/site-packages/keyring/util/__init__.py)
____________________ ERROR collecting tests/test_crypto.py _____________________
tests/test_crypto.py:6: in <module>
    from .test_file import FileKeyringTests
.tox/python/lib/python3.10/site-packages/_pytest/assertion/rewrite.py:168: in exec_module
    exec(co, module.__dict__)
tests/test_file.py:14: in <module>
    from keyrings.alt import file
keyrings/alt/file.py:9: in <module>
    from keyring.util import properties
E   ImportError: cannot import name 'properties' from 'keyring.util' (/home/ben/src/forks/keyrings.alt/.tox/python/lib/python3.10/site-packages/keyring/util/__init__.py)
____________________ ERROR collecting tests/test_crypto.py _____________________
ImportError while importing test module '/home/ben/src/forks/keyrings.alt/tests/test_crypto.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib64/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_crypto.py:6: in <module>
    from .test_file import FileKeyringTests
tests/test_file.py:14: in <module>
    from keyrings.alt import file
keyrings/alt/file.py:9: in <module>
    from keyring.util import properties
E   ImportError: cannot import name 'properties' from 'keyring.util' (/home/ben/src/forks/keyrings.alt/.tox/python/lib/python3.10/site-packages/keyring/util/__init__.py)
_____________________ ERROR collecting tests/test_file.py ______________________
tests/test_file.py:14: in <module>
    from keyrings.alt import file
keyrings/alt/file.py:9: in <module>
    from keyring.util import properties
E   ImportError: cannot import name 'properties' from 'keyring.util' (/home/ben/src/forks/keyrings.alt/.tox/python/lib/python3.10/site-packages/keyring/util/__init__.py)
_____________________ ERROR collecting tests/test_file.py ______________________
ImportError while importing test module '/home/ben/src/forks/keyrings.alt/tests/test_file.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib64/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_file.py:14: in <module>
    from keyrings.alt import file
keyrings/alt/file.py:9: in <module>
    from keyring.util import properties
E   ImportError: cannot import name 'properties' from 'keyring.util' (/home/ben/src/forks/keyrings.alt/.tox/python/lib/python3.10/site-packages/keyring/util/__init__.py)
_____________________ ERROR collecting tests/test_multi.py _____________________
tests/test_multi.py:4: in <module>
    from keyrings.alt import multi
keyrings/alt/multi.py:3: in <module>
    from keyring.util import properties
E   ImportError: cannot import name 'properties' from 'keyring.util' (/home/ben/src/forks/keyrings.alt/.tox/python/lib/python3.10/site-packages/keyring/util/__init__.py)
_____________________ ERROR collecting tests/test_multi.py _____________________
ImportError while importing test module '/home/ben/src/forks/keyrings.alt/tests/test_multi.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib64/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_multi.py:4: in <module>
    from keyrings.alt import multi
keyrings/alt/multi.py:3: in <module>
    from keyring.util import properties
E   ImportError: cannot import name 'properties' from 'keyring.util' (/home/ben/src/forks/keyrings.alt/.tox/python/lib/python3.10/site-packages/keyring/util/__init__.py)
_____________________ ERROR collecting tests/test_pyfs.py ______________________
tests/test_pyfs.py:10: in <module>
    from keyrings.alt import pyfs
keyrings/alt/pyfs.py:7: in <module>
    from keyring.util import platform_, properties
E   ImportError: cannot import name 'properties' from 'keyring.util' (/home/ben/src/forks/keyrings.alt/.tox/python/lib/python3.10/site-packages/keyring/util/__init__.py)
_____________________ ERROR collecting tests/test_pyfs.py ______________________
ImportError while importing test module '/home/ben/src/forks/keyrings.alt/tests/test_pyfs.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib64/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_pyfs.py:10: in <module>
    from keyrings.alt import pyfs
keyrings/alt/pyfs.py:7: in <module>
    from keyring.util import platform_, properties
E   ImportError: cannot import name 'properties' from 'keyring.util' (/home/ben/src/forks/keyrings.alt/.tox/python/lib/python3.10/site-packages/keyring/util/__init__.py)

---------- coverage: platform linux, python 3.10.6-final-0 -----------
Name                        Stmts   Miss  Cover   Missing
---------------------------------------------------------
conftest.py                     4      0   100%
docs/conf.py                    7      0   100%
keyrings/__init__.py            1      0   100%
keyrings/alt/Gnome.py          75     68     9%   4-5, 14-110
keyrings/alt/Google.py        213    196     8%   21-341
keyrings/alt/Windows.py        88     84     5%   6-148
keyrings/alt/__init__.py        0      0   100%
keyrings/alt/escape.py         18     10    44%   19-21, 29, 33-34, 41-45
keyrings/alt/file.py          115    108     6%   10-218
keyrings/alt/file_base.py      92     84     9%   11-183
keyrings/alt/keyczar.py        61     29    52%   16-18, 29, 36, 41-52, 56-58, 62-64, 71-72, 76, 80, 91-94, 98
keyrings/alt/multi.py          42     40     5%   4-62
keyrings/alt/pyfs.py          149    143     4%   8-255
tests/__init__.py               0      0   100%
tests/mocks.py                137     79    42%   14, 21-23, 26, 33, 57-63, 66, 69, 84-85, 97-109, 112-114, 117-121, 134-153, 156-161, 164-170, 175-177, 183-185, 195, 201, 207, 210, 215, 220-221, 227, 231, 236, 240, 246, 250
tests/test_Gnome.py            22     16    27%   10-35
tests/test_Google.py          209    203     3%   8-424
tests/test_Windows.py          20     16    20%   8-32
tests/test_crypto.py           21     17    19%   8-29
tests/test_file.py            132    121     8%   15-206
tests/test_keyczar.py          53     41    23%   13-14, 17-21, 25-31, 35-45, 50-55, 58-65, 68-71
tests/test_multi.py            37     34     8%   5-63
tests/test_pyfs.py             57     50    12%   11-111
---------------------------------------------------------
TOTAL                        1553   1339    14%

=========================== short test summary info ============================
ERROR keyrings/alt/Gnome.py - ImportError: cannot import name 'properties' fr...
ERROR keyrings/alt/Google.py - ImportError: cannot import name 'properties' f...
ERROR keyrings/alt/Windows.py - ImportError: cannot import name 'properties' ...
ERROR keyrings/alt/file.py - ImportError: cannot import name 'properties' fro...
ERROR keyrings/alt/file_base.py - ImportError: cannot import name 'properties...
ERROR keyrings/alt/multi.py - ImportError: cannot import name 'properties' fr...
ERROR keyrings/alt/pyfs.py - ImportError: cannot import name 'properties' fro...
ERROR tests/test_Gnome.py - ImportError: cannot import name 'properties' from...
ERROR tests/test_Gnome.py
ERROR tests/test_Google.py - ImportError: cannot import name 'properties' fro...
ERROR tests/test_Google.py
ERROR tests/test_Windows.py - ImportError: cannot import name 'properties' fr...
ERROR tests/test_Windows.py
ERROR tests/test_crypto.py - ImportError: cannot import name 'properties' fro...
ERROR tests/test_crypto.py
ERROR tests/test_file.py - ImportError: cannot import name 'properties' from ...
ERROR tests/test_file.py
ERROR tests/test_multi.py - ImportError: cannot import name 'properties' from...
ERROR tests/test_multi.py
ERROR tests/test_pyfs.py - ImportError: cannot import name 'properties' from ...
ERROR tests/test_pyfs.py
!!!!!!!!!!!!!!!!!!! Interrupted: 21 errors during collection !!!!!!!!!!!!!!!!!!!
============================== 21 errors in 0.35s ==============================
ERROR: InvocationError for command /home/ben/src/forks/keyrings.alt/.tox/python/bin/pytest (exited with code 2)
___________________________________ summary ____________________________________
ERROR:   python: commands failed

Warning about missing __init__

I don't know whether this is a valid bug or not, but I'll report it just in case.

$ python3 -Wall -c "import keyring"
/usr/lib/python3.5/importlib/_bootstrap_external.py:412: ImportWarning: Not importing directory /home/dmitry/.local/lib/python3.5/site-packages/keyrings: missing __init__
  _warnings.warn(msg.format(portions[0]), ImportWarning)

keyrings.alt tests rely on keyring tests

Packages in general should not rely on tests in another package as most people are not really careful when messing around tests.
In this case tests are relying on following two files:

keyring/tests/test_backend.py
keyring/tests/util.py

Distributions usually just remove tests upon installation so they are not even available and this thus fails. Could you please rethink how to do that and rely only on the keyring api without the tests?

Python 3.7: PyGObject is implicit requirement

I'm attempting to use pycrypto as my backend, but every time I call something that uses the keyring package I get this traceback:

Error initializing plugin EntryPoint('Gnome', 'keyrings.alt.Gnome', None, Distribution('keyrings.alt', '3.1-py3.7')).
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/keyring/backend.py", line 154, in _load_plugins
    init_func = ep.load()
  File "/usr/lib/python3.7/site-packages/entrypoints.py", line 77, in load
    mod = import_module(self.module_name)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/lib/python3.7/site-packages/keyrings/alt/Gnome.py", line 3, in <module>
    gi.require_version('GnomeKeyring', '1.0')
AttributeError: module 'gi' has no attribute 'require_version'

The issue is resolved by installing PyGObject.

testing on openSUSE Tumbleweed fails

in a non trivial way, at least for me:

_win_crypto (unittest.loader._FailedTest) ... ERROR
_win_crypto (unittest.loader._FailedTest) ... ERROR
[...]
======================================================================
ERROR: _win_crypto (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: _win_crypto
Traceback (most recent call last):
  File "/usr/lib64/python3.5/unittest/loader.py", line 153, in loadTestsFromName
    module = __import__(module_name)
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 662, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/home/abuild/rpmbuild/BUILD/keyrings.alt-2.0/keyrings/alt/_win_crypto.py", line 4, in <module>
    from ctypes import windll, WinDLL, WINFUNCTYPE
ImportError: cannot import name 'windll'

======================================================================
ERROR: _win_crypto (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: _win_crypto
Traceback (most recent call last):
  File "/usr/lib64/python3.5/unittest/loader.py", line 153, in loadTestsFromName
    module = __import__(module_name)
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 662, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/home/abuild/rpmbuild/BUILD/keyrings.alt-2.0/keyrings/alt/_win_crypto.py", line 4, in <module>
    from ctypes import windll, WinDLL, WINFUNCTYPE
ImportError: cannot import name 'windll'

----------------------------------------------------------------------
Ran 316 tests in 1.397s

FAILED (errors=2, skipped=112)
Test failed: <unittest.runner.TextTestResult run=316 errors=2 failures=0>

Why the hell does unittest attempt to load _win_crypto at all?

I'm building the keyrings.alt package besides a few others in preparation for the official openSUSE eco system here.
As you can see, this happens with Tumbleweed only (the rolling release version of openSUSE), that is based on Python 3.5.1, while the other targets run the tests just fine (all based on Python 3.4.5).

The full build log is available here

@jaraco Sorry for bothering you with such things, but I'm lost with this one...

Missing license

Dear Jaraco,

would you assign a license to your package, please.

Without a license, your package cannot be distributed properly.

Thanks,
Pete

Tests fail with fs 2.0

Yesterday, the pyfs project released 2.0.0 (a bump from 0.5.4 apparently), and with this the tests break. The keyring should pin to < 2 until someone invests the time to update the library.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.