Skip to content

Commit

Permalink
Merge pull request #967 from hashicorp/org/add-no-code-permissions
Browse files Browse the repository at this point in the history
Org: Include no-code specific permissions to `OrganizationPermissions`
  • Loading branch information
briancain committed Aug 27, 2024
2 parents 26f46b9 + 2763cc2 commit 8e308df
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
24 changes: 24 additions & 0 deletions organization_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 8e308df

Please sign in to comment.