From 6d7d4601d0edd9da5159b7668c9c4b93f5e85db1 Mon Sep 17 00:00:00 2001 From: Rachael Berecka Date: Mon, 31 Jul 2023 09:54:15 -0700 Subject: [PATCH] Fixup tests and remove beta flag since feature is now released --- CHANGELOG.md | 2 +- team_project_access.go | 10 +++++----- team_project_access_integration_test.go | 16 ++++++---------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4025e102c..912eb7fa8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ ## Enhancements * Added BETA support for including `projects` relationship and `projects-count` attribute to policy_set on create by @hs26gill [#737](https://github.com/hashicorp/go-tfe/pull/737) * Added BETA method `AddProjects` and `RemoveProjects` for attaching/detaching policy set to projects by @Netra2104 [#735](https://github.com/hashicorp/go-tfe/pull/735) -* Added BETA support for adding and updating custom permissions to `TeamProjectAccesses`. A `TeamProjectAccessType` of `"custom"` can set various permissions applied at +* Added support for adding and updating custom permissions to `TeamProjectAccesses`. A `TeamProjectAccessType` of `"custom"` can set various permissions applied at the project level to the project itself (`ProjectAccessOptions`) and all of the workspaces in a project (`WorkspaceAccessOptions`).[#745](https://github.com/hashicorp/go-tfe/pull/745) # v1.30.0 diff --git a/team_project_access.go b/team_project_access.go index 4ba109449..fe7002e72 100644 --- a/team_project_access.go +++ b/team_project_access.go @@ -150,11 +150,11 @@ type WorkspaceAccessPermissionsOptions struct { SentinelMocks *WorkspaceSentinelMocksPermissionType `json:"sentinel-mocks,omitempty"` StateVersions *WorkspaceStateVersionsPermissionType `json:"state-versions,omitempty"` Variables *WorkspaceVariablesPermissionType `json:"variables,omitempty"` - Create bool `json:"create,omitempty"` - Locking bool `json:"locking,omitempty"` - Move bool `json:"move,omitempty"` - Delete bool `json:"delete,omitempty"` - RunTasks bool `json:"run-tasks,omitempty"` + Create bool `json:"create"` + Locking bool `json:"locking"` + Move bool `json:"move"` + Delete bool `json:"delete"` + RunTasks bool `json:"run-tasks"` } // TeamProjectAccessListOptions represents the options for listing team project accesses diff --git a/team_project_access_integration_test.go b/team_project_access_integration_test.go index e07690517..702a5fa2f 100644 --- a/team_project_access_integration_test.go +++ b/team_project_access_integration_test.go @@ -166,7 +166,6 @@ func TestTeamProjectAccessesAdd(t *testing.T) { }) t.Run("with valid options for all custom TeamProject permissions", func(t *testing.T) { - skipUnlessBeta(t) options := TeamProjectAccessAddOptions{ Access: *ProjectAccess(TeamProjectAccessCustom), Team: tmTest, @@ -223,7 +222,6 @@ func TestTeamProjectAccessesAdd(t *testing.T) { }) t.Run("with valid options for some custom TeamProject permissions", func(t *testing.T) { - skipUnlessBeta(t) options := TeamProjectAccessAddOptions{ Access: *ProjectAccess(TeamProjectAccessCustom), Team: tmTest, @@ -237,12 +235,12 @@ func TestTeamProjectAccessesAdd(t *testing.T) { } tpa, err := client.TeamProjectAccess.Add(ctx, options) - defer func() { + t.Cleanup(func() { err := client.TeamProjectAccess.Remove(ctx, tpa.ID) if err != nil { t.Logf("error removing team access (%s): %s", tpa.ID, err) } - }() + }) require.NoError(t, err) @@ -303,7 +301,6 @@ func TestTeamProjectAccessesAdd(t *testing.T) { }) t.Run("when invalid custom project permission is provided in options", func(t *testing.T) { - skipUnlessBeta(t) tpa, err := client.TeamProjectAccess.Add(ctx, TeamProjectAccessAddOptions{ Access: *ProjectAccess(TeamProjectAccessCustom), Team: tmTest, @@ -355,7 +352,6 @@ func TestTeamProjectAccessesUpdate(t *testing.T) { }) t.Run("with valid custom permissions attributes for all permissions", func(t *testing.T) { - skipUnlessBeta(t) options := TeamProjectAccessUpdateOptions{ Access: ProjectAccess(TeamProjectAccessCustom), ProjectAccess: &ProjectAccessPermissionsOptions{ @@ -377,7 +373,8 @@ func TestTeamProjectAccessesUpdate(t *testing.T) { tpa, err := client.TeamProjectAccess.Update(ctx, tpaTest.ID, options) require.NoError(t, err) - + require.NotNil(t, options.ProjectAccess) + require.NotNil(t, options.WorkspaceAccess) assert.Equal(t, tpa.Access, TeamProjectAccessCustom) assert.Equal(t, *options.ProjectAccess.Teams, tpa.ProjectAccess.ProjectTeamsPermission) assert.Equal(t, *options.ProjectAccess.Settings, tpa.ProjectAccess.ProjectSettingsPermission) @@ -407,7 +404,6 @@ func TestTeamProjectAccessesUpdate(t *testing.T) { tpaCustomTest, err := client.TeamProjectAccess.Add(ctx, TpaOptions) require.NoError(t, err) - skipUnlessBeta(t) options := TeamProjectAccessUpdateOptions{ Access: ProjectAccess(TeamProjectAccessCustom), ProjectAccess: &ProjectAccessPermissionsOptions{ @@ -420,7 +416,8 @@ func TestTeamProjectAccessesUpdate(t *testing.T) { tpa, err := client.TeamProjectAccess.Update(ctx, tpaCustomTest.ID, options) require.NoError(t, err) - + require.NotNil(t, options.ProjectAccess) + require.NotNil(t, options.WorkspaceAccess) assert.Equal(t, *options.ProjectAccess.Teams, tpa.ProjectAccess.ProjectTeamsPermission) assert.Equal(t, false, tpa.WorkspaceAccess.WorkspaceCreatePermission) // assert that other attributes remain the same @@ -433,7 +430,6 @@ func TestTeamProjectAccessesUpdate(t *testing.T) { assert.Equal(t, tpaCustomTest.WorkspaceAccess.WorkspaceStateVersionsPermission, tpa.WorkspaceAccess.WorkspaceStateVersionsPermission) }) t.Run("with invalid custom permissions attributes", func(t *testing.T) { - skipUnlessBeta(t) options := TeamProjectAccessUpdateOptions{ Access: ProjectAccess(TeamProjectAccessCustom), ProjectAccess: &ProjectAccessPermissionsOptions{