From 111aadd0f0d89e3d577cf122a86828faeac28118 Mon Sep 17 00:00:00 2001 From: Pam Selle <204372+pselle@users.noreply.github.com> Date: Fri, 2 Oct 2020 15:01:17 -0400 Subject: [PATCH] Extend tests further --- command/format/diff_test.go | 45 ++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/command/format/diff_test.go b/command/format/diff_test.go index 09b66c373..81225a39f 100644 --- a/command/format/diff_test.go +++ b/command/format/diff_test.go @@ -3650,6 +3650,12 @@ func TestResourceChange_sensitiveVariable(t *testing.T) { "another": cty.StringVal("not secret"), }), }), + "nested_block_set": cty.ListVal([]cty.Value{ + cty.ObjectVal(map[string]cty.Value{ + "an_attr": cty.StringVal("secretval"), + "another": cty.StringVal("not secret"), + }), + }), }), AfterValMarks: []cty.PathValueMarks{ { @@ -3673,6 +3679,10 @@ func TestResourceChange_sensitiveVariable(t *testing.T) { Path: cty.Path{cty.GetAttrStep{Name: "nested_block_list"}}, Marks: cty.NewValueMarks("sensitive"), }, + { + Path: cty.Path{cty.GetAttrStep{Name: "nested_block_set"}}, + Marks: cty.NewValueMarks("sensitive"), + }, }, RequiredReplace: cty.NewPathSet(), Tainted: false, @@ -3694,6 +3704,15 @@ func TestResourceChange_sensitiveVariable(t *testing.T) { }, Nesting: configschema.NestingList, }, + "nested_block_set": { + Block: configschema.Block{ + Attributes: map[string]*configschema.Attribute{ + "an_attr": {Type: cty.String, Optional: true}, + "another": {Type: cty.String, Optional: true}, + }, + }, + Nesting: configschema.NestingSet, + }, }, }, ExpectedOutput: ` # test_instance.example will be created @@ -3715,6 +3734,11 @@ func TestResourceChange_sensitiveVariable(t *testing.T) { # At least one attribute in this block is (or was) sensitive, # so its contents will not be displayed. } + + + nested_block_set { + # At least one attribute in this block is (or was) sensitive, + # so its contents will not be displayed. + } } `, }, @@ -3826,6 +3850,14 @@ func TestResourceChange_sensitiveVariable(t *testing.T) { "map_whole": {Type: cty.Map(cty.String), Optional: true}, }, BlockTypes: map[string]*configschema.NestedBlock{ + "nested_block": { + Block: configschema.Block{ + Attributes: map[string]*configschema.Attribute{ + "an_attr": {Type: cty.String, Optional: true}, + }, + }, + Nesting: configschema.NestingList, + }, "nested_block_set": { Block: configschema.Block{ Attributes: map[string]*configschema.Attribute{ @@ -3864,6 +3896,13 @@ func TestResourceChange_sensitiveVariable(t *testing.T) { # after applying this change ~ special = (sensitive) + # Warning: this block will no longer be marked as sensitive + # after applying this change + ~ nested_block { + # At least one attribute in this block is (or was) sensitive, + # so its contents will not be displayed. + } + # Warning: this block will no longer be marked as sensitive # after applying this change ~ nested_block_set { @@ -3933,9 +3972,6 @@ func TestResourceChange_sensitiveVariable(t *testing.T) { Path: cty.Path{cty.GetAttrStep{Name: "nested_block_single"}}, Marks: cty.NewValueMarks("sensitive"), }, - { - Marks: cty.NewValueMarks("sensitive"), - }, }, RequiredReplace: cty.NewPathSet(), Tainted: false, @@ -4050,9 +4086,6 @@ func TestResourceChange_sensitiveVariable(t *testing.T) { Path: cty.Path{cty.GetAttrStep{Name: "nested_block_map"}}, Marks: cty.NewValueMarks("sensitive"), }, - { - Marks: cty.NewValueMarks("sensitive"), - }, }, AfterValMarks: []cty.PathValueMarks{ {