@red-hat-developer-hub/e2e-test-utils 1.1.16 → 1.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/deployment/keycloak/deployment.d.ts +18 -0
- package/dist/deployment/keycloak/deployment.d.ts.map +1 -1
- package/dist/deployment/keycloak/deployment.js +50 -0
- package/dist/deployment/keycloak/index.d.ts +1 -0
- package/dist/deployment/keycloak/index.d.ts.map +1 -1
- package/dist/utils/common.d.ts +2 -1
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/common.js +9 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -1
- package/package.json +6 -2
|
@@ -46,6 +46,13 @@ export declare class KeycloakHelper {
|
|
|
46
46
|
* Create a user in a realm with optional group membership
|
|
47
47
|
*/
|
|
48
48
|
createUser(realm: string, config: KeycloakUserConfig): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Create users and groups in a realm.
|
|
51
|
+
*/
|
|
52
|
+
createUsersAndGroups(realm: string, options: {
|
|
53
|
+
users?: KeycloakUserConfig[];
|
|
54
|
+
groups?: KeycloakGroupConfig[];
|
|
55
|
+
}): Promise<void>;
|
|
49
56
|
/**
|
|
50
57
|
* Get all users in a realm
|
|
51
58
|
*/
|
|
@@ -54,6 +61,10 @@ export declare class KeycloakHelper {
|
|
|
54
61
|
* Get all groups in a realm
|
|
55
62
|
*/
|
|
56
63
|
getGroups(realm: string): Promise<KeycloakGroupConfig[]>;
|
|
64
|
+
/**
|
|
65
|
+
* Get groups for a user in a realm (user resolved by username).
|
|
66
|
+
*/
|
|
67
|
+
getGroupsOfUser(realm: string, username: string): Promise<KeycloakGroupConfig[]>;
|
|
57
68
|
/**
|
|
58
69
|
* Delete a user from a realm
|
|
59
70
|
*/
|
|
@@ -62,6 +73,13 @@ export declare class KeycloakHelper {
|
|
|
62
73
|
* Delete a group from a realm
|
|
63
74
|
*/
|
|
64
75
|
deleteGroup(realm: string, groupName: string): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Delete users and groups from a realm.
|
|
78
|
+
*/
|
|
79
|
+
deleteUsersAndGroups(realm: string, options: {
|
|
80
|
+
users?: Array<KeycloakUserConfig | string>;
|
|
81
|
+
groups?: Array<KeycloakGroupConfig | string>;
|
|
82
|
+
}): Promise<void>;
|
|
65
83
|
/**
|
|
66
84
|
* Delete a realm
|
|
67
85
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deployment.d.ts","sourceRoot":"","sources":["../../../src/deployment/keycloak/deployment.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAY1E,OAAO,KAAK,EACV,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AAEpB,qBAAa,cAAc;IAClB,SAAS,yBAAgC;IACzC,gBAAgB,EAAE,wBAAwB,CAAC;IAC3C,WAAW,EAAE,MAAM,CAAM;IACzB,KAAK,EAAE,MAAM,CAAM;IACnB,QAAQ,EAAE,MAAM,CAAM;IACtB,YAAY,EAAE,MAAM,CAAM;IACjC,OAAO,CAAC,YAAY,CAAoC;gBAE5C,OAAO,GAAE,yBAA8B;IAInD;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAa7B;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAUnC;;OAEG;IACG,gBAAgB,CAAC,OAAO,CAAC,EAAE;QAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;QACvC,MAAM,CAAC,EAAE,mBAAmB,EAAE,CAAC;QAC/B,KAAK,CAAC,EAAE,kBAAkB,EAAE,CAAC;KAC9B,GAAG,OAAO,CAAC,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users and groups in a realm.
|
|
225
|
+
*/
|
|
226
|
+
async createUsersAndGroups(realm, options) {
|
|
227
|
+
await this._ensureAdminClient();
|
|
228
|
+
const { groups = [], users = [] } = options;
|
|
229
|
+
for (const group of groups) {
|
|
230
|
+
await this.createGroup(realm, group);
|
|
231
|
+
}
|
|
232
|
+
for (const user of users) {
|
|
233
|
+
await this.createUser(realm, user);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
223
236
|
/**
|
|
224
237
|
* Get all users in a realm
|
|
225
238
|
*/
|
|
@@ -245,10 +258,29 @@ export class KeycloakHelper {
|
|
|
245
258
|
const groups = await this._adminClient.groups.find();
|
|
246
259
|
return groups.map((g) => ({ name: g.name }));
|
|
247
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* Get groups for a user in a realm (user resolved by username).
|
|
263
|
+
*/
|
|
264
|
+
async getGroupsOfUser(realm, username) {
|
|
265
|
+
await this._ensureAdminClient();
|
|
266
|
+
this._adminClient.setConfig({ realmName: realm });
|
|
267
|
+
const users = await this._adminClient.users.find({ username });
|
|
268
|
+
if (users.length === 0) {
|
|
269
|
+
return [];
|
|
270
|
+
}
|
|
271
|
+
const user = users[0];
|
|
272
|
+
const groups = await this._adminClient.users.listGroups({
|
|
273
|
+
id: user.id,
|
|
274
|
+
});
|
|
275
|
+
return groups.map((g) => ({ name: g.name }));
|
|
276
|
+
}
|
|
248
277
|
/**
|
|
249
278
|
* Delete a user from a realm
|
|
250
279
|
*/
|
|
251
280
|
async deleteUser(realm, username) {
|
|
281
|
+
if (DEFAULT_USERS.some((u) => u.username === username)) {
|
|
282
|
+
throw new Error(`Deleting default Keycloak user "${username}" is not permitted.`);
|
|
283
|
+
}
|
|
252
284
|
await this._ensureAdminClient();
|
|
253
285
|
this._adminClient.setConfig({ realmName: realm });
|
|
254
286
|
const users = await this._adminClient.users.find({ username });
|
|
@@ -261,6 +293,9 @@ export class KeycloakHelper {
|
|
|
261
293
|
* Delete a group from a realm
|
|
262
294
|
*/
|
|
263
295
|
async deleteGroup(realm, groupName) {
|
|
296
|
+
if (DEFAULT_GROUPS.some((g) => g.name === groupName)) {
|
|
297
|
+
throw new Error(`Deleting default Keycloak group "${groupName}" is not permitted.`);
|
|
298
|
+
}
|
|
264
299
|
await this._ensureAdminClient();
|
|
265
300
|
this._adminClient.setConfig({ realmName: realm });
|
|
266
301
|
const groups = await this._adminClient.groups.find({ search: groupName });
|
|
@@ -270,6 +305,21 @@ export class KeycloakHelper {
|
|
|
270
305
|
this._log(`Deleted group: ${groupName}`);
|
|
271
306
|
}
|
|
272
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* Delete users and groups from a realm.
|
|
310
|
+
*/
|
|
311
|
+
async deleteUsersAndGroups(realm, options) {
|
|
312
|
+
await this._ensureAdminClient();
|
|
313
|
+
const { groups = [], users = [] } = options;
|
|
314
|
+
const usernames = users.map((u) => typeof u === "string" ? u : u.username);
|
|
315
|
+
const groupNames = groups.map((g) => (typeof g === "string" ? g : g.name));
|
|
316
|
+
for (const username of usernames) {
|
|
317
|
+
await this.deleteUser(realm, username);
|
|
318
|
+
}
|
|
319
|
+
for (const groupName of groupNames) {
|
|
320
|
+
await this.deleteGroup(realm, groupName);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
273
323
|
/**
|
|
274
324
|
* Delete a realm
|
|
275
325
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/deployment/keycloak/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/deployment/keycloak/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,YAAY,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/utils/common.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/utils/common.ts"],"names":[],"mappings":"AAAA,iBAAS,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,oBAAc,UAS/C;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/utils/common.ts"],"names":[],"mappings":"AAAA,iBAAS,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,oBAAc,UAS/C;AAED,iBAAS,UAAU,CAAC,GAAG,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,GAAG,IAAI,CAO5D;AAED,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC"}
|
package/dist/utils/common.js
CHANGED
|
@@ -5,4 +5,12 @@ function envsubst(str, env = process.env) {
|
|
|
5
5
|
});
|
|
6
6
|
return out;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
function requireEnv(...varNames) {
|
|
9
|
+
for (const varName of varNames) {
|
|
10
|
+
const value = process.env[varName];
|
|
11
|
+
if (!value) {
|
|
12
|
+
throw new Error(`Required variable ${varName} is not set`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export { envsubst, requireEnv };
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { envsubst } from "./common.js";
|
|
1
|
+
export { envsubst, requireEnv } from "./common.js";
|
|
2
2
|
export { $, runQuietUnlessFailure } from "./bash.js";
|
|
3
3
|
export { mergeYamlFiles, mergeYamlFilesIfExists, mergeYamlFilesToFile, } from "./merge-yamls.js";
|
|
4
4
|
export { KubernetesClientHelper } from "./kubernetes-client.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,CAAC,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { envsubst } from "./common.js";
|
|
1
|
+
export { envsubst, requireEnv } from "./common.js";
|
|
2
2
|
export { $, runQuietUnlessFailure } from "./bash.js";
|
|
3
3
|
export { mergeYamlFiles, mergeYamlFilesIfExists, mergeYamlFilesToFile, } from "./merge-yamls.js";
|
|
4
4
|
export { KubernetesClientHelper } from "./kubernetes-client.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@red-hat-developer-hub/e2e-test-utils",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.18",
|
|
4
4
|
"description": "Test utilities for RHDH E2E tests",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
],
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build": "yarn clean && tsc -p tsconfig.build.json && cp -r src/deployment/rhdh/config dist/deployment/rhdh/ && cp -r src/deployment/keycloak/config dist/deployment/keycloak/",
|
|
62
|
+
"prepare": "husky",
|
|
62
63
|
"check": "yarn typecheck && yarn lint:check && yarn prettier:check",
|
|
63
64
|
"clean": "rm -rf dist",
|
|
64
65
|
"lint:check": "eslint . --ignore-pattern dist --ignore-pattern README.md --ignore-pattern docs",
|
|
@@ -90,7 +91,10 @@
|
|
|
90
91
|
"@types/lodash.clonedeepwith": "^4.5.9",
|
|
91
92
|
"@types/lodash.mergewith": "^4.6.9",
|
|
92
93
|
"@types/node": "^24.10.1",
|
|
93
|
-
"@types/proper-lockfile": "^4.1.4"
|
|
94
|
+
"@types/proper-lockfile": "^4.1.4",
|
|
95
|
+
"husky": "^9.1.7",
|
|
96
|
+
"lint-staged": "^15.4.3",
|
|
97
|
+
"markdown-link-check": "^3.13.6"
|
|
94
98
|
},
|
|
95
99
|
"dependencies": {
|
|
96
100
|
"@axe-core/playwright": "^4.11.0",
|