Skip to content
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

DEVPROD-3065: Update directive to handle SetLastRevision permission #7689

Merged
merged 9 commits into from
Apr 5, 2024

Conversation

SupaJoon
Copy link
Contributor

@SupaJoon SupaJoon commented Mar 27, 2024

DEVPROD-3065

Description

SetLastRevision requires "edit project" permissions based on legacy code.
This mutation should always fail when dispatched from Spruce but it passes in during GQL integration tests and local EVG GQL playground. I think we discovered this before but I'm failing to find the ticket.

@SupaJoon SupaJoon requested review from a team March 27, 2024 21:44
Copy link
Contributor

@hadjri hadjri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we verify this in staging too?

@@ -136,6 +138,29 @@ func New(apiURL string) Config {
}
}

if operationContext == SetLastRevisionMutation {
projectIdentifier, ok := args["opts"].(map[string]interface{})["projectIdentifier"].(string)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just retrieve the project ID directly from the request or is that not possible?

Copy link
Contributor Author

@SupaJoon SupaJoon Apr 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you show me which data structure you're referring to? "opts" refers to the mutation parameter where the directive was applied.

graphql/directive_test.go Outdated Show resolved Hide resolved
Comment on lines 153 to 157
opts := gimlet.PermissionOpts{
Resource: project.Id,
ResourceType: evergreen.ProjectResourceType,
Permission: evergreen.PermissionProjectSettings,
RequiredLevel: evergreen.ProjectSettingsEdit.Value,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these opts are shared by CopyProjectMutation, DeleteProjectMutation and SetLastRevisionMutation, I wonder if we can refactor a bit to make it less repetitive. I imagine CreateProjectMutation might eventually belong in a different directive like how the legacy UI does it

@minnakt minnakt changed the title DEVPROD-3065: Update directive to handle SetLastRevison permission DEVPROD-3065: Update directive to handle SetLastRevision permission Mar 29, 2024
@SupaJoon SupaJoon requested review from hadjri and minnakt and removed request for hadjri April 3, 2024 14:47
@SupaJoon
Copy link
Contributor Author

SupaJoon commented Apr 3, 2024

Can we verify this in staging too?

I was able to test the changes in staging by executing the code-block within the SetLastRevision condition.

@@ -104,17 +106,21 @@ func New(apiURL string) Config {
}
}

generatePermissionOpts := func(projectId string) gimlet.PermissionOpts {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. maybe getPermissionOpts would be a good name, i feel like generate implies something fancier

@@ -104,17 +106,21 @@ func New(apiURL string) Config {
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(request) can we move the block for CreateProjectMutation above the declaration of the args variable, since it doesn't use the args variable?

@SupaJoon SupaJoon merged commit f3fcbce into evergreen-ci:main Apr 5, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants