add handler for encoded groups, implement test cases
Signed-off-by: Hghtwr <johannes.sonner@outlook.com>
This commit is contained in:
@@ -144,6 +144,21 @@ const httpHandlers = [
|
||||
|
||||
// dynamic handlers
|
||||
|
||||
const httpGroupFindByEncodedPathDynamic = all_groups_response.flatMap(group => [
|
||||
// Handler for apiBaseUrl
|
||||
rest.get(`${apiBaseUrl}/groups/${group.full_path}`, (_, res, ctx) => {
|
||||
return res(
|
||||
ctx.json(all_groups_response.find(g => g.full_path === group.full_path)),
|
||||
);
|
||||
}),
|
||||
// Handler for apiSaaSBaseUrl
|
||||
rest.get(`${apiBaseUrlSaas}/groups/${group.full_path}`, (_, res, ctx) => {
|
||||
return res(
|
||||
ctx.json(all_groups_response.find(g => g.full_path === group.full_path)),
|
||||
);
|
||||
}),
|
||||
]);
|
||||
|
||||
const httpGroupFindByIdDynamic = all_groups_response.map(group => {
|
||||
return rest.get(`${apiBaseUrl}/groups/${group.id}`, (_, res, ctx) => {
|
||||
return res(ctx.json(all_groups_response.find(g => g.id === group.id)));
|
||||
@@ -491,7 +506,7 @@ const graphqlHandlers = [
|
||||
{
|
||||
id: 'gid://gitlab/Group/1',
|
||||
name: 'group1',
|
||||
description: 'description1',
|
||||
description: '',
|
||||
fullPath: 'path/group1',
|
||||
parent: {
|
||||
id: '123',
|
||||
@@ -626,4 +641,5 @@ export const handlers = [
|
||||
...httpGroupListDescendantProjectsById,
|
||||
...httpGroupListDescendantProjectsByName,
|
||||
...graphqlHandlers,
|
||||
...httpGroupFindByEncodedPathDynamic,
|
||||
];
|
||||
|
||||
@@ -170,10 +170,7 @@ export class GitLabClient {
|
||||
groupPath: string,
|
||||
options?: CommonListOptions,
|
||||
): Promise<GitLabGroup> {
|
||||
return this.nonPagedRequest(
|
||||
`/groups/${encodeURIComponent(groupPath)}`,
|
||||
options,
|
||||
);
|
||||
return this.nonPagedRequest(`/groups/${groupPath}`, options);
|
||||
}
|
||||
|
||||
async listDescendantGroups(
|
||||
|
||||
+1
-1
@@ -435,7 +435,7 @@ describe('GitlabOrgDiscoveryEntityProvider - refresh', () => {
|
||||
});
|
||||
|
||||
// This should return all members of the self-hosted instance regardless of the group set -> expected_full_members_group_org_scan_entities
|
||||
// All instance members, but only the group entities below the config.group
|
||||
// All instance members, but only the group entities of config.group and below (#26554)
|
||||
it('Self-hosted: should get all instance users when restrictUsersToGroup is not set', async () => {
|
||||
const config = new ConfigReader(mock.config_org_group_selfHosted);
|
||||
const schedule = new PersistingTaskRunner();
|
||||
|
||||
+2
@@ -396,7 +396,9 @@ export class GitlabOrgDiscoveryEntityProvider implements EntityProvider {
|
||||
else {
|
||||
groups = (await this.gitLabClient.listDescendantGroups(this.config.group))
|
||||
.items;
|
||||
|
||||
groups.push(await this.gitLabClient.getGroupByPath(this.config.group));
|
||||
|
||||
const rootGroupSplit = this.config.group.split('/');
|
||||
const rootGroup = this.config.restrictUsersToGroup
|
||||
? rootGroupSplit[rootGroupSplit.length - 1]
|
||||
|
||||
Reference in New Issue
Block a user