Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Openlobby Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
openlobby
Openlobby Server
Commits
cc2d2278
Commit
cc2d2278
authored
7 years ago
by
jan.bednarik
Browse files
Options
Downloads
Patches
Plain Diff
Keycloak test fixture.
parent
bfcdcf2f
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/conftest.py
+27
-1
27 additions, 1 deletion
tests/conftest.py
with
27 additions
and
1 deletion
tests/conftest.py
+
27
−
1
View file @
cc2d2278
import
pytest
import
pytest
import
dsnparse
from
django_elasticsearch_dsl.test
import
ESTestCase
from
django_elasticsearch_dsl.test
import
ESTestCase
...
@@ -16,8 +17,33 @@ class TestCase(ESTestCase, DummyTestCase):
...
@@ -16,8 +17,33 @@ class TestCase(ESTestCase, DummyTestCase):
@pytest.fixture
@pytest.fixture
def
django_es
():
def
django_es
():
"""
Setup and teardown of test indices.
"""
"""
Setup and teardown of
Elasticsearch
test indices.
"""
testCase
=
TestCase
()
testCase
=
TestCase
()
testCase
.
setUp
()
testCase
.
setUp
()
yield
yield
testCase
.
tearDown
()
testCase
.
tearDown
()
def
pytest_addoption
(
parser
):
parser
.
addoption
(
'
--keycloak
'
,
action
=
'
store
'
,
help
=
(
'
Keycloak server DSN with OpenID client credentials for auth tests.
'
'
Format: http://client_id:client_secret@host:port/realm
'
))
@pytest.fixture
(
scope
=
'
session
'
)
def
keycloak
(
request
):
"""
Keycloak server and OpenID client info.
"""
dsn
=
request
.
config
.
getoption
(
'
--keycloak
'
)
if
dsn
is
None
:
pytest
.
skip
(
'
No Keycloak DSN provided.
'
)
config
=
dsnparse
.
parse
(
dsn
)
realm_url
=
'
{}://{}:{}/auth/realms/{}
'
.
format
(
config
.
scheme
,
config
.
host
,
config
.
port
,
config
.
paths
[
0
])
return
{
'
client_id
'
:
config
.
username
,
'
client_secret
'
:
config
.
password
,
'
issuer
'
:
realm_url
,
'
authorization_endpoint
'
:
'
{}/protocol/openid-connect/auth
'
.
format
(
realm_url
),
'
token_endpoint
'
:
'
{}/protocol/openid-connect/token
'
.
format
(
realm_url
),
'
userinfo_endpoint
'
:
'
{}/protocol/openid-connect/userinfo
'
.
format
(
realm_url
),
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment