Skip to content

DELETE license API endpoint #3697

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

Merged
merged 2 commits into from
Aug 25, 2022
Merged

DELETE license API endpoint #3697

merged 2 commits into from
Aug 25, 2022

Conversation

spikecurtis
Copy link
Contributor

First PR for #3281

Follow on PR will include the CLI command.

@Emyrk In addition to the DELETE API, I've added a new check to the TestAuthorizeAllEndpoints test, which asserts that each route assertion actually gets checked during the API walk. As it turns out, some of them were not getting hit, and we were silently thinking that certain RBAC assertions were being checked when they were not. Most were simple errors in the parameter names in the paths (this could be due to drift in the API definition). But, there were some where the RBAC check is actually different, so I would like you to take a look at the updates to the assertions.

Signed-off-by: Spike Curtis <spike@coder.com>
@spikecurtis spikecurtis requested review from Emyrk and a team August 25, 2022 18:55
Signed-off-by: Spike Curtis <spike@coder.com>
Copy link
Member

@Emyrk Emyrk left a comment

Choose a reason for hiding this comment

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

Authorize test update looks good, just should drop that one comment 👍

Comment on lines +121 to +141
urlParameters := map[string]string{
"{organization}": admin.OrganizationID.String(),
"{user}": admin.UserID.String(),
"{organizationname}": organization.Name,
"{workspace}": workspace.ID.String(),
"{workspacebuild}": workspace.LatestBuild.ID.String(),
"{workspacename}": workspace.Name,
"{workspacebuildname}": workspace.LatestBuild.Name,
"{workspaceagent}": workspaceResources[0].Agents[0].ID.String(),
"{buildnumber}": strconv.FormatInt(int64(workspace.LatestBuild.BuildNumber), 10),
"{template}": template.ID.String(),
"{hash}": file.Hash,
"{workspaceresource}": workspaceResources[0].ID.String(),
"{workspaceapp}": workspaceResources[0].Agents[0].Apps[0].Name,
"{templateversion}": version.ID.String(),
"{jobID}": templateVersionDryRun.ID.String(),
"{templatename}": template.Name,
// Only checking template scoped params here
"parameters/{scope}/{id}": fmt.Sprintf("parameters/%s/%s",
string(templateParam.Scope), templateParam.ScopeID.String()),
}
Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -422,32 +445,18 @@ func (a *AuthTester) Test(ctx context.Context, assertRoute map[string]RouteCheck
}
a.t.Run(name, func(t *testing.T) {
a.authorizer.reset()
routeAssertions, ok := assertRoute[strings.TrimRight(name, "/")]
routeKey := strings.TrimRight(name, "/")
routeAssertions, ok := assertRoute[routeKey]
if !ok {
// By default, all omitted routes check for just "authorize" called
Copy link
Member

Choose a reason for hiding this comment

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

I think we need to drop this comment then? This was initially done because I was lazy, but I totally see how it allowed some routes to drift 🤦‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I still think it's fine for routes in the walk not to be in assertRoute and us just check that auth is called.

The issue is that there were entries in the assertRoute that were not present in the walk. Those entries asserted particular RBAC actions and objects, but because the routes were misspelled, the assertions were never checked.

@spikecurtis spikecurtis merged commit ca38114 into main Aug 25, 2022
@spikecurtis spikecurtis deleted the spike/3281_delete_license_api branch August 25, 2022 21:04
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.

2 participants