From 95533132974e9dddec416f7cf737fe43eb560b9a Mon Sep 17 00:00:00 2001 From: Glenn Sarti Date: Tue, 19 Apr 2022 11:49:39 +0800 Subject: [PATCH] Revert "Add Run Tasks permissions for Org. and Workspace" This reverts commit fb2d82ce429b9ea17c8c9024837a0c0cded9d892. --- organization.go | 1 - organization_integration_test.go | 23 ----------- team.go | 2 - team_access.go | 2 - team_access_integration_test.go | 65 -------------------------------- team_integration_test.go | 42 --------------------- workspace.go | 1 - workspace_integration_test.go | 22 ----------- 8 files changed, 158 deletions(-) diff --git a/organization.go b/organization.go index 7c17ea885..1a4e7da64 100644 --- a/organization.go +++ b/organization.go @@ -113,7 +113,6 @@ type OrganizationPermissions struct { CanCreateWorkspace bool `jsonapi:"attr,can-create-workspace"` CanCreateWorkspaceMigration bool `jsonapi:"attr,can-create-workspace-migration"` CanDestroy bool `jsonapi:"attr,can-destroy"` - CanManageRunTasks bool `jsonapi:"attr,can-manage-run-tasks"` CanTraverse bool `jsonapi:"attr,can-traverse"` CanUpdate bool `jsonapi:"attr,can-update"` CanUpdateAPIToken bool `jsonapi:"attr,can-update-api-token"` diff --git a/organization_integration_test.go b/organization_integration_test.go index 10cafc305..e097b6470 100644 --- a/organization_integration_test.go +++ b/organization_integration_test.go @@ -459,26 +459,3 @@ func TestOrganization_Unmarshal(t *testing.T) { assert.NotEmpty(t, org.Permissions) assert.Equal(t, org.Permissions.CanCreateTeam, true) } - -func TestOrganizationsReadRunTasksPermission(t *testing.T) { - skipIfFreeOnly(t) - skipIfBeta(t) - skipIfEnterprise(t) - - client := testClient(t) - ctx := context.Background() - - orgTest, orgTestCleanup := createOrganization(t, client) - defer orgTestCleanup() - - t.Run("when the org exists", func(t *testing.T) { - org, err := client.Organizations.Read(ctx, orgTest.Name) - require.NoError(t, err) - assert.Equal(t, orgTest, org) - assert.NotEmpty(t, org.Permissions) - - t.Run("permissions are properly decoded", func(t *testing.T) { - assert.True(t, org.Permissions.CanManageRunTasks) - }) - }) -} diff --git a/team.go b/team.go index aa4a8a6a6..92d92a160 100644 --- a/team.go +++ b/team.go @@ -64,7 +64,6 @@ type OrganizationAccess struct { ManageVCSSettings bool `jsonapi:"attr,manage-vcs-settings"` ManageProviders bool `jsonapi:"attr,manage-providers"` ManageModules bool `jsonapi:"attr,manage-modules"` - ManageRunTasks bool `jsonapi:"attr,manage-run-tasks"` } // TeamPermissions represents the current user's permissions on the team. @@ -140,7 +139,6 @@ type OrganizationAccessOptions struct { ManageVCSSettings *bool `json:"manage-vcs-settings,omitempty"` ManageProviders *bool `json:"manage-providers,omitempty"` ManageModules *bool `json:"manage-modules,omitempty"` - ManageRunTasks *bool `json:"manage-run-tasks,omitempty"` } // List all the teams of the given organization. diff --git a/team_access.go b/team_access.go index 7496cce53..2a54f458e 100644 --- a/team_access.go +++ b/team_access.go @@ -98,7 +98,6 @@ type TeamAccess struct { StateVersions StateVersionsPermissionType `jsonapi:"attr,state-versions"` SentinelMocks SentinelMocksPermissionType `jsonapi:"attr,sentinel-mocks"` WorkspaceLocking bool `jsonapi:"attr,workspace-locking"` - RunTasks bool `jsonapi:"attr,run-tasks"` // Relations Team *Team `jsonapi:"relation,team"` @@ -155,7 +154,6 @@ type TeamAccessUpdateOptions struct { StateVersions *StateVersionsPermissionType `jsonapi:"attr,state-versions,omitempty"` SentinelMocks *SentinelMocksPermissionType `jsonapi:"attr,sentinel-mocks,omitempty"` WorkspaceLocking *bool `jsonapi:"attr,workspace-locking,omitempty"` - RunTasks *bool `jsonapi:"attr,run-tasks,omitempty"` } // List all the team accesses for a given workspace. diff --git a/team_access_integration_test.go b/team_access_integration_test.go index ae2728e67..cb9197707 100644 --- a/team_access_integration_test.go +++ b/team_access_integration_test.go @@ -338,68 +338,3 @@ func TestTeamAccessesRemove(t *testing.T) { assert.Equal(t, err, ErrInvalidAccessTeamID) }) } - -func TestTeamAccessesReadRunTasks(t *testing.T) { - skipIfFreeOnly(t) - skipIfBeta(t) - skipIfEnterprise(t) - - client := testClient(t) - ctx := context.Background() - - orgTest, orgTestCleanup := createOrganization(t, client) - defer orgTestCleanup() - wTest, wTestCleanup := createWorkspace(t, client, orgTest) - defer wTestCleanup() - tmTest, tmTestCleanup := createTeam(t, client, orgTest) - defer tmTestCleanup() - - taTest, taTestCleanup := createTeamAccess(t, client, tmTest, wTest, orgTest) - defer taTestCleanup() - - t.Run("when the team access exists", func(t *testing.T) { - ta, err := client.TeamAccess.Read(ctx, taTest.ID) - require.NoError(t, err) - - assert.Equal(t, AccessAdmin, ta.Access) - - t.Run("permission attributes are decoded", func(t *testing.T) { - assert.Equal(t, true, ta.RunTasks) - }) - }) -} - -func TestTeamAccessesUpdateRunTasks(t *testing.T) { - skipIfFreeOnly(t) - skipIfBeta(t) - skipIfEnterprise(t) - - client := testClient(t) - ctx := context.Background() - - orgTest, orgTestCleanup := createOrganization(t, client) - defer orgTestCleanup() - - wTest, wTestCleanup := createWorkspace(t, client, orgTest) - defer wTestCleanup() - - tmTest, tmTestCleanup := createTeam(t, client, orgTest) - defer tmTestCleanup() - - taTest, taTestCleanup := createTeamAccess(t, client, tmTest, wTest, orgTest) - defer taTestCleanup() - - t.Run("with valid attributes", func(t *testing.T) { - newAccess := !taTest.RunTasks - options := TeamAccessUpdateOptions{ - Access: Access(AccessCustom), - RunTasks: &newAccess, - } - - ta, err := client.TeamAccess.Update(ctx, taTest.ID, options) - require.NoError(t, err) - - assert.Equal(t, AccessCustom, ta.Access) - assert.Equal(t, newAccess, ta.RunTasks) - }) -} diff --git a/team_integration_test.go b/team_integration_test.go index 83149409e..0d8423029 100644 --- a/team_integration_test.go +++ b/team_integration_test.go @@ -350,45 +350,3 @@ func TestTeamCreateOptions_Marshal(t *testing.T) { ` assert.Equal(t, expectedBody, string(bodyBytes)) } - -func TestTeamsUpdateRunTasks(t *testing.T) { - skipIfFreeOnly(t) - skipIfBeta(t) - skipIfEnterprise(t) - - client := testClient(t) - ctx := context.Background() - - orgTest, orgTestCleanup := createOrganization(t, client) - defer orgTestCleanup() - - tmTest, tmTestCleanup := createTeam(t, client, orgTest) - defer tmTestCleanup() - - t.Run("with valid options", func(t *testing.T) { - options := TeamUpdateOptions{ - Name: String("foo bar"), - OrganizationAccess: &OrganizationAccessOptions{ - ManageRunTasks: Bool(true), - }, - Visibility: String("organization"), - } - - tm, err := client.Teams.Update(ctx, tmTest.ID, options) - require.NoError(t, err) - - refreshed, err := client.Teams.Read(ctx, tmTest.ID) - require.NoError(t, err) - - for _, item := range []*Team{ - tm, - refreshed, - } { - assert.Equal(t, *options.Name, item.Name) - assert.Equal(t, - *options.OrganizationAccess.ManageRunTasks, - item.OrganizationAccess.ManageRunTasks, - ) - } - }) -} diff --git a/workspace.go b/workspace.go index e4200eb85..0f58e4ab5 100644 --- a/workspace.go +++ b/workspace.go @@ -193,7 +193,6 @@ type WorkspacePermissions struct { CanDestroy bool `jsonapi:"attr,can-destroy"` CanForceUnlock bool `jsonapi:"attr,can-force-unlock"` CanLock bool `jsonapi:"attr,can-lock"` - CanManageRunTasks bool `jsonapi:"attr,can-manage-run-tasks"` CanQueueApply bool `jsonapi:"attr,can-queue-apply"` CanQueueDestroy bool `jsonapi:"attr,can-queue-destroy"` CanQueueRun bool `jsonapi:"attr,can-queue-run"` diff --git a/workspace_integration_test.go b/workspace_integration_test.go index fd6eb145a..e4e53add8 100644 --- a/workspace_integration_test.go +++ b/workspace_integration_test.go @@ -1411,25 +1411,3 @@ func TestWorkspaceCreateOptions_Marshal(t *testing.T) { ` assert.Equal(t, expectedBody, string(bodyBytes)) } - -func TestWorkspacesRunTasksPermission(t *testing.T) { - skipIfFreeOnly(t) - skipIfBeta(t) - skipIfEnterprise(t) - - client := testClient(t) - ctx := context.Background() - - orgTest, orgTestCleanup := createOrganization(t, client) - defer orgTestCleanup() - - wTest, wTestCleanup := createWorkspace(t, client, orgTest) - defer wTestCleanup() - - t.Run("when the workspace exists", func(t *testing.T) { - w, err := client.Workspaces.Read(ctx, orgTest.Name, wTest.Name) - require.NoError(t, err) - assert.Equal(t, wTest, w) - assert.True(t, w.Permissions.CanManageRunTasks) - }) -}