UNPKG

keycloak-testcontainer

Version:
39 lines (38 loc) 1.26 kB
import { Keycloak } from '../keycloak.js'; export const defaultAdminUser = { username: Keycloak.ADMIN_USER, password: Keycloak.ADMIN_PASSWORD }; export class EnvironmentBuilder { constructor() { this.adminUser = defaultAdminUser; this.managementPort = 9000; this.managementPath = '/'; this.hostnamePath = '/'; } withHostname(hostname) { this.hostname = hostname; } withAdminUser(adminUser) { this.adminUser = adminUser; } withManagementPort(port) { this.managementPort = port; } getManagementPort() { return this.managementPort; } withManagementPath(managementPath) { this.managementPath = managementPath; } withHostnamePath(path) { this.hostnamePath = path; } getHostNamePath() { return this.hostnamePath; } build() { const { username, password } = this.adminUser; return Object.assign(Object.assign({ KEYCLOAK_ADMIN: username, KEYCLOAK_ADMIN_PASSWORD: password, KC_HTTP_MANAGEMENT_PORT: this.managementPort.toString(), KC_HTTP_MANAGEMENT_RELATIVE_PATH: this.managementPath }, (this.hostname && { KC_HOSTNAME: this.hostname })), { KC_HTTP_RELATIVE_PATH: this.hostnamePath }); } }