Skip to content

Commit

Permalink
Merge pull request #11 from keitaroinc/test2
Browse files Browse the repository at this point in the history
Tests
  • Loading branch information
popovski2 authored Mar 8, 2024
2 parents d3789cd + e124700 commit bd13f04
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
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'[email protected]'
)

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

0 comments on commit bd13f04

Please sign in to comment.