Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
nomad-FAIR
Commits
ed57cfff
Commit
ed57cfff
authored
Aug 28, 2019
by
Markus Scheidgen
Browse files
Run tests agains the keycloak on labdev.
parent
63bad93a
Pipeline
#54533
passed with stages
in 27 minutes and 24 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
ed57cfff
...
...
@@ -90,6 +90,7 @@ tests:
NOMAD_RABBITMQ_HOST
:
rabbitmq
NOMAD_ELASTIC_HOST
:
elastic
NOMAD_MONGO_HOST
:
mongo
NOMAD_KEYCLOAK_CLIENT_SECRET
:
${CI_KEYCLOAK_TEST_CLIENT_SECRET}
script
:
-
cd /app
-
python -m pytest --cov=nomad -sv tests
...
...
nomad/config.py
View file @
ed57cfff
...
...
@@ -111,14 +111,16 @@ elastic = NomadConfig(
index_name
=
'nomad_fairdi_calcs'
)
keycloak_base_url
=
'https://labdev-nomad.esc.rzg.mpg.de/fairdi/keycloak/auth/'
keycloak
=
NomadConfig
(
server_url
=
'http://localhost:8002/auth/'
,
issuer_url
=
'http://localhost:8002/auth/
realms/fairdi_nomad_test'
,
server_url
=
keycloak_base_url
,
issuer_url
=
keycloak_base_url
+
'
realms/fairdi_nomad_test'
,
realm_name
=
'fairdi_nomad_test'
,
username
=
'admin'
,
password
=
'password'
,
client_id
=
'nomad_api_dev'
,
client_secret
_key
=
'ae9bb323-3793-4243-9e4b-f380c54e54e2
'
client_secret
=
'**********
'
)
mongo
=
NomadConfig
(
...
...
nomad/infrastructure.py
View file @
ed57cfff
...
...
@@ -27,6 +27,7 @@ from mongoengine import connect
import
smtplib
from
email.mime.text
import
MIMEText
from
keycloak
import
KeycloakOpenID
,
KeycloakAdmin
from
keycloak.exceptions
import
KeycloakAuthenticationError
import
json
import
jwt
from
flask
import
g
,
request
...
...
@@ -119,7 +120,7 @@ class Keycloak():
server_url
=
config
.
keycloak
.
server_url
,
client_id
=
config
.
keycloak
.
client_id
,
realm_name
=
config
.
keycloak
.
realm_name
,
client_secret_key
=
config
.
keycloak
.
client_secret
_key
)
client_secret_key
=
config
.
keycloak
.
client_secret
)
return
self
.
__oidc_client
...
...
@@ -162,8 +163,10 @@ class Keycloak():
username
,
password
=
basicauth
.
decode
(
auth
)
token_info
=
self
.
_oidc_client
.
token
(
username
=
username
,
password
=
password
)
g
.
oidc_access_token
=
token_info
[
'access_token'
]
except
KeycloakAuthenticationError
:
return
'Could not authenticate, wrong credentials'
except
Exception
as
e
:
# TODO logging
logger
.
error
(
'Could not authenticate Basic auth'
,
exc_info
=
e
)
return
'Could not authenticate Basic auth: %s'
%
str
(
e
)
if
g
.
oidc_access_token
is
not
None
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment