Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tests/functional/ctst/common/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import { createKubeCustomObjectClient, waitForZenkoToStabilize } from 'steps/utils/kubernetes';
import { startDLQConsumer, stopDLQConsumer } from 'steps/utils/kafka';

import 'cli-testing/hooks/KeycloakSetup';
import 'cli-testing/hooks/Logger';

// HTTPS should not cause any error for CTST
Expand All @@ -42,7 +41,7 @@

setParallelCanAssign(noParallelRun);

BeforeAll(async function () {

Check warning on line 44 in tests/functional/ctst/common/hooks.ts

View workflow job for this annotation

GitHub Actions / lint-functional-tests

Unexpected function expression
const kafkaHosts = process.env['KAFKA_HOST_PORT'];
const dlqTopic = process.env['KAFKA_DEAD_LETTER_TOPIC'];
if (kafkaHosts && dlqTopic) {
Expand All @@ -50,7 +49,7 @@
}
});

AfterAll(async function () {

Check warning on line 52 in tests/functional/ctst/common/hooks.ts

View workflow job for this annotation

GitHub Actions / lint-functional-tests

Unexpected function expression
await stopDLQConsumer();
});

Expand Down
29 changes: 29 additions & 0 deletions tests/functional/ctst/common/hooksKeycloakSetup.ts
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { BeforeAll } from '@cucumber/cucumber';
import * as Werelogs from 'werelogs';
import { WorkCoordination } from 'cli-testing';
import Keycloak from 'steps/utils/keycloak';

BeforeAll({ name: 'keycloak setup' }, async () => {
const logger = new Werelogs.Logger('KeycloakSetup').newRequestLogger();

if (process.env.SEED_KEYCLOAK_DEFAULT_ROLES !== 'true') {
logger.info('Skipping Keycloak setup');
return;
}

await WorkCoordination.runOnceAcrossWorkers(
{ lockName: 'keycloak-seed', logger },
async () => {
logger.info('Starting Keycloak setup');
const keycloakSeeder = new Keycloak({
host: `https://${process.env.KEYCLOAK_HOST}`,
realm: `${process.env.KEYCLOAK_REALM}`,
username: process.env.KEYCLOAK_ADMIN_USERNAME || 'admin',
password: process.env.KEYCLOAK_ADMIN_PASSWORD || 'password',
clientId: process.env.KEYCLOAK_ADMIN_CLIENT_ID || 'admin-cli',
}, logger);
await keycloakSeeder.seedKeycloakWithDefaultRoles();
logger.info('Keycloak setup completed successfully');
},
);
});
Loading
Loading