From 29f4d68fe4f7de80a6d7b6cbfaeae8ff8da6affe Mon Sep 17 00:00:00 2001 From: blagoja Date: Wed, 28 Feb 2024 10:22:30 +0100 Subject: [PATCH 1/4] Test commmit --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e790aba..99af6ea 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ python-keycloak==2.6.1 python-keycloak-client - From 60bf878ff2af1641282cbb144f7f5ab5ae5a9fc4 Mon Sep 17 00:00:00 2001 From: blagoja Date: Wed, 28 Feb 2024 10:28:37 +0100 Subject: [PATCH 2/4] Change solr image --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 832066d..059883b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: image: openknowledge/ckan-dev:2.9 services: solr: - image: ckan/ckan-solr-dev:2.9 + image: ckan/ckan-solr:2.9-solr9 postgres: image: ckan/ckan-postgres-dev:2.9 env: From 25bebc1cc97e8382795f1a2202b12703368c4aaa Mon Sep 17 00:00:00 2001 From: blagoja Date: Wed, 28 Feb 2024 10:44:58 +0100 Subject: [PATCH 3/4] Add helpers testst --- ckanext/keycloak/tests/test_helpers.py | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 ckanext/keycloak/tests/test_helpers.py diff --git a/ckanext/keycloak/tests/test_helpers.py b/ckanext/keycloak/tests/test_helpers.py new file mode 100644 index 0000000..8d0334e --- /dev/null +++ b/ckanext/keycloak/tests/test_helpers.py @@ -0,0 +1,33 @@ +import pytest +import ckan.model as model +import ckan.tests.factories as factories +from ckanext.keycloak import helpers as h + + +def test_generate_password(): + password = h.generate_password() + assert len(password) >= 8 + assert type(password) is str + + +@pytest.mark.usefixtures(u'clean_db', u'clean_index') +def test_activate_user_if_deleted(): + user = factories.User() + user = model.User.get(user[u'name']) + user.delete() + h.activate_user_if_deleted(user) + assert not user.is_deleted() + + +@pytest.mark.usefixtures(u'clean_db') +def test_ensure_unique_user_name_existing_user(): + + user = factories.User( + name='existing-user', + email=u'existing-user@example.com' + ) + + user_name = h.ensure_unique_username_from_email(user['email']) + + assert user_name != user['email'].split('@')[0] + assert user_name.startswith(user['email'].split('@')[0]) \ No newline at end of file From e1247002885bc9038e82d7f17fd9c7bc593c64d1 Mon Sep 17 00:00:00 2001 From: blagoja Date: Wed, 28 Feb 2024 14:16:29 +0100 Subject: [PATCH 4/4] Remove print --- ckanext/keycloak/keycloak.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ckanext/keycloak/keycloak.py b/ckanext/keycloak/keycloak.py index 75986db..1767de2 100644 --- a/ckanext/keycloak/keycloak.py +++ b/ckanext/keycloak/keycloak.py @@ -21,7 +21,6 @@ def get_token(self, code, redirect_uri): return self.get_keycloak_client().token(grant_type="authorization_code", code=code, redirect_uri=redirect_uri) def get_user_info(self, token): - print (token.get('access_token')) return self.get_keycloak_client().userinfo(token.get('access_token')) def get_user_groups(self, token):