Skip to content

Commit a3ba6cc

Browse files
authored
fix: app deployment publish permissions (#8042)
1 parent 63e6827 commit a3ba6cc

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

integration-tests/tests/api/app-deployments.spec.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { createHive } from '@graphql-hive/core';
88
import { psql } from '@hive/postgres';
99
import { clickHouseInsert } from '../../testkit/clickhouse';
1010
import { graphql } from '../../testkit/gql';
11+
import { ResourceAssignmentModeType } from '../../testkit/gql/graphql';
1112
import { execute } from '../../testkit/graphql';
1213

1314
const CreateAppDeployment = graphql(`
@@ -1742,8 +1743,9 @@ test('retire app deployments fails without feature flag enabled for organization
17421743
});
17431744

17441745
test('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: {

packages/services/api/src/modules/app-deployments/providers/app-deployments-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export class AppDeploymentsManager {
124124
},
125125
});
126126

127-
const target = await this.targetManager.getTarget(selector);
127+
const target = await this.targetManager.getTargetById(selector);
128128

129129
return await this.appDeployments.addDocumentsToAppDeployment({
130130
target,

0 commit comments

Comments
 (0)