diff --git a/CHANGELOG.md b/CHANGELOG.md index 3164c455e..3ead3d59e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# UNRELEASED + +## Enhancements + +* Adds support for including no-code permissions to the `OrganizationPermissions` struct [#967](https://github.com/hashicorp/go-tfe/pull/967) + # v1.64.1 # Bug Fixes diff --git a/organization.go b/organization.go index 040e2027d..78813a387 100644 --- a/organization.go +++ b/organization.go @@ -183,7 +183,9 @@ type OrganizationPermissions struct { CanCreateTeam bool `jsonapi:"attr,can-create-team"` CanCreateWorkspace bool `jsonapi:"attr,can-create-workspace"` CanCreateWorkspaceMigration bool `jsonapi:"attr,can-create-workspace-migration"` + CanDeployNoCodeModules bool `jsonapi:"attr,can-deploy-no-code-modules"` CanDestroy bool `jsonapi:"attr,can-destroy"` + CanManageNoCodeModules bool `jsonapi:"attr,can-manage-no-code-modules"` CanManageRunTasks bool `jsonapi:"attr,can-manage-run-tasks"` CanTraverse bool `jsonapi:"attr,can-traverse"` CanUpdate bool `jsonapi:"attr,can-update"` diff --git a/organization_integration_test.go b/organization_integration_test.go index 53e4dd1ac..0c57f4c90 100644 --- a/organization_integration_test.go +++ b/organization_integration_test.go @@ -151,6 +151,30 @@ func TestOrganizationsCreate(t *testing.T) { }) } +func TestOrganizationsReadWithBusiness(t *testing.T) { + client := testClient(t) + ctx := context.Background() + + orgTest, orgTestCleanup := createOrganization(t, client) + t.Cleanup(orgTestCleanup) + // With Business + newSubscriptionUpdater(orgTest).WithBusinessPlan().Update(t) + + 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.Name, org.Name) + assert.Equal(t, orgTest.ExternalID, org.ExternalID) + assert.NotEmpty(t, org.Permissions) + + t.Run("permissions are properly decoded", func(t *testing.T) { + assert.True(t, org.Permissions.CanDestroy) + assert.True(t, org.Permissions.CanDeployNoCodeModules) + assert.True(t, org.Permissions.CanManageNoCodeModules) + }) + }) +} + func TestOrganizationsRead(t *testing.T) { client := testClient(t) ctx := context.Background()