keycloak-testcontainer
Version:
Run a Keycloak testcontainer with node.js
74 lines (73 loc) • 2.13 kB
JavaScript
import { CommandsBuilder } from '../configuration/commands.js';
import { EnvironmentBuilder, defaultAdminUser } from '../configuration/environment.js';
export class Configuration {
constructor() {
this.defaultPort = 8080;
this.adminUser = defaultAdminUser;
this.commandsBuilder = new CommandsBuilder();
this.environmentBuilder = new EnvironmentBuilder();
}
withHostName(hostname) {
this.environmentBuilder.withHostname(hostname);
return this;
}
getHostNamePath() {
return this.environmentBuilder.getHostNamePath();
}
withHealth() {
this.commandsBuilder.withHealth();
return this;
}
withRealmImport() {
this.commandsBuilder.withRealmImport();
return this;
}
withDatabase(options) {
this.commandsBuilder.withDatabase(options);
return this;
}
withMetrics() {
this.commandsBuilder.withMetrics();
return this;
}
withFeatures(features) {
this.commandsBuilder.withFeatures(features);
return this;
}
withDisabledFeatures(disabledFeatures) {
this.commandsBuilder.withDisabledFeatures(disabledFeatures);
return this;
}
withAdminUser(adminUser) {
this.adminUser = adminUser;
this.environmentBuilder.withAdminUser(adminUser);
return this;
}
withManagementPort(managementPort) {
this.environmentBuilder.withManagementPort(managementPort);
return this;
}
withManagementPath(managementPath) {
this.environmentBuilder.withManagementPath(managementPath);
return this;
}
withHostnamePath(path) {
this.environmentBuilder.withHostnamePath(path);
return this;
}
getCommands() {
return this.commandsBuilder.build();
}
getEnvironmentConfiguration() {
return this.environmentBuilder.build();
}
getAdminUser() {
return this.adminUser;
}
getPorts() {
return [
this.defaultPort,
this.environmentBuilder.getManagementPort()
];
}
}