diff --git a/src/caosdb/connection/authentication/external_credentials_provider.py b/src/caosdb/connection/authentication/external_credentials_provider.py index bebe43fedf215dfc2b744fbc0c96d7e9d50ba3e5..1cf4cefc90de2a0281528eb83c1efe55eda4f345 100644 --- a/src/caosdb/connection/authentication/external_credentials_provider.py +++ b/src/caosdb/connection/authentication/external_credentials_provider.py @@ -21,8 +21,7 @@ # # ** end header # -"""external_credentials_provider. -""" +"""external_credentials_provider.""" from __future__ import absolute_import, unicode_literals from abc import ABCMeta import logging diff --git a/src/caosdb/connection/authentication/interface.py b/src/caosdb/connection/authentication/interface.py index 8be18b57352a1f89bf139a5b569970ff483472d1..745517a2ab1b884a1fad5e0627ffd9de26853ed6 100644 --- a/src/caosdb/connection/authentication/interface.py +++ b/src/caosdb/connection/authentication/interface.py @@ -126,7 +126,7 @@ class AbstractAuthenticator(ABC): def on_request(self, method, path, headers, **kwargs): # pylint: disable=unused-argument - """on_request + """on_request. A call-back which is to be called by the connection before each request. This method set the auth cookie for that request. @@ -150,7 +150,7 @@ class AbstractAuthenticator(ABC): class CredentialsAuthenticator(AbstractAuthenticator): - """CredentialsAuthenticator + """CredentialsAuthenticator. Subclass of AbstractAuthenticator which provides authentication via credentials (username/password). This class always needs a diff --git a/src/caosdb/connection/interface.py b/src/caosdb/connection/interface.py index 58acf60985c9e318d1642301660bf7de8e984715..a6f739171597a848356321578f4a4065a2e94006 100644 --- a/src/caosdb/connection/interface.py +++ b/src/caosdb/connection/interface.py @@ -67,8 +67,8 @@ class CaosDBHTTPResponse(ABC): def close(self): """close. - Close this response. Depending on the implementation this might also - close underlying streams, sockets etc. + Close this response. Depending on the implementation this might + also close underlying streams, sockets etc. """ diff --git a/src/caosdb/connection/utils.py b/src/caosdb/connection/utils.py index c1245a088e868077a817f9a7877a1ae51bf9fb9f..8c1518c1ba66b45c69d5b9fa0d137f0df633cd0c 100644 --- a/src/caosdb/connection/utils.py +++ b/src/caosdb/connection/utils.py @@ -164,8 +164,10 @@ def check_python_ssl_version(hexversion): "\nPython 3 version is smaller than 3.2. It is not does not fully support SSL encryption. Please update your Python to 2.7.9 or greater, or 3.2 or greater." ) + _PATTERN = re.compile(r"^SessionToken=([^;]*);.*$") + def unquote(string): """unquote. @@ -177,6 +179,7 @@ def unquote(string): return bts.decode("utf-8") return bts + def parse_auth_token(cookie): """parse_auth_token. @@ -197,6 +200,7 @@ def parse_auth_token(cookie): auth_token = unquote(_PATTERN.split(cookie)[1]) return auth_token + def auth_token_to_cookie(auth_token): """auth_token_to_cookie. diff --git a/unittests/test_authentication_keyring.py b/unittests/test_authentication_keyring.py index 1105b9d29604e7809c1f6ab6d6a6d027c5115025..715514498b406478a3bddcc64c7794316f64368e 100644 --- a/unittests/test_authentication_keyring.py +++ b/unittests/test_authentication_keyring.py @@ -21,7 +21,7 @@ # # ** end header # -"""test_authentication_keyring +"""test_authentication_keyring. Tests for the caosdb.connection.authentication.keyring module. """ diff --git a/unittests/test_authentication_pass.py b/unittests/test_authentication_pass.py index e5e4870c890a6a19effe672a3fde127cb4ea1fd7..45bda08a46bcc95aa73e5609f053f3ac178901dc 100644 --- a/unittests/test_authentication_pass.py +++ b/unittests/test_authentication_pass.py @@ -21,7 +21,7 @@ # # ** end header # -"""test_authentication_pass +"""test_authentication_pass. Tests for the caosdb.connection.authentication.pass module. """ diff --git a/unittests/test_connection_utils.py b/unittests/test_connection_utils.py index 4af6319986c5f16be7e2a8bfeab6d2e92a3eb5a3..c21b453e3a7588f30d86be8d2ed39bb4d7a1d31e 100644 --- a/unittests/test_connection_utils.py +++ b/unittests/test_connection_utils.py @@ -21,7 +21,7 @@ # # ** end header # -"""Test caosdb.connection.utils""" +"""Test caosdb.connection.utils.""" # pylint: disable=missing-docstring from __future__ import unicode_literals, print_function from pytest import raises @@ -47,5 +47,6 @@ def setup_module(): def test_parse_auth_token(): assert parse_auth_token("SessionToken=%5Bblablabla%5D; expires=bla; ...") == "[blablabla]" + def test_auth_token_to_cookie(): assert auth_token_to_cookie("[blablabla]") == "SessionToken=%5Bblablabla%5D;"