Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix boundary_worker auth token overwritten during creation & ForceNew on auth token change #461

Merged
merged 2 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/provider/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func resourceWorker() *schema.Resource {
Description: "The worker authentication token required to register the worker for the worker-led authentication flow. Leaving this blank will result in a controller generated token.",
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
controllerGeneratedActivationToken: {
Description: "A single use token generated by the controller to be passed to the self-managed worker.",
Expand Down Expand Up @@ -98,7 +99,6 @@ func setFromWorkerResponseMap(d *schema.ResourceData, raw map[string]interface{}
d.Set(NameKey, raw["name"])
d.Set(DescriptionKey, raw["description"])
d.Set(address, raw["address"])
d.Set(workerGeneratedAuthToken, raw["worker_generated_auth_token"])
d.Set(controllerGeneratedActivationToken, raw["controller_generated_activation_token"])
d.Set(releaseVersion, raw["release_version"])
d.Set(authorizedActions, raw["authorized_actions"])
Expand Down
7 changes: 7 additions & 0 deletions internal/provider/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,14 @@ func TestWorkerWorkerLed(t *testing.T) {
testAccCheckworkerResourceExists(provider, "boundary_worker.worker_led"),
resource.TestCheckResourceAttr("boundary_worker.worker_led", "description", workerDesc),
resource.TestCheckResourceAttr("boundary_worker.worker_led", "name", workerName),
resource.TestCheckResourceAttr("boundary_worker.worker_led", "worker_generated_auth_token", workerToken),
),
},
{
// create
Config: testConfig(url, workerLedCreate),
PlanOnly: true,
},
importStep("boundary_worker.worker_led"),
{
// update
Expand All @@ -90,6 +96,7 @@ func TestWorkerWorkerLed(t *testing.T) {
testAccCheckworkerResourceExists(provider, "boundary_worker.worker_led"),
resource.TestCheckResourceAttr("boundary_worker.worker_led", "description", workerDescUpdate),
resource.TestCheckResourceAttr("boundary_worker.worker_led", "name", workerNameUpdate),
resource.TestCheckResourceAttr("boundary_worker.worker_led", "worker_generated_auth_token", workerToken),
),
},
importStep("boundary_worker.worker_led"),
Expand Down