Skip to content

Commit 0680a77

Browse files
add dns keys datasource (#7186) (#5179)
* initial commit for muxer and framework provider * minor changes to new provider and muxer * add provider model, provider schema, defaults in config * initial commit to upgrading the provider * match schema to sdk provider * remove duplicates * add dns record set, test and provider schema update * add dcl custom endpoints, custom endpoint validator and credentials validator * mv sdk provider defaults to config, fix up other small issues * add changes from merging with main * working with provider meta * move MultiEnvDefault function so it will hopefully be picked up by the validator * don't need to downgrade the provider * fix beta build issue * remove redundant dcl generated custom endpoint * strange org policy issue - only needed in ga * fix failures in beta * fix vcr tests * fix vcr tests for real hopefully * fix provider meta error * Update record set data source test to compare muxed provider to v4.50.0 This includes copying useful test util functions from terraform-provider-random (https://github.com/hashicorp/terraform-provider-random/blob/main/internal/provider/resource_integer_test.go#L1006) * Fix error in `providerVersion450` * add framework_test_utils * add functionality to configure the test framework provider and get check destroys working * add managed zone check destroy * add tflog to framework files * review comment changes * use version.ProviderVersion * add comment for test provider configure function * remove redundant Cloudbuildv2CustomEndpoint endpoint on framework provider * adding data source dns keys * fix providermeta errors * add sdk upgrade tests and check destroy to dns keys tests * add descriptions * formatting changes * add check attribute values equal * remove diffsuppress comment, add other test checks --------- Signed-off-by: Modular Magician <[email protected]> Co-authored-by: Sarah French <[email protected]>
1 parent 9d02521 commit 0680a77

File tree

6 files changed

+455
-168
lines changed

6 files changed

+455
-168
lines changed

.changelog/7186.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:none
2+
3+
```

google-beta/data_source_dns_key_test.go

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,41 @@ import (
1111
func TestAccDataSourceDNSKeys_basic(t *testing.T) {
1212
t.Parallel()
1313

14-
dnsZoneName := fmt.Sprintf("data-dnskey-test-%s", randString(t, 10))
14+
dnsZoneName := fmt.Sprintf("tf-dnskey-test-%s", randString(t, 10))
15+
16+
var kskDigest1, kskDigest2, zskPubKey1, zskPubKey2, kskAlg1, kskAlg2 string
1517

1618
vcrTest(t, resource.TestCase{
1719
PreCheck: func() { testAccPreCheck(t) },
18-
Providers: testAccProviders,
19-
CheckDestroy: testAccCheckDNSManagedZoneDestroyProducer(t),
20+
CheckDestroy: testAccCheckDNSManagedZoneDestroyProducerFramework(t),
2021
Steps: []resource.TestStep{
2122
{
22-
Config: testAccDataSourceDNSKeysConfig(dnsZoneName, "on"),
23+
ExternalProviders: providerVersion450(),
24+
Config: testAccDataSourceDNSKeysConfig(dnsZoneName, "on"),
2325
Check: resource.ComposeTestCheckFunc(
2426
testAccDataSourceDNSKeysDSRecordCheck("data.google_dns_keys.foo_dns_key"),
2527
resource.TestCheckResourceAttr("data.google_dns_keys.foo_dns_key", "key_signing_keys.#", "1"),
2628
resource.TestCheckResourceAttr("data.google_dns_keys.foo_dns_key", "zone_signing_keys.#", "1"),
2729
resource.TestCheckResourceAttr("data.google_dns_keys.foo_dns_key_id", "key_signing_keys.#", "1"),
2830
resource.TestCheckResourceAttr("data.google_dns_keys.foo_dns_key_id", "zone_signing_keys.#", "1"),
31+
testExtractResourceAttr("data.google_dns_keys.foo_dns_key", "key_signing_keys.0.digests.0.digest", &kskDigest1),
32+
testExtractResourceAttr("data.google_dns_keys.foo_dns_key_id", "zone_signing_keys.0.public_key", &zskPubKey1),
33+
testExtractResourceAttr("data.google_dns_keys.foo_dns_key_id", "key_signing_keys.0.algorithm", &kskAlg1),
34+
),
35+
},
36+
{
37+
ProtoV5ProviderFactories: protoV5ProviderFactories(t),
38+
Config: testAccDataSourceDNSKeysConfig(dnsZoneName, "on"),
39+
Check: resource.ComposeTestCheckFunc(
40+
testAccDataSourceDNSKeysDSRecordCheck("data.google_dns_keys.foo_dns_key"),
41+
resource.TestCheckResourceAttr("data.google_dns_keys.foo_dns_key", "key_signing_keys.#", "1"),
42+
resource.TestCheckResourceAttr("data.google_dns_keys.foo_dns_key", "zone_signing_keys.#", "1"),
43+
testExtractResourceAttr("data.google_dns_keys.foo_dns_key", "key_signing_keys.0.digests.0.digest", &kskDigest2),
44+
testExtractResourceAttr("data.google_dns_keys.foo_dns_key_id", "zone_signing_keys.0.public_key", &zskPubKey2),
45+
testExtractResourceAttr("data.google_dns_keys.foo_dns_key_id", "key_signing_keys.0.algorithm", &kskAlg2),
46+
testCheckAttributeValuesEqual(&kskDigest1, &kskDigest2),
47+
testCheckAttributeValuesEqual(&zskPubKey1, &zskPubKey2),
48+
testCheckAttributeValuesEqual(&kskAlg1, &kskAlg2),
2949
),
3050
},
3151
},
@@ -35,15 +55,23 @@ func TestAccDataSourceDNSKeys_basic(t *testing.T) {
3555
func TestAccDataSourceDNSKeys_noDnsSec(t *testing.T) {
3656
t.Parallel()
3757

38-
dnsZoneName := fmt.Sprintf("data-dnskey-test-%s", randString(t, 10))
58+
dnsZoneName := fmt.Sprintf("tf-dnskey-test-%s", randString(t, 10))
3959

4060
vcrTest(t, resource.TestCase{
4161
PreCheck: func() { testAccPreCheck(t) },
42-
Providers: testAccProviders,
43-
CheckDestroy: testAccCheckDNSManagedZoneDestroyProducer(t),
62+
CheckDestroy: testAccCheckDNSManagedZoneDestroyProducerFramework(t),
4463
Steps: []resource.TestStep{
4564
{
46-
Config: testAccDataSourceDNSKeysConfig(dnsZoneName, "off"),
65+
ExternalProviders: providerVersion450(),
66+
Config: testAccDataSourceDNSKeysConfig(dnsZoneName, "off"),
67+
Check: resource.ComposeTestCheckFunc(
68+
resource.TestCheckResourceAttr("data.google_dns_keys.foo_dns_key", "key_signing_keys.#", "0"),
69+
resource.TestCheckResourceAttr("data.google_dns_keys.foo_dns_key", "zone_signing_keys.#", "0"),
70+
),
71+
},
72+
{
73+
ProtoV5ProviderFactories: protoV5ProviderFactories(t),
74+
Config: testAccDataSourceDNSKeysConfig(dnsZoneName, "off"),
4775
Check: resource.ComposeTestCheckFunc(
4876
resource.TestCheckResourceAttr("data.google_dns_keys.foo_dns_key", "key_signing_keys.#", "0"),
4977
resource.TestCheckResourceAttr("data.google_dns_keys.foo_dns_key", "zone_signing_keys.#", "0"),

0 commit comments

Comments
 (0)