-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: new permission system #5674
Changes from all commits
92aab41
19e16c7
b3eeb49
e409810
7ec3cf2
7530244
2804cc1
98e365b
42c9e0d
4b27eda
30a3aac
ffc5da3
2621e1d
bd281ae
43cc4b0
a32c98a
4db4825
ce7fda3
412d953
23c5328
c313a8e
19c2b33
1c04793
df433e9
c4f5262
f54397c
e622a4b
74eb597
1478383
a1c9536
fb456de
5583425
cc5a8bf
59a570c
4959256
109ec53
fadbe9e
c9f0cda
4b86af5
84550fa
bec8391
63dc998
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -495,19 +495,6 @@ export function initSeed() { | |
secret, | ||
); | ||
}, | ||
|
||
async updateSchemaVersionStatus(versionId: string, valid: boolean) { | ||
return await updateSchemaVersionStatus( | ||
{ | ||
organizationSlug: organization.slug, | ||
projectSlug: project.slug, | ||
targetSlug: target.slug, | ||
valid, | ||
versionId, | ||
}, | ||
secret, | ||
).then(r => r.expectNoGraphQLErrors()); | ||
}, | ||
async publishSchema(options: { | ||
sdl: string; | ||
headerName?: 'x-api-token' | 'authorization'; | ||
|
@@ -708,6 +695,22 @@ export function initSeed() { | |
|
||
return result.target?.schemaVersions.edges.map(edge => edge.node); | ||
}, | ||
async updateSchemaVersionStatus( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was never intended to run this via a registry access token, so I moved it to the project level and execute it with the organization owner token instead. |
||
versionId: string, | ||
valid: boolean, | ||
ttarget: TargetOverwrite = target, | ||
) { | ||
return await updateSchemaVersionStatus( | ||
{ | ||
organizationSlug: organization.slug, | ||
projectSlug: project.slug, | ||
targetSlug: ttarget.slug, | ||
valid, | ||
versionId, | ||
}, | ||
ownerToken, | ||
).then(r => r.expectNoGraphQLErrors()); | ||
}, | ||
}; | ||
}, | ||
async inviteAndJoinMember(inviteToken: string = ownerToken) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -662,7 +662,7 @@ describe('CDN token', () => { | |
expect(deleteResult).toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({ | ||
message: `No access (reason: "Missing target:settings permission")`, | ||
message: `No access (reason: "Missing permission for performing 'cdnAccessToken:delete' on resource")`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we now have granular permissions the messages changed slightly. We do not have any logic that depends on the message contents, except integration test fixtures. |
||
}), | ||
]), | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,76 +4,6 @@ import { execute } from '../../../testkit/graphql'; | |
import { initSeed } from '../../../testkit/seed'; | ||
|
||
describe('Policy Access', () => { | ||
describe('Target', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. deleted as unused. |
||
const query = graphql(` | ||
query TargetSchemaPolicyAccess($selector: TargetSelectorInput!) { | ||
target(selector: $selector) { | ||
schemaPolicy { | ||
mergedRules { | ||
severity | ||
} | ||
} | ||
} | ||
} | ||
`); | ||
|
||
test.concurrent( | ||
'should successfully fetch Target.schemaPolicy if the user has access to SETTINGS', | ||
async ({ expect }) => { | ||
const { createOrg } = await initSeed().createOwner(); | ||
const { organization, createProject, inviteAndJoinMember } = await createOrg(); | ||
const { project, target } = await createProject(ProjectType.Single); | ||
const adminRole = organization.memberRoles.find(r => r.name === 'Admin'); | ||
|
||
if (!adminRole) { | ||
throw new Error('Admin role not found'); | ||
} | ||
|
||
const { member, memberToken, assignMemberRole } = await inviteAndJoinMember(); | ||
await assignMemberRole({ | ||
roleId: adminRole.id, | ||
userId: member.user.id, | ||
}); | ||
|
||
const result = await execute({ | ||
document: query, | ||
variables: { | ||
selector: { | ||
organizationSlug: organization.slug, | ||
projectSlug: project.slug, | ||
targetSlug: target.slug, | ||
}, | ||
}, | ||
authToken: memberToken, | ||
}).then(r => r.expectNoGraphQLErrors()); | ||
|
||
expect(result.target?.schemaPolicy?.mergedRules).not.toBeNull(); | ||
}, | ||
); | ||
|
||
test.concurrent( | ||
'should fail to fetch Target.schemaPolicy if the user lacks access to SETTINGS', | ||
async ({ expect }) => { | ||
const { createOrg } = await initSeed().createOwner(); | ||
const { organization, createProject, inviteAndJoinMember } = await createOrg(); | ||
const { project, target } = await createProject(ProjectType.Single); | ||
const { memberToken } = await inviteAndJoinMember(); | ||
|
||
await execute({ | ||
document: query, | ||
variables: { | ||
selector: { | ||
organizationSlug: organization.slug, | ||
projectSlug: project.slug, | ||
targetSlug: target.slug, | ||
}, | ||
}, | ||
authToken: memberToken, | ||
}).then(r => r.expectGraphQLErrors()); | ||
}, | ||
); | ||
}); | ||
|
||
describe('Project', () => { | ||
const query = graphql(` | ||
query ProjectSchemaPolicyAccess($selector: ProjectSelectorInput!) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am deleting all this stuff since it is not used by the app anyways and I wanted to avoid having to update the permission checks for these.