extend filter logic to include parent group

Signed-off-by: Hghtwr <johannes.sonner@outlook.com>
This commit is contained in:
Hghtwr
2024-11-10 21:19:09 +01:00
parent 0d5d4215ac
commit bbfd6bc8ff
2 changed files with 26 additions and 2 deletions
@@ -2347,7 +2347,7 @@ export const expected_full_members_group_org_scan_entities: MockObject[] = [
name: 'JohnDoe',
},
spec: {
memberOf: ['subgroup1'],
memberOf: ['group1', 'subgroup1'], // since #26554 also config.group needs to be here.
profile: {
displayName: 'John Doe',
email: 'john.doe@company.com',
@@ -2431,6 +2431,29 @@ export const expected_full_members_group_org_scan_entities: MockObject[] = [
},
locationKey: 'GitlabOrgDiscoveryEntityProvider:test-id',
},
{
entity: {
apiVersion: 'backstage.io/v1alpha1',
kind: 'Group',
metadata: {
annotations: {
'backstage.io/managed-by-location': 'url:https://example.com/group1',
'backstage.io/managed-by-origin-location':
'url:https://example.com/group1',
'example.com/team-path': 'group1',
},
name: 'group1',
},
spec: {
children: [],
profile: {
displayName: 'group1',
},
type: 'team',
},
},
locationKey: 'GitlabOrgDiscoveryEntityProvider:test-id',
},
{
entity: {
apiVersion: 'backstage.io/v1alpha1',
@@ -775,7 +775,8 @@ export class GitlabOrgDiscoveryEntityProvider implements EntityProvider {
return (
this.config.groupPattern.test(group.full_path) &&
(!this.config.group ||
group.full_path.startsWith(`${this.config.group}/`))
group.full_path.startsWith(`${this.config.group}/`) ||
group.full_path === this.config.group)
);
}