Skip to content

Commit

Permalink
- removes leftovers
Browse files Browse the repository at this point in the history
- keycloak UTs updates (based on new and improved flows)

Ref: #71
  • Loading branch information
oliveratfoodcoopx committed Nov 23, 2022
1 parent d4465d1 commit ba266f8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 34 deletions.
25 changes: 19 additions & 6 deletions tapir/accounts/tests/test_keycloak.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,30 @@
from tapir.accounts.tests.factories.factories import TapirUserFactory
from django.test import RequestFactory

class KeycloakAuthentication(TapirFactoryTestBase):

def test_backend_authenticates_user_against_keycloak_server(self):
class KeycloakServerBackendAuthenticationTests(TapirFactoryTestBase):
"""
This testa are run against the keycloak server within this project
(Docker server keycloak-server)
"""
def test_authenticates_user_against_keycloak(self):
request = RequestFactory().get('/')
auth_user = authenticate(request, username='demo@demo.com', password='demo')
self.assertIsNotNone(auth_user)

def test_backend_disabled_cannot_login(self):
def test_disabled_cannot_login(self):
request = RequestFactory().get('/')
auth_user = authenticate(request, username='inactive@inactive.com', password='inactive')
self.assertIsNone(auth_user)

def test_backend_differentiates_between_different_realms(self):
self.fail("user from another realm cannot login")
def test_differentiates_between_different_realms(self):
self.fail("user from another realm cannot login")



class KeycloakServerSignupTests(TapirFactoryTestBase):
"""
This testa are run against the keycloak server within this project
(Docker server keycloak-server)
"""
def test_users_can_signup_using_username_and_password(self):
self.fail('caputre signup form nd post it')
26 changes: 0 additions & 26 deletions tapir/accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,29 +88,3 @@ def send_user_welcome_email(request, pk):
messages.info(request, _("Account welcome email sent."))

return redirect(tapir_user.get_absolute_url())



def logged(request):
from django.http import HttpResponse
from keycloak import KeycloakOpenID
keycloak_openid = KeycloakOpenID(
server_url="http://keycloak-server:8080", # add auth?
client_id="tapirweb",
realm_name="tapir",
client_secret_key="UYAoNSPYkJd8IpktSYOXp24PBHT6LN1r"
)

token = keycloak_openid.token(
grant_type='authorization_code',
code=request.GET['code'],
redirect_uri="http://localhost:8000/accounts/logged"
)
print("----------------------------------")
print(token)
print("----------------------------------")
userinfo = keycloak_openid.userinfo(token['access_token'])
print("----------------------------------")
print(userinfo)
print("----------------------------------")
return HttpResponse(token)
1 change: 0 additions & 1 deletion tapir/wirgarten/forms/registration/pickup_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def __init__(self, *args, **kwargs):
product_type__name=product_type_id
).values("pickup_location__id")
)

self.fields["pickup_location"] = PickupLocationChoiceField(
label=_("Abholort"), initial=0, queryset=filtered_pickup_locations
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h4>{{wizard.steps.current|get_step_title}}</h4>
</div>

<div class="card-body">

{{ wizard.management_form }}
{% block cardbody%}

Expand Down

0 comments on commit ba266f8

Please sign in to comment.