From c1490dc27d2bb1304091e56183014265f3a5b887 Mon Sep 17 00:00:00 2001 From: Timm Fitschen <timm.fitschen@ds.mpg.de> Date: Tue, 20 Nov 2018 00:02:42 +0100 Subject: [PATCH] STY: formatting --- .../authentication/external_credentials_provider.py | 3 +-- src/caosdb/connection/authentication/interface.py | 4 ++-- src/caosdb/connection/interface.py | 4 ++-- src/caosdb/connection/utils.py | 4 ++++ unittests/test_authentication_keyring.py | 2 +- unittests/test_authentication_pass.py | 2 +- unittests/test_connection_utils.py | 3 ++- 7 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/caosdb/connection/authentication/external_credentials_provider.py b/src/caosdb/connection/authentication/external_credentials_provider.py index bebe43fe..1cf4cefc 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 8be18b57..745517a2 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 58acf609..a6f73917 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 c1245a08..8c1518c1 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 1105b9d2..71551449 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 e5e4870c..45bda08a 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 4af63199..c21b453e 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;" -- GitLab