From 81d561273f3f4eb972eb694e19bfceaec8b5c7ad Mon Sep 17 00:00:00 2001 From: npalaska Date: Thu, 30 Mar 2023 09:02:03 -0400 Subject: [PATCH] fix some left over gaps --- dashboard/src/utils/helper.js | 16 ++++++++++++++++ .../server/api/resources/endpoint_configure.py | 6 +++--- lib/pbench/server/database/models/users.py | 2 +- .../etc/pbench-server/pbench-server.cfg | 2 +- server/pbenchinacan/run-pbench-in-a-can | 2 +- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/dashboard/src/utils/helper.js b/dashboard/src/utils/helper.js index 7d72ef8baf..ec0af30161 100644 --- a/dashboard/src/utils/helper.js +++ b/dashboard/src/utils/helper.js @@ -4,3 +4,19 @@ export const uid = () => { return head + tail; }; + +/** + * Expand a templated API URI like a Python `.format` + * + * @param {Object} endpoints - endpoint object from server + * @param {string} name - name of the API to expand + * @param {Object} args - value for each templated parameter + * @return {string} - formatted URI + */ +export const expandUriTemplate = (endpoints, name, args) => { + let uri = endpoints.uri[name].template; + for (const [key, value] of Object.entries(args)) { + uri = uri.replace(`{${key}}`, value); + } + return uri; +}; diff --git a/lib/pbench/server/api/resources/endpoint_configure.py b/lib/pbench/server/api/resources/endpoint_configure.py index 355c5a25d6..21e673f5b3 100644 --- a/lib/pbench/server/api/resources/endpoint_configure.py +++ b/lib/pbench/server/api/resources/endpoint_configure.py @@ -178,9 +178,9 @@ def get(self): } try: - client = self.server_config.get("openid-connect", "client") - realm = self.server_config.get("openid-connect", "realm") - server = self.server_config.get("openid-connect", "server_url") + client = self.server_config.get("openid", "client") + realm = self.server_config.get("openid", "realm") + server = self.server_config.get("openid", "server_url") except (NoOptionError, NoSectionError): pass else: diff --git a/lib/pbench/server/database/models/users.py b/lib/pbench/server/database/models/users.py index 7fd0ee5190..93971735e4 100644 --- a/lib/pbench/server/database/models/users.py +++ b/lib/pbench/server/database/models/users.py @@ -1,5 +1,5 @@ import enum -from typing import Optional, Union +from typing import Optional from sqlalchemy import Column, String from sqlalchemy.exc import IntegrityError diff --git a/server/pbenchinacan/etc/pbench-server/pbench-server.cfg b/server/pbenchinacan/etc/pbench-server/pbench-server.cfg index 04aa17a1e2..05468ce5e0 100644 --- a/server/pbenchinacan/etc/pbench-server/pbench-server.cfg +++ b/server/pbenchinacan/etc/pbench-server/pbench-server.cfg @@ -23,7 +23,7 @@ uri = postgresql://pbenchcontainer:pbench@localhost:5432/pbenchcontainer [flask-app] secret-key = "pbench-in-a-can secret shhh" -[openid-connect] +[openid] server_url = http://localhost:8090 ########################################################################### diff --git a/server/pbenchinacan/run-pbench-in-a-can b/server/pbenchinacan/run-pbench-in-a-can index 3a8587e7fb..14ea49054c 100755 --- a/server/pbenchinacan/run-pbench-in-a-can +++ b/server/pbenchinacan/run-pbench-in-a-can @@ -24,7 +24,7 @@ export PB_SERVER_IMAGE_PULL_POLICY="${PB_SERVER_IMAGE_PULL_POLICY:-${PB_COMMON_I export PB_DASHBOARD_DIR="${PB_DASHBOARD_DIR:-${PWD}/dashboard/build/}" export KEYCLOAK_REALM=${KEYCLOAK_REALM:-"pbench-server"} -export KEYCLOAK_CLIENT=${KEYCLOAK_CLIENT:-"pbench-dashboard"} +export KEYCLOAK_CLIENT=${KEYCLOAK_CLIENT:-"pbench-client"} # Set up TMP_DIR, if it's not already defined, to point to WORKSPACE_TMP, if it # is defined (e.g., by the CI), or to `/var/tmp/pbench` as a fallback.