Skip to content

Commit

Permalink
Merge 1a2875e into 74a7ae8
Browse files Browse the repository at this point in the history
  • Loading branch information
woutor committed May 3, 2019
2 parents 74a7ae8 + 1a2875e commit 630a5dc
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 36 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -23,14 +23,14 @@ before_install:
--name=hydra
-e DATABASE_URL=memory
--entrypoint=hydra
oryd/hydra:v1.0.0-rc.2_oryOS.9
oryd/hydra:v1.0.0-rc.11
serve all --dangerous-force-http
- sleep 10
- >
docker run -it
-e HYDRA_ADMIN_URL=http://hydra:4445
--link=hydra:hydra
oryd/hydra:v1.0.0-rc.2_oryOS.9
oryd/hydra:v1.0.0-rc.11
clients create --skip-tls-verify
--id client
--secret secret
Expand Down
31 changes: 18 additions & 13 deletions hydra/oauth2.py
Expand Up @@ -70,60 +70,66 @@ def revoke_token(self, token):

def get_login_request(self, challenge):
response = self.request(
'GET', '/oauth2/auth/requests/login/{}'.format(challenge))
'GET', '/oauth2/auth/requests/login',
params={'login_challenge': challenge})
if response.ok:
return response.json()

def get_consent_request(self, challenge):
response = self.request(
'GET', '/oauth2/auth/requests/consent/{}'.format(challenge))
'GET', '/oauth2/auth/requests/consent',
params={'consent_challenge': challenge})
if response.ok:
return response.json()

def accept_login_request(self, challenge, accept_login_config):
response = self.request(
'PUT', '/oauth2/auth/requests/login/{}/accept'.format(challenge),
'PUT', '/oauth2/auth/requests/login/accept',
params={'login_challenge': challenge},
json=accept_login_config)
if response.ok:
return response.json()

def accept_consent_request(self, challenge, accept_consent_config):
response = self.request(
'PUT', '/oauth2/auth/requests/consent/{}/accept'.format(challenge),
'PUT', '/oauth2/auth/requests/consent/accept',
params={'consent_challenge': challenge},
json=accept_consent_config)
if response.ok:
return response.json()

def reject_login_request(self, challenge, reject_login_config):
response = self.request(
'PUT', '/oauth2/auth/requests/login/{}/reject'.format(challenge),
'PUT', '/oauth2/auth/requests/login/reject',
params={'login_challenge': challenge},
json=reject_login_config)
if response.ok:
return response.json()

def reject_consent_request(self, challenge, reject_consent_config):
response = self.request(
'PUT', '/oauth2/auth/requests/consent/{}/reject'.format(challenge),
'PUT', '/oauth2/auth/requests/consent/reject',
params={'consent_challenge': challenge},
json=reject_consent_config)
if response.ok:
return response.json()

def revokes_all_previous_consent_session_user(self, user):
response = self.request(
'DELETE', '/oauth2/auth/sessions/consent/{}'
.format(user))
'DELETE', '/oauth2/auth/sessions/consent',
params={'subject': user})
if response.ok:
response.json()

def revokes_consent_sessions_oAuth2_client(self, user, client):
response = self.request(
'DELETE', '/oauth2/auth/sessions/consent/{}/{}'
.format(user, client))
'DELETE', '/oauth2/auth/sessions/consent',
params={'subject': user, 'client': client})
return response.ok

def lists_all_consent_sessions_user(self, user):
response = self.request(
'GET', '/oauth2/auth/sessions/consent/{}' .format(user))
'GET', '/oauth2/auth/sessions/consent', params={'subject': user})
if response.ok:
return response.json()

Expand All @@ -135,8 +141,7 @@ def logs_user_out_deleting_session_cookie(self):

