Rename listSaasGroups -> listDescendantGroups
Signed-off-by: Stephen Barry <sbarry@poppulo.com>
This commit is contained in:
@@ -575,12 +575,12 @@ describe('GitLabClient', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('listSaasGroups', () => {
|
||||
describe('listDescendantGroups', () => {
|
||||
it('gets all groups under root', async () => {
|
||||
server.use(
|
||||
graphql
|
||||
.link(`${MOCK_CONFIG.baseUrl}/api/graphql`)
|
||||
.query('listSaasGroups', async (_, res, ctx) =>
|
||||
.query('listDescendantGroups', async (_, res, ctx) =>
|
||||
res(
|
||||
ctx.data({
|
||||
group: {
|
||||
@@ -611,7 +611,7 @@ describe('GitLabClient', () => {
|
||||
logger: getVoidLogger(),
|
||||
});
|
||||
|
||||
const saasGroups = (await client.listSaasGroups('group1')).items;
|
||||
const saasGroups = (await client.listDescendantGroups('group1')).items;
|
||||
|
||||
const expectedSaasGroup = [
|
||||
{
|
||||
@@ -631,7 +631,7 @@ describe('GitLabClient', () => {
|
||||
server.use(
|
||||
graphql
|
||||
.link(`${MOCK_CONFIG.baseUrl}/api/graphql`)
|
||||
.query('listSaasGroups', async (_, res, ctx) =>
|
||||
.query('listDescendantGroups', async (_, res, ctx) =>
|
||||
res(
|
||||
ctx.data({
|
||||
group: {},
|
||||
@@ -644,7 +644,7 @@ describe('GitLabClient', () => {
|
||||
logger: getVoidLogger(),
|
||||
});
|
||||
|
||||
const saasGroups = (await client.listSaasGroups('group1')).items;
|
||||
const saasGroups = (await client.listDescendantGroups('group1')).items;
|
||||
|
||||
expect(saasGroups).toEqual([]);
|
||||
});
|
||||
@@ -653,7 +653,7 @@ describe('GitLabClient', () => {
|
||||
server.use(
|
||||
graphql
|
||||
.link(`${MOCK_CONFIG.baseUrl}/api/graphql`)
|
||||
.query('listSaasGroups', async (_, res, ctx) =>
|
||||
.query('listDescendantGroups', async (_, res, ctx) =>
|
||||
res(
|
||||
ctx.errors([
|
||||
{ message: 'Unexpected end of document', locations: [] },
|
||||
@@ -666,7 +666,7 @@ describe('GitLabClient', () => {
|
||||
logger: getVoidLogger(),
|
||||
});
|
||||
|
||||
await expect(() => client.listSaasGroups('group1')).rejects.toThrow(
|
||||
await expect(() => client.listDescendantGroups('group1')).rejects.toThrow(
|
||||
'GraphQL errors: [{"message":"Unexpected end of document","locations":[]}]',
|
||||
);
|
||||
});
|
||||
@@ -674,7 +674,7 @@ describe('GitLabClient', () => {
|
||||
server.use(
|
||||
graphql
|
||||
.link(`${MOCK_CONFIG.baseUrl}/api/graphql`)
|
||||
.query('listSaasGroups', async (req, res, ctx) =>
|
||||
.query('listDescendantGroups', async (req, res, ctx) =>
|
||||
res(
|
||||
ctx.data({
|
||||
group: {
|
||||
@@ -717,7 +717,7 @@ describe('GitLabClient', () => {
|
||||
logger: getVoidLogger(),
|
||||
});
|
||||
|
||||
const saasGroups = (await client.listSaasGroups('root')).items;
|
||||
const saasGroups = (await client.listDescendantGroups('root')).items;
|
||||
|
||||
const expectedSaasGroup1 = {
|
||||
id: 1,
|
||||
|
||||
@@ -22,7 +22,6 @@ import {
|
||||
import { Logger } from 'winston';
|
||||
import {
|
||||
GitLabGroup,
|
||||
GitLabSaasUsersResponse,
|
||||
GitLabSaasGroupsResponse,
|
||||
GitLabGroupMembersResponse,
|
||||
GitLabUser,
|
||||
@@ -103,7 +102,7 @@ export class GitLabClient {
|
||||
let endCursor: string | null = null;
|
||||
|
||||
do {
|
||||
const response: GitLabSaasUsersResponse = await fetch(
|
||||
const response: GitLabGroupMembersResponse = await fetch(
|
||||
`${this.config.baseUrl}/api/graphql`,
|
||||
{
|
||||
method: 'POST',
|
||||
@@ -170,7 +169,9 @@ export class GitLabClient {
|
||||
return { items };
|
||||
}
|
||||
|
||||
async listSaasGroups(groupPath: string): Promise<PagedResponse<GitLabGroup>> {
|
||||
async listDescendantGroups(
|
||||
groupPath: string,
|
||||
): Promise<PagedResponse<GitLabGroup>> {
|
||||
const items: GitLabGroup[] = [];
|
||||
let hasNextPage: boolean = false;
|
||||
let endCursor: string | null = null;
|
||||
@@ -186,7 +187,7 @@ export class GitLabClient {
|
||||
},
|
||||
body: JSON.stringify({
|
||||
variables: { group: groupPath, endCursor },
|
||||
query: `query listSaasGroups($group: ID!, $endCursor: String) {
|
||||
query: `query listDescendantGroups($group: ID!, $endCursor: String) {
|
||||
group(fullPath: $group) {
|
||||
descendantGroups(first: 100, after: $endCursor){
|
||||
nodes{
|
||||
|
||||
+1
-1
@@ -514,7 +514,7 @@ describe('GitlabOrgDiscoveryEntityProvider', () => {
|
||||
server.use(
|
||||
graphql
|
||||
.link('https://gitlab.com/api/graphql')
|
||||
.query('listSaasGroups', async (_, res, ctx) =>
|
||||
.query('listDescendantGroups', async (_, res, ctx) =>
|
||||
res(
|
||||
ctx.data({
|
||||
group: {
|
||||
|
||||
+1
-1
@@ -189,7 +189,7 @@ export class GitlabOrgDiscoveryEntityProvider implements EntityProvider {
|
||||
active: true,
|
||||
});
|
||||
} else {
|
||||
groups = (await client.listSaasGroups(this.config.group)).items;
|
||||
groups = (await client.listDescendantGroups(this.config.group)).items;
|
||||
users = (await client.listSaasUsers(this.config.group.split('/')[0]))
|
||||
.items;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user