mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 02:54:20 +00:00
23 lines
671 B
TypeScript
23 lines
671 B
TypeScript
|
import { ensureItemExists } from './ensure';
|
||
|
import { getOrgUnderTest } from './orgs';
|
||
|
import { API } from './types';
|
||
|
|
||
|
export function ensureProjectGrantExists(
|
||
|
api: API,
|
||
|
foreignOrgId: number,
|
||
|
foreignProjectId: number,
|
||
|
): Cypress.Chainable<number> {
|
||
|
return getOrgUnderTest(api).then((orgUnderTest) => {
|
||
|
return ensureItemExists(
|
||
|
api,
|
||
|
`${api.mgmtBaseURL}/projectgrants/_search`,
|
||
|
(grant: any) => grant.grantedOrgId == orgUnderTest && grant.projectId == foreignProjectId,
|
||
|
`${api.mgmtBaseURL}/projects/${foreignProjectId}/grants`,
|
||
|
{ granted_org_id: orgUnderTest },
|
||
|
foreignOrgId,
|
||
|
'grantId',
|
||
|
'grantId',
|
||
|
);
|
||
|
});
|
||
|
}
|