Skip to content

Conversation

@JarrettSpiker
Copy link
Contributor

@JarrettSpiker JarrettSpiker commented Sep 23, 2025

Description

Adds UserTokensEnabled for Organizations.

This new HCP Terraform setting defaults to true. When disabled by an organization owner, user tokens will no longer be permitted to access the organization's resources through the API.

Testing plan

  1. Validate that the setting can be read from existing orgs
  2. Test creating orgs with the setting enabled/disabled
  3. Test updating an org to enable/disable the setting
  4. Validate that the setting is not included in update request serialization if not specified

External links

Output from tests

Including output from tests may require access to a TFE instance. Ignore this section if you have no environment to test against.

/usr/local/bin/go test -timeout 3000s -run ^TestOrganizationsUpdate$ github.com/hashicorp/go-tfe

=== RUN   TestOrganizationsUpdate
=== RUN   TestOrganizationsUpdate/with_HCP_Terraform-only_options
--- PASS: TestOrganizationsUpdate/with_HCP_Terraform-only_options (2.83s)
=== RUN   TestOrganizationsUpdate/with_new_AggregatedCommitStatusEnabled_option
--- PASS: TestOrganizationsUpdate/with_new_AggregatedCommitStatusEnabled_option (5.25s)
=== RUN   TestOrganizationsUpdate/with_new_SpeculativePlanManagementEnabled_option
--- PASS: TestOrganizationsUpdate/with_new_SpeculativePlanManagementEnabled_option (3.65s)
=== RUN   TestOrganizationsUpdate/with_new_UserTokensEnabled_option
--- PASS: TestOrganizationsUpdate/with_new_UserTokensEnabled_option (5.66s)
=== RUN   TestOrganizationsUpdate/with_valid_options
--- PASS: TestOrganizationsUpdate/with_valid_options (3.72s)
=== RUN   TestOrganizationsUpdate/with_invalid_name
--- PASS: TestOrganizationsUpdate/with_invalid_name (0.00s)
=== RUN   TestOrganizationsUpdate/with_agent_pool_provided,_but_remote_execution_mode
--- PASS: TestOrganizationsUpdate/with_agent_pool_provided,_but_remote_execution_mode (3.75s)
=== RUN   TestOrganizationsUpdate/when_only_updating_a_subset_of_fields
--- PASS: TestOrganizationsUpdate/when_only_updating_a_subset_of_fields (2.16s)
=== RUN   TestOrganizationsUpdate/with_different_default_execution_modes
--- PASS: TestOrganizationsUpdate/with_different_default_execution_modes (3.93s)
--- PASS: TestOrganizationsUpdate (31.59s)
PASS
ok      github.com/hashicorp/go-tfe
...

Rollback Plan

If we need to revert this change before a go-tfe release, we will.

Changes to Security Controls

no

@JarrettSpiker JarrettSpiker requested a review from a team as a code owner September 23, 2025 21:33
@JarrettSpiker JarrettSpiker marked this pull request as draft September 23, 2025 21:33
@JarrettSpiker JarrettSpiker force-pushed the jspiker/user-token-enablement branch from bf749f0 to 62ba5e8 Compare September 24, 2025 15:53
@JarrettSpiker JarrettSpiker force-pushed the jspiker/user-token-enablement branch from 62ba5e8 to 7eb9144 Compare November 25, 2025 19:11
@JarrettSpiker JarrettSpiker marked this pull request as ready for review November 25, 2025 19:13
@JarrettSpiker JarrettSpiker changed the title [DRAFT] Add UserTokensEnabled field for Organizations Add UserTokensEnabled field for Organizations Nov 25, 2025
@datadog-terraform-cloud-hashicorp
Copy link

datadog-terraform-cloud-hashicorp bot commented Nov 25, 2025

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: e7cf4aa | Docs | Was this helpful? Give us feedback!

@ctrombley ctrombley force-pushed the jspiker/user-token-enablement branch from 09dc30b to e7cf4aa Compare November 27, 2025 00:12
RemainingTestableCount int `jsonapi:"attr,remaining-testable-count"`
SpeculativePlanManagementEnabled bool `jsonapi:"attr,speculative-plan-management-enabled"`
EnforceHYOK bool `jsonapi:"attr,enforce-hyok"`
UserTokensEnabled *bool `jsonapi:"attr,user-tokens-enabled"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we use a bool pointer type? false and nil are both logically equivalent, correct?

org, err := ownerClient.Organizations.Update(ctx, orgTest.Name, options)
require.NoError(t, err)
assert.False(t, *org.UserTokensEnabled, "user tokens disabled")

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider including assertions that validate the change had the intended effect, i.e. try and look up some resources and expect an error here. (& the inverse when the setting is off)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants