100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
#!/usr/bin/env python3
"""Render Keycloak URLs for CLI and legacy Helm values without a cluster."""
from pathlib import Path
import re
import subprocess
import unittest
CHART = Path(__file__).resolve().parents[1] / "keycloak"
class KeycloakUrlTest(unittest.TestCase):
def test_public_urls(self):
cases = (
("localhost", "https://localhost/auth"),
("load2.openremote.app", "https://load2.openremote.app/auth"),
("localhost:9443", "https://localhost:9443/auth"),
("https://load2.openremote.app/auth", "https://load2.openremote.app/auth"),
("https://localhost:8443/auth", "https://localhost:8443/auth"),
("http://localhost:8080/auth", "http://localhost:8080/auth"),
("https://login.example.com/custom", "https://login.example.com/custom"),
)
for hostname, expected in cases:
with self.subTest(hostname=hostname):
result = subprocess.run(
["helm", "template", "keycloak", str(CHART),
"--set-string", f"or.hostname={hostname}"],
capture_output=True, text=True, check=True,
)
urls = re.findall(r'- name: KC_HOSTNAME\s+value: "([^"]+)"', result.stdout)
self.assertEqual(urls, [expected])
if __name__ == "__main__":
unittest.main(verbosity=2)