Skip to content

Commit 11d0a7f

Browse files
SDKv2 Diff tests for secret set type
1 parent 278674c commit 11d0a7f

File tree

81 files changed

+3452
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+3452
-0
lines changed

pkg/tests/diff_test/detailed_diff_set_test.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,3 +575,57 @@ func TestSDKv2DetailedDiffSetNestedComputedBlock(t *testing.T) {
575575
})
576576
}
577577
}
578+
579+
func TestSDKv2DetailedDiffSetBlockSensitive(t *testing.T) {
580+
t.Parallel()
581+
582+
blockSchemaSensitive := schema.Resource{
583+
Schema: map[string]*schema.Schema{
584+
"test": {
585+
Type: schema.TypeSet,
586+
Optional: true,
587+
Sensitive: true,
588+
Elem: &schema.Resource{
589+
Schema: map[string]*schema.Schema{
590+
"nested": {
591+
Type: schema.TypeString,
592+
Optional: true,
593+
},
594+
},
595+
},
596+
},
597+
},
598+
}
599+
600+
blockSchemaNestedSensitive := schema.Resource{
601+
Schema: map[string]*schema.Schema{
602+
"test": {
603+
Type: schema.TypeSet,
604+
Optional: true,
605+
Elem: &schema.Resource{
606+
Schema: map[string]*schema.Schema{
607+
"nested": {
608+
Type: schema.TypeString,
609+
Optional: true,
610+
Sensitive: true,
611+
},
612+
},
613+
},
614+
},
615+
},
616+
}
617+
618+
setSchemaValueMakerPairs := []setSchemaValueMakerPair{
619+
{"block sensitive", blockSchemaSensitive, nestedListValueMaker},
620+
{"block nested sensitive", blockSchemaNestedSensitive, nestedListValueMaker},
621+
}
622+
623+
for _, schemaValueMakerPair := range setSchemaValueMakerPairs {
624+
t.Run(schemaValueMakerPair.name, func(t *testing.T) {
625+
t.Parallel()
626+
for _, scenario := range setScenarios() {
627+
t.Run(scenario.name, runSetTest(schemaValueMakerPair.res, schemaValueMakerPair.valueMaker, scenario.initialValue, scenario.changeValue, false))
628+
}
629+
})
630+
}
631+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
tests.testOutput{
2+
initialValue: &[]string{},
3+
changeValue: &[]string{"value"},
4+
tfOut: `
5+
Terraform used the selected providers to generate the following execution
6+
plan. Resource actions are indicated with the following symbols:
7+
~ update in-place
8+
9+
Terraform will perform the following actions:
10+
11+
# crossprovider_test_res.example will be updated in-place
12+
~ resource "crossprovider_test_res" "example" {
13+
id = "newid"
14+
15+
+ test {
16+
# At least one attribute in this block is (or was) sensitive,
17+
# so its contents will not be displayed.
18+
}
19+
}
20+
21+
Plan: 0 to add, 1 to change, 0 to destroy.
22+
23+
`,
24+
pulumiOut: `Previewing update (test):
25+
pulumi:pulumi:Stack: (same)
26+
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test]
27+
~ crossprovider:index/testRes:TestRes: (update)
28+
[id=newid]
29+
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example]
30+
+ tests: [secret]
31+
Resources:
32+
~ 1 to update
33+
1 unchanged
34+
`,
35+
detailedDiff: map[string]interface{}{"tests": map[string]interface{}{}},
36+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
tests.testOutput{
2+
initialValue: &[]string{
3+
"val1",
4+
"val2",
5+
},
6+
changeValue: &[]string{
7+
"val1",
8+
"val2",
9+
"val3",
10+
},
11+
tfOut: `
12+
Terraform used the selected providers to generate the following execution
13+
plan. Resource actions are indicated with the following symbols:
14+
~ update in-place
15+
16+
Terraform will perform the following actions:
17+
18+
# crossprovider_test_res.example will be updated in-place
19+
~ resource "crossprovider_test_res" "example" {
20+
id = "newid"
21+
22+
+ test {
23+
# At least one attribute in this block is (or was) sensitive,
24+
# so its contents will not be displayed.
25+
}
26+
27+
# (2 unchanged blocks hidden)
28+
}
29+
30+
Plan: 0 to add, 1 to change, 0 to destroy.
31+
32+
`,
33+
pulumiOut: `Previewing update (test):
34+
pulumi:pulumi:Stack: (same)
35+
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test]
36+
~ crossprovider:index/testRes:TestRes: (update)
37+
[id=newid]
38+
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example]
39+
~ tests: [
40+
+ [2]: [secret]
41+
]
42+
Resources:
43+
~ 1 to update
44+
1 unchanged
45+
`,
46+
detailedDiff: map[string]interface{}{"tests[2]": map[string]interface{}{}},
47+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
tests.testOutput{
2+
initialValue: &[]string{
3+
"val2",
4+
"val3",
5+
},
6+
changeValue: &[]string{
7+
"val2",
8+
"val3",
9+
"val1",
10+
},
11+
tfOut: `
12+
Terraform used the selected providers to generate the following execution
13+
plan. Resource actions are indicated with the following symbols:
14+
~ update in-place
15+
16+
Terraform will perform the following actions:
17+
18+
# crossprovider_test_res.example will be updated in-place
19+
~ resource "crossprovider_test_res" "example" {
20+
id = "newid"
21+
22+
+ test {
23+
# At least one attribute in this block is (or was) sensitive,
24+
# so its contents will not be displayed.
25+
}
26+
27+
# (2 unchanged blocks hidden)
28+
}
29+
30+
Plan: 0 to add, 1 to change, 0 to destroy.
31+
32+
`,
33+
pulumiOut: `Previewing update (test):
34+
pulumi:pulumi:Stack: (same)
35+
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test]
36+
~ crossprovider:index/testRes:TestRes: (update)
37+
[id=newid]
38+
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example]
39+
~ tests: [
40+
+ [2]: [secret]
41+
]
42+
Resources:
43+
~ 1 to update
44+
1 unchanged
45+
`,
46+
detailedDiff: map[string]interface{}{"tests[2]": map[string]interface{}{}},
47+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
tests.testOutput{
2+
initialValue: &[]string{
3+
"val2",
4+
"val3",
5+
},
6+
changeValue: &[]string{
7+
"val1",
8+
"val2",
9+
"val3",
10+
},
11+
tfOut: `
12+
Terraform used the selected providers to generate the following execution
13+
plan. Resource actions are indicated with the following symbols:
14+
~ update in-place
15+
16+
Terraform will perform the following actions:
17+
18+
# crossprovider_test_res.example will be updated in-place
19+
~ resource "crossprovider_test_res" "example" {
20+
id = "newid"
21+
22+
+ test {
23+
# At least one attribute in this block is (or was) sensitive,
24+
# so its contents will not be displayed.
25+
}
26+
27+
# (2 unchanged blocks hidden)
28+
}
29+
30+
Plan: 0 to add, 1 to change, 0 to destroy.
31+
32+
`,
33+
pulumiOut: `Previewing update (test):
34+
pulumi:pulumi:Stack: (same)
35+
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test]
36+
~ crossprovider:index/testRes:TestRes: (update)
37+
[id=newid]
38+
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example]
39+
~ tests: [
40+
+ [0]: [secret]
41+
]
42+
Resources:
43+
~ 1 to update
44+
1 unchanged
45+
`,
46+
detailedDiff: map[string]interface{}{"tests[0]": map[string]interface{}{}},
47+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
tests.testOutput{
2+
initialValue: &[]string{
3+
"val3",
4+
"val1",
5+
},
6+
changeValue: &[]string{
7+
"val2",
8+
"val3",
9+
"val1",
10+
},
11+
tfOut: `
12+
Terraform used the selected providers to generate the following execution
13+
plan. Resource actions are indicated with the following symbols:
14+
~ update in-place
15+
16+
Terraform will perform the following actions:
17+
18+
# crossprovider_test_res.example will be updated in-place
19+
~ resource "crossprovider_test_res" "example" {
20+
id = "newid"
21+
22+
+ test {
23+
# At least one attribute in this block is (or was) sensitive,
24+
# so its contents will not be displayed.
25+
}
26+
27+
# (2 unchanged blocks hidden)
28+
}
29+
30+
Plan: 0 to add, 1 to change, 0 to destroy.
31+
32+
`,
33+
pulumiOut: `Previewing update (test):
34+
pulumi:pulumi:Stack: (same)
35+
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test]
36+
~ crossprovider:index/testRes:TestRes: (update)
37+
[id=newid]
38+
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example]
39+
~ tests: [
40+
+ [0]: [secret]
41+
]
42+
Resources:
43+
~ 1 to update
44+
1 unchanged
45+
`,
46+
detailedDiff: map[string]interface{}{"tests[0]": map[string]interface{}{}},
47+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
tests.testOutput{
2+
initialValue: &[]string{
3+
"val1",
4+
"val3",
5+
},
6+
changeValue: &[]string{
7+
"val1",
8+
"val2",
9+
"val3",
10+
},
11+
tfOut: `
12+
Terraform used the selected providers to generate the following execution
13+
plan. Resource actions are indicated with the following symbols:
14+
~ update in-place
15+
16+
Terraform will perform the following actions:
17+
18+
# crossprovider_test_res.example will be updated in-place
19+
~ resource "crossprovider_test_res" "example" {
20+
id = "newid"
21+
22+
+ test {
23+
# At least one attribute in this block is (or was) sensitive,
24+
# so its contents will not be displayed.
25+
}
26+
27+
# (2 unchanged blocks hidden)
28+
}
29+
30+
Plan: 0 to add, 1 to change, 0 to destroy.
31+
32+
`,
33+
pulumiOut: `Previewing update (test):
34+
pulumi:pulumi:Stack: (same)
35+
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test]
36+
~ crossprovider:index/testRes:TestRes: (update)
37+
[id=newid]
38+
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example]
39+
~ tests: [
40+
+ [1]: [secret]
41+
]
42+
Resources:
43+
~ 1 to update
44+
1 unchanged
45+
`,
46+
detailedDiff: map[string]interface{}{"tests[1]": map[string]interface{}{}},
47+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
tests.testOutput{
2+
initialValue: &[]string{
3+
"val2",
4+
"val1",
5+
},
6+
changeValue: &[]string{
7+
"val2",
8+
"val3",
9+
"val1",
10+
},
11+
tfOut: `
12+
Terraform used the selected providers to generate the following execution
13+
plan. Resource actions are indicated with the following symbols:
14+
~ update in-place
15+
16+
Terraform will perform the following actions:
17+
18+
# crossprovider_test_res.example will be updated in-place
19+
~ resource "crossprovider_test_res" "example" {
20+
id = "newid"
21+
22+
+ test {
23+
# At least one attribute in this block is (or was) sensitive,
24+
# so its contents will not be displayed.
25+
}
26+
27+
# (2 unchanged blocks hidden)
28+
}
29+
30+
Plan: 0 to add, 1 to change, 0 to destroy.
31+
32+
`,
33+
pulumiOut: `Previewing update (test):
34+
pulumi:pulumi:Stack: (same)
35+
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test]
36+
~ crossprovider:index/testRes:TestRes: (update)
37+
[id=newid]
38+
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example]
39+
~ tests: [
40+
+ [1]: [secret]
41+
]
42+
Resources:
43+
~ 1 to update
44+
1 unchanged
45+
`,
46+
detailedDiff: map[string]interface{}{"tests[1]": map[string]interface{}{}},
47+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
tests.testOutput{
2+
initialValue: &[]string{},
3+
changeValue: nil,
4+
tfOut: `
5+
No changes. Your infrastructure matches the configuration.
6+
7+
Terraform has compared your real infrastructure against your configuration
8+
and found no differences, so no changes are needed.
9+
`,
10+
pulumiOut: `Previewing update (test):
11+
pulumi:pulumi:Stack: (same)
12+
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test]
13+
Resources:
14+
2 unchanged
15+
`,
16+
}

0 commit comments

Comments
 (0)