diff --git a/src/caosdb/connection/authentication/external_credentials_provider.py b/src/caosdb/connection/authentication/external_credentials_provider.py index 8164d49b4d50203c4de4d1ecd946bb309e74dd4d..8795ee28789c775fd3e811f35f36d2f635b43f69 100644 --- a/src/caosdb/connection/authentication/external_credentials_provider.py +++ b/src/caosdb/connection/authentication/external_credentials_provider.py @@ -31,6 +31,7 @@ from .plain import PlainTextCredentialsProvider # meta class compatible with Python 2 *and* 3: ABC = ABCMeta(str('ABC'), (object, ), {str('__slots__'): ()}) + class ExternalCredentialsProvider(PlainTextCredentialsProvider, ABC): """ExternalCredentialsProvider. diff --git a/src/caosdb/connection/authentication/interface.py b/src/caosdb/connection/authentication/interface.py index fe9cb9170933cc12f76747d9d3c62a1a1fd2e8bd..b705ab130476ba5ab7b9459cbdda8e1a25ed8752 100644 --- a/src/caosdb/connection/authentication/interface.py +++ b/src/caosdb/connection/authentication/interface.py @@ -144,7 +144,6 @@ class AbstractAuthenticator(ABC): headers['Cookie'] = self._session_token - class CredentialsAuthenticator(AbstractAuthenticator): """CredentialsAuthenticator diff --git a/src/caosdb/exceptions.py b/src/caosdb/exceptions.py index 485ad908b18310d9f8346beb2261b528a8a45cce..baa72b2428a42c75c3b0e8c46b55d5b11f843417 100644 --- a/src/caosdb/exceptions.py +++ b/src/caosdb/exceptions.py @@ -32,6 +32,7 @@ class CaosDBException(Exception): Exception.__init__(self, msg) self.msg = msg + class ConfigurationException(CaosDBException): """ConfigurationException. @@ -48,6 +49,7 @@ class ConfigurationException(CaosDBException): msg : str A description of the misconfiguration. """ + def __init__(self, msg): super(ConfigurationException, self).__init__(msg + ConfigurationException._INFO) diff --git a/unittests/test_authentication_external.py b/unittests/test_authentication_external.py index c595d38f83f6994f62baca924b1225832b9a659b..a526385978bc6e356ae547e333768ccd6b26d5f9 100644 --- a/unittests/test_authentication_external.py +++ b/unittests/test_authentication_external.py @@ -10,9 +10,11 @@ from caosdb.connection.authentication import ( external_credentials_provider as ecp ) + class _TestCaller(ecp.ExternalCredentialsProvider): pass + def test_callback(): def _callback(**config): assert "opt" in config @@ -21,6 +23,7 @@ def test_callback(): t.configure(opt=None) assert t.password == "secret" + def test_log_password_incident(): class _mylogger(logging.Logger): def log(self, level, msg, *args, **kwargs): diff --git a/unittests/test_authentication_keyring.py b/unittests/test_authentication_keyring.py index 721adefde1df3a819c72ec61433debd9856e6b9f..1105b9d29604e7809c1f6ab6d6a6d027c5115025 100644 --- a/unittests/test_authentication_keyring.py +++ b/unittests/test_authentication_keyring.py @@ -29,6 +29,7 @@ import sys from pytest import raises from caosdb.connection.authentication.keyring import KeyringCaller + def test_initialization(): def _callback(**config): assert not config diff --git a/unittests/test_authentication_pass.py b/unittests/test_authentication_pass.py index 968fdfd94b75eef27f76bb0e0f07370bca3e5150..e5e4870c890a6a19effe672a3fde127cb4ea1fd7 100644 --- a/unittests/test_authentication_pass.py +++ b/unittests/test_authentication_pass.py @@ -27,10 +27,11 @@ Tests for the caosdb.connection.authentication.pass module. """ import sys from pytest import raises -_PASSCALLER="caosdb.connection.authentication.pass" +_PASSCALLER = "caosdb.connection.authentication.pass" __import__(_PASSCALLER) PassCaller = sys.modules[_PASSCALLER].PassCaller + def test_initialization(): def _callback(**config): assert not config diff --git a/unittests/test_authentication_plain.py b/unittests/test_authentication_plain.py index 6b59a23101111ee3592ee5395560a33ab1382b17..26c57e953f28a2a0ab80e35026c27ff74f18d370 100644 --- a/unittests/test_authentication_plain.py +++ b/unittests/test_authentication_plain.py @@ -30,6 +30,7 @@ from __future__ import unicode_literals from pytest import raises from caosdb.connection.authentication.plain import PlainTextCredentialsProvider + def test_subclass_configure(): """Test the correct passing of the password argument.""" class SubClassOf(PlainTextCredentialsProvider): @@ -53,6 +54,7 @@ def test_subclass_configure(): assert exc_info.value.args[0] == ("configure() got multiple values for " "keyword argument 'password'") + def test_plain_has_logger(): p = PlainTextCredentialsProvider() assert hasattr(p, "logger")