mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: update template with noop returned undefined template (#11688)
* fix: doing a noop patch to templates resulted in 404 The patch response did not include the template. The UI required the template to be returned to form the new page path null is more explicit, and harder to make occur by mistake.
This commit is contained in:
@@ -687,6 +687,44 @@ func TestTemplates(t *testing.T) {
|
||||
require.Empty(t, template.DeprecationMessage)
|
||||
require.False(t, template.Deprecated)
|
||||
})
|
||||
|
||||
// Create a template, remove the group, see if an owner can
|
||||
// still fetch the template.
|
||||
t.Run("GetOnEveryoneRemove", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
owner, first := coderdenttest.New(t, &coderdenttest.Options{
|
||||
Options: &coderdtest.Options{
|
||||
IncludeProvisionerDaemon: true,
|
||||
TemplateScheduleStore: schedule.NewEnterpriseTemplateScheduleStore(agplUserQuietHoursScheduleStore()),
|
||||
},
|
||||
LicenseOptions: &coderdenttest.LicenseOptions{
|
||||
Features: license.Features{
|
||||
codersdk.FeatureAccessControl: 1,
|
||||
codersdk.FeatureTemplateRBAC: 1,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
client, _ := coderdtest.CreateAnotherUser(t, owner, first.OrganizationID, rbac.RoleTemplateAdmin())
|
||||
version := coderdtest.CreateTemplateVersion(t, client, first.OrganizationID, nil)
|
||||
template := coderdtest.CreateTemplate(t, client, first.OrganizationID, version.ID)
|
||||
|
||||
ctx := testutil.Context(t, testutil.WaitMedium)
|
||||
err := client.UpdateTemplateACL(ctx, template.ID, codersdk.UpdateTemplateACL{
|
||||
UserPerms: nil,
|
||||
GroupPerms: map[string]codersdk.TemplateRole{
|
||||
// OrgID is the everyone ID
|
||||
first.OrganizationID.String(): codersdk.TemplateRoleDeleted,
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
||||
defer cancel()
|
||||
|
||||
_, err = owner.Template(ctx, template.ID)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
func TestTemplateACL(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user