Extend tests further

This commit is contained in:
Pam Selle 2020-10-02 15:01:17 -04:00
parent 55c96da27e
commit 111aadd0f0
1 changed files with 39 additions and 6 deletions

View File

@ -3650,6 +3650,12 @@ func TestResourceChange_sensitiveVariable(t *testing.T) {
"another": cty.StringVal("not secret"), "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{ AfterValMarks: []cty.PathValueMarks{
{ {
@ -3673,6 +3679,10 @@ func TestResourceChange_sensitiveVariable(t *testing.T) {
Path: cty.Path{cty.GetAttrStep{Name: "nested_block_list"}}, Path: cty.Path{cty.GetAttrStep{Name: "nested_block_list"}},
Marks: cty.NewValueMarks("sensitive"), Marks: cty.NewValueMarks("sensitive"),
}, },
{
Path: cty.Path{cty.GetAttrStep{Name: "nested_block_set"}},
Marks: cty.NewValueMarks("sensitive"),
},
}, },
RequiredReplace: cty.NewPathSet(), RequiredReplace: cty.NewPathSet(),
Tainted: false, Tainted: false,
@ -3694,6 +3704,15 @@ func TestResourceChange_sensitiveVariable(t *testing.T) {
}, },
Nesting: configschema.NestingList, 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 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, # At least one attribute in this block is (or was) sensitive,
# so its contents will not be displayed. # 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}, "map_whole": {Type: cty.Map(cty.String), Optional: true},
}, },
BlockTypes: map[string]*configschema.NestedBlock{ 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": { "nested_block_set": {
Block: configschema.Block{ Block: configschema.Block{
Attributes: map[string]*configschema.Attribute{ Attributes: map[string]*configschema.Attribute{
@ -3864,6 +3896,13 @@ func TestResourceChange_sensitiveVariable(t *testing.T) {
# after applying this change # after applying this change
~ special = (sensitive) ~ 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 # Warning: this block will no longer be marked as sensitive
# after applying this change # after applying this change
~ nested_block_set { ~ nested_block_set {
@ -3933,9 +3972,6 @@ func TestResourceChange_sensitiveVariable(t *testing.T) {
Path: cty.Path{cty.GetAttrStep{Name: "nested_block_single"}}, Path: cty.Path{cty.GetAttrStep{Name: "nested_block_single"}},
Marks: cty.NewValueMarks("sensitive"), Marks: cty.NewValueMarks("sensitive"),
}, },
{
Marks: cty.NewValueMarks("sensitive"),
},
}, },
RequiredReplace: cty.NewPathSet(), RequiredReplace: cty.NewPathSet(),
Tainted: false, Tainted: false,
@ -4050,9 +4086,6 @@ func TestResourceChange_sensitiveVariable(t *testing.T) {
Path: cty.Path{cty.GetAttrStep{Name: "nested_block_map"}}, Path: cty.Path{cty.GetAttrStep{Name: "nested_block_map"}},
Marks: cty.NewValueMarks("sensitive"), Marks: cty.NewValueMarks("sensitive"),
}, },
{
Marks: cty.NewValueMarks("sensitive"),
},
}, },
AfterValMarks: []cty.PathValueMarks{ AfterValMarks: []cty.PathValueMarks{
{ {