Skip to content

Commit

Permalink
feat(config-api): testng framework wip
Browse files Browse the repository at this point in the history
Signed-off-by: pujavs <[email protected]>
  • Loading branch information
pujavs committed Dec 18, 2024
2 parents 98712a2 + 498b82a commit d9fc6b6
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 35 deletions.
3 changes: 3 additions & 0 deletions docker-jans-config-api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ RUN cd /tmp/jans \
&& cp ${JANS_SETUP_DIR}/templates/jans-config-api/config.ldif /app/templates/jans-config-api/ \
&& cp ${JANS_SETUP_DIR}/templates/jans-config-api/dynamic-conf.json /app/templates/jans-config-api/ \
&& cp ${JANS_SETUP_DIR}/setup_app/utils/printVersion.py /opt/jans/bin/printVersion.py \
&& chmod +x /opt/jans/bin/printVersion.py \
&& ln -s /opt/jans/bin/printVersion.py /opt/jans/bin/show_version.py \
&& cp ${JANS_CONFIG_API_RESOURCES}/config-api-rs-protect.json /app/templates/jans-config-api/ \
&& mkdir -p org/eclipse/jetty \
Expand Down Expand Up @@ -237,6 +238,8 @@ COPY templates /app/templates/
RUN cp /app/templates/jans-config-api/jans-config-api.xml ${JETTY_BASE}/jans-config-api/webapps/
COPY scripts /app/scripts
RUN chmod +x /app/scripts/entrypoint.sh
RUN chmod +x /app/scripts/external_healthcheck.py \
&& ln -s /app/scripts/external_healthcheck.py /opt/jans/bin/jans_services_status.py

# unquote apiApprovedIssuer
RUN sed -i 's/"${apiApprovedIssuer}"/${apiApprovedIssuer}/g' /app/templates/jans-config-api/dynamic-conf.json
Expand Down
64 changes: 64 additions & 0 deletions docker-jans-config-api/scripts/external_healthcheck.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env python3
import json

import requests

from jans.pycloudlib import get_manager


def poll_healthchecks(manager):
import urllib3

hostname = manager.config.get("hostname")
statuses = {}

for comp, endpoint, status_code_only in [
("jans-auth", "/jans-auth/sys/health-check", False),
("jans-lock", "/jans-auth/sys/health-check", False),
("jans-config-api", "/jans-config-api/api/v1/health/live", False),
("jans-casa", "/jans-casa/health-check", False),
("jans-fido2", "/jans-fido2/sys/health-check", False),
("jans-scim", "/jans-scim/sys/health-check", False),
("jans-link", "/jans-link/sys/health-check", False),
# healthcheck endpoint for KC is bind to internal port 9000,
# hence we poll the public endpoint instead
("keycloak", "/kc", True),
]:
# default component status
status = "Down"

scheme = "https"
verify = False

if scheme == "https" and verify is False:
urllib3.disable_warnings()

resp = requests.get(f"{scheme}://{hostname}{endpoint}", timeout=5, verify=verify)

if resp.ok:
if status_code_only:
status = "Running"
else:
try:
if comp == "jans-lock":
healthcheck_data = resp.json().get("jans-lock", {"status": status})
else:
healthcheck_data = resp.json()

if healthcheck_data["status"].lower() in ("running", "up"):
status = "Running"

# response from server is not JSON
except requests.exceptions.JSONDecodeError:
if resp.text.lower() == "ok":
status = "Running"

# finalized statuses
statuses[comp] = status

return json.dumps(statuses)


if __name__ == "__main__":
manager = get_manager()
print(poll_healthchecks(manager))
16 changes: 8 additions & 8 deletions jans-config-api/docs/jans-config-api-swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9303,19 +9303,19 @@ components:
type: string
selected:
type: boolean
adminCanAccess:
type: boolean
userCanAccess:
whitePagesCanView:
type: boolean
adminCanView:
type: boolean
adminCanEdit:
userCanView:
type: boolean
userCanEdit:
type: boolean
userCanView:
adminCanEdit:
type: boolean
whitePagesCanView:
adminCanAccess:
type: boolean
userCanAccess:
type: boolean
baseDn:
type: string
Expand Down Expand Up @@ -10177,6 +10177,8 @@ components:
type: boolean
lockMessageConfig:
$ref: '#/components/schemas/LockMessageConfig'
fapi:
type: boolean
allResponseTypesSupported:
uniqueItems: true
type: array
Expand All @@ -10186,8 +10188,6 @@ components:
- code
- token
- id_token
fapi:
type: boolean
AuthenticationFilter:
required:
- baseDn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,8 @@ public void setUserPassword(String userPassword) {
@Override
public String toString() {
return "CustomUser [inum=" + inum + ", mail=" + mail + ", displayName=" + displayName
+ ", givenName=" + givenName + ", userPassword=" + userPassword + "]";
+ ", givenName=" + givenName + "]";
}





}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ public void setCustomAttributes(List<CustomObjectAttribute> customAttributes) {

@Override
public String toString() {
return "UserPatchRequest [jsonPatchString=" + jsonPatchString + ", customAttributes=" + customAttributes + "]";
return "UserPatchRequest [jsonPatchString=" + jsonPatchString + "]";
}
}
Loading

0 comments on commit d9fc6b6

Please sign in to comment.