def invalidates_users_authentication_session(self, user):
response = self.request(
'DELETE', '/oauth2/auth/sessions/login/{}' .format(user))
print(response)
'DELETE', '/oauth2/auth/sessions/login', params={'subject': user})
if response.ok:
return response

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -8,7 +8,7 @@
name='hydra-sdk',
description='Go Hydra SDK for Python',
keywords='hydra oauth2 openid go',
version='1.0.1',
version='1.0.2',
packages=['hydra'],
install_requires=[
'requests==2.21.0',
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Expand Up @@ -18,7 +18,7 @@ def hydra_fixture():
client = docker.from_env()

container_hydra_server = client.containers.run(
'oryd/hydra:v1.0.0-beta.9',
'oryd/hydra:v1.0.0-rc.11',
name='hydra_server',
detach=True,
environment={'DATABASE_URL': 'memory'},
Expand All @@ -32,7 +32,7 @@ def hydra_fixture():
break

container_add_client = client.containers.run(
'oryd/hydra:v1.0.0-beta.9',
'oryd/hydra:v1.0.0-rc.11',
environment={'HYDRA_ADMIN_URL': 'http://hydra:4445'},
detach=True,
links={'hydra_server': 'hydra'},
Expand Down
36 changes: 18 additions & 18 deletions tests/test_oauth2.py
Expand Up @@ -108,8 +108,8 @@ def test_can_get_login_request(self, request):
c.get_login_request(self.challenge)
request.assert_called_with(
'GET',
'http://localhost:4445/oauth2/auth/requests/login/{}'
.format(self.challenge))
'http://localhost:4445/oauth2/auth/requests/login',
params={'login_challenge': self.challenge})

@patch('requests.request')
def test_can_accept_login_request(self, request):
Expand All @@ -122,8 +122,8 @@ def test_can_accept_login_request(self, request):
c.accept_login_request(self.challenge, accept_config)
request.assert_called_with(
'PUT',
'http://localhost:4445/oauth2/auth/requests/login/{}/accept'
.format(self.challenge),
'http://localhost:4445/oauth2/auth/requests/login/accept',
params={'login_challenge': self.challenge},
json=accept_config)

@patch('requests.request')
Expand All @@ -132,8 +132,8 @@ def test_can_get_consent_request(self, request):
c.get_consent_request(self.challenge)
request.assert_called_with(
'GET',
'http://localhost:4445/oauth2/auth/requests/consent/{}'
.format(self.challenge))
'http://localhost:4445/oauth2/auth/requests/consent',
params={'consent_challenge': self.challenge})

@patch('requests.request')
def test_can_accept_consent_request(self, request):
Expand All @@ -148,8 +148,8 @@ def test_can_accept_consent_request(self, request):
c.accept_consent_request(self.challenge, accept_config)
request.assert_called_with(
'PUT',
'http://localhost:4445/oauth2/auth/requests/consent/{}/accept'
.format(self.challenge),
'http://localhost:4445/oauth2/auth/requests/consent/accept',
params={'consent_challenge': self.challenge},
json=accept_config)

@patch('requests.request')
Expand All @@ -165,8 +165,8 @@ def test_can_reject_login_request(self, request):
c.reject_login_request(self.challenge, reject_config)
request.assert_called_once_with(
'PUT',
'http://localhost:4445/oauth2/auth/requests/login/{}/reject'
.format(self.challenge),
'http://localhost:4445/oauth2/auth/requests/login/reject',
params={'login_challenge': self.challenge},
json=reject_config)

@patch('requests.request')
Expand All @@ -182,8 +182,8 @@ def test_can_reject_consent_request(self, request):
c.reject_consent_request(self.challenge, reject_config)
request.assert_called_once_with(
'PUT',
'http://localhost:4445/oauth2/auth/requests/consent/{}/reject'
.format(self.challenge),
'http://localhost:4445/oauth2/auth/requests/consent/reject',
params={'consent_challenge': self.challenge},
json=reject_config)

@patch('requests.request')
Expand All @@ -193,8 +193,8 @@ def test_can_revokes_all_previous_consent_session_user(self, request):
c.revokes_all_previous_consent_session_user(user)
request.assert_called_once_with(
'DELETE',
'http://localhost:4445/oauth2/auth/sessions/consent/{}'
.format(user)
'http://localhost:4445/oauth2/auth/sessions/consent',
params={'subject': user}
)

@patch('requests.request')
Expand All @@ -205,8 +205,8 @@ def test_can_revoke_consent_sessions_oAuth2_client(self, request):
c.revokes_consent_sessions_oAuth2_client(user, c.client)
request.assert_called_with(
'DELETE',
'http://localhost:4445/oauth2/auth/sessions/consent/{}/{}'
.format(user, client))
'http://localhost:4445/oauth2/auth/sessions/consent',
params={'subject': user, 'client': client})

@patch('requests.request')
def test_can_lists_all_consent_sessions_user(self, request):
Expand All @@ -215,8 +215,8 @@ def test_can_lists_all_consent_sessions_user(self, request):
c.lists_all_consent_sessions_user(user)
request.assert_called_once_with(
'GET',
'http://localhost:4445/oauth2/auth/sessions/consent/{}'
.format(user))
'http://localhost:4445/oauth2/auth/sessions/consent',
params={'subject': user})

@patch('requests.request')
def test_can_logs_user_out_deleting_session_cookie(self, request):
Expand Down

0 comments on commit 630a5dc

Please sign in to comment.