keycloak-testcontainer
Version:
Run a Keycloak testcontainer with node.js
27 lines (26 loc) • 1.39 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import { AbstractStartedContainer } from 'testcontainers';
import initAdminClient from './admin.js';
export class StartedKeycloakContainer extends AbstractStartedContainer {
constructor(startedTestContainer, adminUser) {
super(startedTestContainer);
this.adminUser = adminUser;
}
getAdminClient(options) {
return __awaiter(this, void 0, void 0, function* () {
if (!options) {
const defaultOptions = { baseUrl: `http://localhost:${this.getFirstMappedPort()}` };
return yield initAdminClient(defaultOptions, this.adminUser);
}
return yield initAdminClient(options, this.adminUser);
});
}
}