test: fix keycloak realm import
Some checks failed
Flake checks / Check (pull_request) Failing after 2m45s

This commit is contained in:
b12f 2024-08-27 15:16:57 +02:00
parent dec2d76d2a
commit 9bba502b46
Signed by: b12f
GPG key ID: 729956E1124F8F26
3 changed files with 286 additions and 301 deletions

View file

@ -57,10 +57,6 @@ in
database-password-file = "/tmp/dbf";
};
services.keycloak.database.createLocally = true;
services.keycloak.extraStartupFlags = [
"--import-realm"
"--file=${realm-export}"
];
networking.interfaces.eth0.ipv4.addresses = [
{
@ -81,12 +77,43 @@ in
nachtigall.wait_for_unit("system.slice")
nachtigall.succeed("ping 127.0.0.1 -c 2")
nachtigall.wait_for_unit("nginx.service")
nachtigall.wait_for_unit("keycloak.service")
nachtigall.systemctl("stop keycloak.service")
nachtigall.wait_until_succeeds("if (($(ps aux | grep 'Dkc.home.dir=/run/keycloak' | grep -v grep | wc -l) == 0)); then true; else false; fi")
nachtigall.succeed("${pkgs.keycloak}/bin/kc.sh --verbose import --optimized --file=${realm-export}")
nachtigall.systemctl("start keycloak.service")
nachtigall.sleep(30)
nachtigall.wait_until_succeeds("curl http://127.0.0.1:8080/")
nachtigall.wait_until_succeeds("curl https://auth.test.pub.solar/")
client.wait_for_unit("system.slice")
client.wait_for_file("/tmp/puppeteer.sock")
puppeteer_run('page.goto("https://auth.test.pub.solar/admin/master/console")')
puppeteer_run('page.waitForNetworkIdle()')
client.screenshot("admin-initial")
puppeteer_run('page.locator("[name=username]").fill("admin")')
puppeteer_run('page.locator("::-p-text(Sign In)").click()')
puppeteer_run('page.waitForNetworkIdle()')
client.screenshot("admin-password")
puppeteer_run('page.locator("[name=password]").fill("password")')
puppeteer_run('page.locator("::-p-text(Sign In)").click()')
puppeteer_run('page.waitForNetworkIdle()')
client.screenshot("admin-login")
puppeteer_run('page.locator("::-p-text(Realm settings)").click()')
puppeteer_run('page.waitForNetworkIdle()')
client.screenshot("admin-theme")
puppeteer_run('page.locator("::-p-text(Themes)").click()')
puppeteer_run('page.waitForNetworkIdle()')
puppeteer_run('page.locator("#kc-login-theme").click()')
client.screenshot("admin-theme-changed")
puppeteer_run('page.locator("li button::-p-text(pub.solar)").click()')
puppeteer_run('page.locator("::-p-text(Save)").click()')
puppeteer_run('page.waitForNetworkIdle()')
client.screenshot("admin-theme-saved")
puppeteer_run('page.goto("https://auth.test.pub.solar")')
puppeteer_run('page.waitForNetworkIdle()')
client.screenshot("initial")

File diff suppressed because it is too large Load diff

View file

@ -14,10 +14,11 @@ const ID_KEYS = [
const renameDomain = (s) => s.replace(/pub.solar/g, 'test.pub.solar');
const changeClientSecrets = (data) => ({
const cleanClients = (data) => ({
...data,
clients: data.clients.map(c => ({
...c,
authorizationSettings: undefined,
...(c.secret ? {
secret: 'secret',
attributes: {
@ -63,7 +64,7 @@ const changeIds = (node) => {
const fileContents = await readFile(filePath, { encoding: 'utf8' });
const data = JSON.parse(renameDomain(fileContents));
const newData = changeIds(changeClientSecrets(data));
const newData = changeIds(cleanClients(data));
console.log(JSON.stringify(newData, null, 2));
})();