@@ -8,6 +8,7 @@ import { createHive } from '@graphql-hive/core';
88import { psql } from '@hive/postgres' ;
99import { clickHouseInsert } from '../../testkit/clickhouse' ;
1010import { graphql } from '../../testkit/gql' ;
11+ import { ResourceAssignmentModeType } from '../../testkit/gql/graphql' ;
1112import { execute } from '../../testkit/graphql' ;
1213
1314const CreateAppDeployment = graphql ( `
@@ -1742,8 +1743,9 @@ test('retire app deployments fails without feature flag enabled for organization
17421743} ) ;
17431744
17441745test ( 'get app deployment documents via GraphQL API' , async ( ) => {
1745- const { createOrg, ownerToken } = await initSeed ( ) . createOwner ( ) ;
1746- const { createProject, setFeatureFlag, organization } = await createOrg ( ) ;
1746+ const { createOrg } = await initSeed ( ) . createOwner ( ) ;
1747+ const { createProject, setFeatureFlag, organization, createOrganizationAccessToken } =
1748+ await createOrg ( ) ;
17471749 await setFeatureFlag ( 'appDeployments' , true ) ;
17481750 const { createTargetAccessToken, project, target } = await createProject ( ) ;
17491751 const token = await createTargetAccessToken ( { } ) ;
@@ -1771,12 +1773,23 @@ test('get app deployment documents via GraphQL API', async () => {
17711773 ` ,
17721774 } ) ;
17731775
1776+ // Ensure this is possible with the minimal available permissions.
1777+ const organizationAccessToken = await createOrganizationAccessToken ( {
1778+ permissions : [ 'appDeployment:create' ] ,
1779+ resources : {
1780+ mode : ResourceAssignmentModeType . All ,
1781+ } ,
1782+ } ) ;
1783+
17741784 const { addDocumentsToAppDeployment } = await execute ( {
17751785 document : AddDocumentsToAppDeployment ,
17761786 variables : {
17771787 input : {
17781788 appName : 'app-name' ,
17791789 appVersion : 'app-version' ,
1790+ target : {
1791+ byId : target . id ,
1792+ } ,
17801793 documents : [
17811794 {
17821795 hash : 'aaa' ,
@@ -1797,7 +1810,7 @@ test('get app deployment documents via GraphQL API', async () => {
17971810 ] ,
17981811 } ,
17991812 } ,
1800- authToken : token . secret ,
1813+ authToken : organizationAccessToken . privateAccessKey ,
18011814 } ) . then ( res => res . expectNoGraphQLErrors ( ) ) ;
18021815 expect ( addDocumentsToAppDeployment . error ) . toBeNull ( ) ;
18031816
@@ -1812,7 +1825,7 @@ test('get app deployment documents via GraphQL API', async () => {
18121825 appDeploymentName : 'app-name' ,
18131826 appDeploymentVersion : 'app-version' ,
18141827 } ,
1815- authToken : ownerToken ,
1828+ authToken : token . secret ,
18161829 } ) . then ( res => res . expectNoGraphQLErrors ( ) ) ;
18171830 expect ( result . target ) . toMatchObject ( {
18181831 appDeployment : {
0 commit comments