Skip to content

Commit

Permalink
Make keycloak port configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
nuwang committed Nov 6, 2023
1 parent 28a015b commit c49af4d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions test/integration/oidc/test_auth_oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
KEYCLOAK_ADMIN_PASSWORD = "admin"
KEYCLOAK_TEST_USERNAME = "gxyuser"
KEYCLOAK_TEST_PASSWORD = "gxypass"
KEYCLOAK_URL = "https://localhost:8443/realms/gxyrealm"
KEYCLOAK_HOST_PORT = 9443
KEYCLOAK_URL = f"https://localhost:{KEYCLOAK_HOST_PORT}/realms/gxyrealm"


OIDC_BACKEND_CONFIG_TEMPLATE = f"""<?xml version="1.0"?>
Expand All @@ -35,28 +36,28 @@
"""


def wait_till_keycloak_ready(port):
def wait_till_app_ready(url):
return (
subprocess.call(
[
"timeout",
"300",
"bash",
"-c",
f"'until curl --silent --output /dev/null http://localhost:{port}; do sleep 0.5; done'",
f"'until curl --silent --output /dev/null {url}; do sleep 0.5; done'",
]
)
== 0
)


def start_keycloak_docker(container_name, port=8443, image="keycloak/keycloak:22.0.1"):
def start_keycloak_docker(container_name, image="keycloak/keycloak:22.0.1"):
keycloak_realm_data = os.path.dirname(__file__)
START_SLURM_DOCKER = [
"docker",
"run",
"-p",
f"{port}:8443",
f"{KEYCLOAK_HOST_PORT}:8443",
"-d",
"--name",
container_name,
Expand All @@ -77,7 +78,7 @@ def start_keycloak_docker(container_name, port=8443, image="keycloak/keycloak:22
"--https-certificate-key-file=/opt/keycloak/data/import/keycloak-server.key.pem",
]
subprocess.check_call(START_SLURM_DOCKER)
wait_till_keycloak_ready(port)
wait_till_app_ready(KEYCLOAK_URL)


def stop_keycloak_docker(container_name):
Expand Down

0 comments on commit c49af4d

Please sign in to comment.