From f04d0b48bcb087d1980bb807f36d783b49f63b09 Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Wed, 23 Jan 2019 15:32:13 +0000 Subject: [PATCH] command/format: Add test to cover update of sensitive field --- command/format/diff_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/command/format/diff_test.go b/command/format/diff_test.go index bc0a3ad82..16cb037da 100644 --- a/command/format/diff_test.go +++ b/command/format/diff_test.go @@ -238,6 +238,35 @@ new line + id = (known after apply) + password = (sensitive value) } +`, + }, + "update with equal sensitive field": { + Action: plans.Update, + Mode: addrs.ManagedResourceMode, + Before: cty.ObjectVal(map[string]cty.Value{ + "id": cty.StringVal("blah"), + "str": cty.StringVal("before"), + "password": cty.StringVal("top-secret"), + }), + After: cty.ObjectVal(map[string]cty.Value{ + "id": cty.UnknownVal(cty.String), + "str": cty.StringVal("after"), + "password": cty.StringVal("top-secret"), + }), + Schema: &configschema.Block{ + Attributes: map[string]*configschema.Attribute{ + "id": {Type: cty.String, Computed: true}, + "str": {Type: cty.String, Optional: true}, + "password": {Type: cty.String, Optional: true, Sensitive: true}, + }, + }, + RequiredReplace: cty.NewPathSet(), + ExpectedOutput: ` # test_instance.example will be updated in-place + ~ resource "test_instance" "example" { + ~ id = "blah" -> (known after apply) + password = (sensitive value) + ~ str = "before" -> "after" + } `, }, }