urbanplatform / django-keycloak-auth

Middleware to allow authorization using Keycloak and Django for django-rest-framework (DRF). This package should only be used in projects starting from scratch, since it overrides the users' management.
MIT License
32 stars 14 forks source link

Add ci test setup #33

Closed moritz89 closed 1 year ago

moritz89 commented 1 year ago

Why:

This change addresses the need by:

simao-silva commented 1 year ago

Any reason why you did not include Python 3.9 and only do tests with Keycloak legacy versions?

moritz89 commented 1 year ago

Any reason why you did not include Python 3.9 and only do tests with Keycloak legacy versions?

Regarding 3.9, it is a tradeoff in the number of builds. The matrix build starts a CI job for each possible combination of Python and Keycloak version. That is why I assessed it to be the case that if a feature is added / removed in an in-between Python version, then it'll also fail in the newest version.

Regarding the legacy tags, AFAIK they are the newest version 19.0.3 vs 19.0.3-legacy is the same Keycloak program version, but are differentiated by the Docker start script. As I've used the legacy start behavior in my tests, the easiest approach was to keep the same Docker start behavior.

I would also propose testing the newest version of major Keycloak releases from the last two years, so that we don't inadvertently break backwards compatibility.

simao-silva commented 1 year ago

I would also propose testing the newest version of major Keycloak releases from the last two years, so that we don't inadvertently break backwards compatibility.

I agree with you. I've included tests with Python 3.7 and 3.9 and Keycloak versions 13 and 14. However, I did not include Keycloak versions from 10 to 12 since I get the following errors in the tests:

======================================================================
ERROR: test_model (test_app.tests.test_init.TestInit)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/django-keycloak-auth/django-keycloak-auth/tests/test_site/test_app/tests/test_init.py", line 11, in setUp
    self.keycloak_init()
  File "/home/runner/work/django-keycloak-auth/django-keycloak-auth/src/django_keycloak/mixins.py", line 37, in keycloak_init
    self._start_users = {user.get("id") for user in self.keycloak.get_users()}
  File "/home/runner/work/django-keycloak-auth/django-keycloak-auth/src/django_keycloak/mixins.py", line 37, in <setcomp>
    self._start_users = {user.get("id") for user in self.keycloak.get_users()}
AttributeError: 'str' object has no attribute 'get'

======================================================================
ERROR: test_pass (test_app.tests.test_init.TestInit)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/django-keycloak-auth/django-keycloak-auth/tests/test_site/test_app/tests/test_init.py", line 11, in setUp
    self.keycloak_init()
  File "/home/runner/work/django-keycloak-auth/django-keycloak-auth/src/django_keycloak/mixins.py", line 37, in keycloak_init
    self._start_users = {user.get("id") for user in self.keycloak.get_users()}
  File "/home/runner/work/django-keycloak-auth/django-keycloak-auth/src/django_keycloak/mixins.py", line 37, in <setcomp>
    self._start_users = {user.get("id") for user in self.keycloak.get_users()}
AttributeError: 'str' object has no attribute 'get'
moritz89 commented 1 year ago

Merged in with v2