Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests #11

Merged
merged 4 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion ckanext/keycloak/keycloak.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
33 changes: 33 additions & 0 deletions ckanext/keycloak/tests/test_helpers.py
Original file line number Diff line number Diff line change
@@ -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])
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
python-keycloak==2.6.1
python-keycloak-client

Loading