2023-02-15 01:52:11 +00:00
|
|
|
import { Context } from 'support/commands';
|
2022-10-11 13:29:23 +00:00
|
|
|
import { ensureItemExists } from './ensure';
|
|
|
|
import { getOrgUnderTest } from './orgs';
|
|
|
|
|
2023-02-15 01:52:11 +00:00
|
|
|
export function ensureProjectGrantExists(ctx: Context, foreignOrgId: string, foreignProjectId: string) {
|
|
|
|
return getOrgUnderTest(ctx).then((orgUnderTest) => {
|
2022-10-11 13:29:23 +00:00
|
|
|
return ensureItemExists(
|
2023-02-15 01:52:11 +00:00
|
|
|
ctx.api,
|
|
|
|
`${ctx.api.mgmtBaseURL}/projectgrants/_search`,
|
2022-10-11 13:29:23 +00:00
|
|
|
(grant: any) => grant.grantedOrgId == orgUnderTest && grant.projectId == foreignProjectId,
|
2023-02-15 01:52:11 +00:00
|
|
|
`${ctx.api.mgmtBaseURL}/projects/${foreignProjectId}/grants`,
|
2022-10-11 13:29:23 +00:00
|
|
|
{ granted_org_id: orgUnderTest },
|
|
|
|
foreignOrgId,
|
|
|
|
'grantId',
|
|
|
|
'grantId',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|