Skip to content

Commit

Permalink
Fixers
Browse files Browse the repository at this point in the history
  • Loading branch information
dbutenhof committed May 6, 2024
1 parent 758062f commit 9cd2575
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def get_index(
"""Retrieve ES indices based on a given root_index_name.
Datasets without an index can't be referenced in most APIs that rely on
Elasticsearch. Instead, we'll raise a CONFLICT error. However, the
Elasticsearch. Instead, we'll raise a NOT_FOUND error. However, the
/api/v1/datasets API will specify ok_no_index as they need to operate
on the dataset regardless of whether indexing is enabled.
Expand Down
6 changes: 3 additions & 3 deletions lib/pbench/test/functional/server/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ class TestIndexing:
def test_details(self, server_client: PbenchServerClient, login_user):
"""Check access to indexed data
Perform a GET /datasets/details/{id} to be confirm whether indexed run
Perform a GET /datasets/details/{id} to confirm whether indexed run
data is available.
"""
print(" ... checking dataset RUN index ...")
Expand All @@ -477,7 +477,7 @@ def test_details(self, server_client: PbenchServerClient, login_user):
indexed = bool(indices.json())
print(
f"\t... checking run details for {d.name} "
f"({'' if indexed else 'not '} indexed)"
f"({'' if indexed else 'not '}indexed)"
)
response = server_client.get(
API.DATASETS_DETAIL, {"dataset": d.resource_id}, raise_error=False
Expand All @@ -490,7 +490,7 @@ def test_details(self, server_client: PbenchServerClient, login_user):
assert (
d.metadata["dataset.metalog.pbench"]["script"]
== detail["runMetadata"]["script"]
), f"Unexpected details {detail}"
)
else:
assert (
response.status_code == HTTPStatus.NOT_FOUND
Expand Down
16 changes: 8 additions & 8 deletions server/pbenchinacan/load_keycloak.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ echo
echo "Keycloak connection successful on : ${KEYCLOAK_HOST_PORT}"
echo

status_code=$(curl -f -s -o /dev/null -w "%{http_code}" -X POST \
status_code=$(curl -f -sS -o /dev/null -w "%{http_code}" -X POST \
"${KEYCLOAK_HOST_PORT}/admin/realms" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
Expand All @@ -88,7 +88,7 @@ fi
# a token from Keycloak using a <client_id>.
# Having <client_id> in the aud claim of the token is essential for the token
# to be validated.
curl -si -f -X POST \
curl -sSi -f -X POST \
"${KEYCLOAK_HOST_PORT}/admin/realms/${REALM}/client-scopes" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
Expand Down Expand Up @@ -117,7 +117,7 @@ curl -si -f -X POST \
]
}'

CLIENT_CONF=$(curl -si -f -X POST \
CLIENT_CONF=$(curl -sSi -f -X POST \
"${KEYCLOAK_HOST_PORT}/admin/realms/${REALM}/clients" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
Expand All @@ -138,7 +138,7 @@ else
echo "Created ${CLIENT} client"
fi

status_code=$(curl -s -o /dev/null -w "%{http_code}" -X POST \
status_code=$(curl -sS -o /dev/null -w "%{http_code}" -X POST \
"${KEYCLOAK_HOST_PORT}/admin/realms/${REALM}/clients/${CLIENT_ID}/roles" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
Expand All @@ -151,15 +151,15 @@ else
echo "Created an 'ADMIN' role under ${CLIENT} client of the ${REALM} realm"
fi

ROLE_ID=$(curl -s -f "${KEYCLOAK_HOST_PORT}/admin/realms/${REALM}/clients/${CLIENT_ID}/roles" \
ROLE_ID=$(curl -sS -f "${KEYCLOAK_HOST_PORT}/admin/realms/${REALM}/clients/${CLIENT_ID}/roles" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" | jq -r '.[0].id')

if [[ -z "${ROLE_ID}" ]]; then
echo "ADMIN role id is empty"
exit 1
fi

USER=$(curl -si -f -X POST \
USER=$(curl -sSi -f -X POST \
"${KEYCLOAK_HOST_PORT}/admin/realms/${REALM}/users" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
Expand All @@ -174,7 +174,7 @@ else
echo "Created an 'admin' user inside ${REALM} realm"
fi

status_code=$(curl -s -o /dev/null -w "%{http_code}" -X POST \
status_code=$(curl -sS -o /dev/null -w "%{http_code}" -X POST \
"${KEYCLOAK_HOST_PORT}/admin/realms/${REALM}/users/${USER_ID}/role-mappings/clients/${CLIENT_ID}" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
Expand All @@ -188,7 +188,7 @@ else
fi

# Verify that the user id has an 'ADMIN' role assigned to it
USER_ROLES=$(curl -s "${KEYCLOAK_HOST_PORT}/admin/realms/${REALM}/users/${USER_ID}/role-mappings/clients/${CLIENT_ID}" \
USER_ROLES=$(curl -sS "${KEYCLOAK_HOST_PORT}/admin/realms/${REALM}/users/${USER_ID}/role-mappings/clients/${CLIENT_ID}" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
-H "Content-Type: application/json" | jq -r '.[].name')

Expand Down

0 comments on commit 9cd2575

Please sign in to comment.