@@ -15,144 +15,24 @@ func TestAccDataSourceGoogleNetblockIpRanges_basic(t *testing.T) {
15
15
{
16
16
Config : testAccNetblockIpRangesConfig ,
17
17
Check : resource .ComposeTestCheckFunc (
18
- // Cloud netblocks
19
- resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.cloud" ,
18
+ resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.some" ,
20
19
"cidr_blocks.#" , regexp .MustCompile (("^[1-9]+[0-9]*$" ))),
21
- resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.cloud " ,
20
+ resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.some " ,
22
21
"cidr_blocks.0" , regexp .MustCompile ("^(?:[0-9a-fA-F./:]{1,4}){1,2}.*/[0-9]{1,3}$" )),
23
- resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.cloud " ,
22
+ resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.some " ,
24
23
"cidr_blocks_ipv4.#" , regexp .MustCompile (("^[1-9]+[0-9]*$" ))),
25
- resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.cloud " ,
24
+ resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.some " ,
26
25
"cidr_blocks_ipv4.0" , regexp .MustCompile ("^(?:[0-9]{1,3}.){3}[0-9]{1,3}/[0-9]{1,2}$" )),
27
- resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.cloud " ,
26
+ resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.some " ,
28
27
"cidr_blocks_ipv6.#" , regexp .MustCompile (("^[1-9]+[0-9]*$" ))),
29
- resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.cloud " ,
28
+ resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.some " ,
30
29
"cidr_blocks_ipv6.0" , regexp .MustCompile ("^(?:[0-9a-fA-F]{1,4}:){1,2}.*/[0-9]{1,3}$" )),
31
30
),
32
31
},
33
- {
34
- Config : testAccNetblockIpRangesConfig_google ,
35
- Check : resource .ComposeTestCheckFunc (
36
- // Google netblocks
37
- resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.google" ,
38
- "cidr_blocks.#" , regexp .MustCompile (("^[1-9]+[0-9]*$" ))),
39
- resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.google" ,
40
- "cidr_blocks.0" , regexp .MustCompile ("^(?:[0-9a-fA-F./:]{1,4}){1,2}.*/[0-9]{1,3}$" )),
41
- resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.google" ,
42
- "cidr_blocks_ipv4.#" , regexp .MustCompile (("^[1-9]+[0-9]*$" ))),
43
- resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.google" ,
44
- "cidr_blocks_ipv4.0" , regexp .MustCompile ("^(?:[0-9]{1,3}.){3}[0-9]{1,3}/[0-9]{1,2}$" )),
45
- resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.google" ,
46
- "cidr_blocks_ipv6.#" , regexp .MustCompile (("^[1-9]+[0-9]*$" ))),
47
- resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.google" ,
48
- "cidr_blocks_ipv6.0" , regexp .MustCompile ("^(?:[0-9a-fA-F]{1,4}:){1,2}.*/[0-9]{1,3}$" )),
49
- ),
50
- },
51
- {
52
- Config : testAccNetblockIpRangesConfig_restricted ,
53
- Check : resource .ComposeTestCheckFunc (
54
- // Private Google Access Restricted VIP
55
- resource .TestCheckResourceAttr ("data.google_netblock_ip_ranges.restricted" , "cidr_blocks.#" , "1" ),
56
- resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.restricted" ,
57
- "cidr_blocks.0" , regexp .MustCompile ("^(?:[0-9a-fA-F./:]{1,4}){1,2}.*/[0-9]{1,3}$" )),
58
- resource .TestCheckResourceAttr ("data.google_netblock_ip_ranges.restricted" , "cidr_blocks_ipv4.#" , "1" ),
59
- resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.restricted" ,
60
- "cidr_blocks_ipv4.0" , regexp .MustCompile ("^(?:[0-9]{1,3}.){3}[0-9]{1,3}/[0-9]{1,2}$" )),
61
- resource .TestCheckResourceAttr ("data.google_netblock_ip_ranges.restricted" , "cidr_blocks_ipv6.#" , "0" ),
62
- ),
63
- },
64
- {
65
- Config : testAccNetblockIpRangesConfig_dns ,
66
- Check : resource .ComposeTestCheckFunc (
67
- // DNS outbound forwarding
68
- resource .TestCheckResourceAttr ("data.google_netblock_ip_ranges.dns" , "cidr_blocks.#" , "1" ),
69
- resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.dns" ,
70
- "cidr_blocks.0" , regexp .MustCompile ("^(?:[0-9a-fA-F./:]{1,4}){1,2}.*/[0-9]{1,3}$" )),
71
- resource .TestCheckResourceAttr ("data.google_netblock_ip_ranges.dns" , "cidr_blocks_ipv4.#" , "1" ),
72
- resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.dns" ,
73
- "cidr_blocks_ipv4.0" , regexp .MustCompile ("^(?:[0-9]{1,3}.){3}[0-9]{1,3}/[0-9]{1,2}$" )),
74
- resource .TestCheckResourceAttr ("data.google_netblock_ip_ranges.dns" , "cidr_blocks_ipv6.#" , "0" ),
75
- ),
76
- },
77
- {
78
- Config : testAccNetblockIpRangesConfig_iap ,
79
- Check : resource .ComposeTestCheckFunc (
80
- // IAP sources
81
- resource .TestCheckResourceAttr ("data.google_netblock_ip_ranges.iap" , "cidr_blocks.#" , "1" ),
82
- resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.iap" ,
83
- "cidr_blocks.0" , regexp .MustCompile ("^(?:[0-9a-fA-F./:]{1,4}){1,2}.*/[0-9]{1,3}$" )),
84
- resource .TestCheckResourceAttr ("data.google_netblock_ip_ranges.iap" , "cidr_blocks_ipv4.#" , "1" ),
85
- resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.iap" ,
86
- "cidr_blocks_ipv4.0" , regexp .MustCompile ("^(?:[0-9]{1,3}.){3}[0-9]{1,3}/[0-9]{1,2}$" )),
87
- resource .TestCheckResourceAttr ("data.google_netblock_ip_ranges.iap" , "cidr_blocks_ipv6.#" , "0" ),
88
- ),
89
- },
90
- {
91
- Config : testAccNetblockIpRangesConfig_hc ,
92
- Check : resource .ComposeTestCheckFunc (
93
- // Modern health checkers
94
- resource .TestCheckResourceAttr ("data.google_netblock_ip_ranges.hc" , "cidr_blocks.#" , "2" ),
95
- resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.hc" ,
96
- "cidr_blocks.0" , regexp .MustCompile ("^(?:[0-9a-fA-F./:]{1,4}){1,2}.*/[0-9]{1,3}$" )),
97
- resource .TestCheckResourceAttr ("data.google_netblock_ip_ranges.hc" , "cidr_blocks_ipv4.#" , "2" ),
98
- resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.hc" ,
99
- "cidr_blocks_ipv4.0" , regexp .MustCompile ("^(?:[0-9]{1,3}.){3}[0-9]{1,3}/[0-9]{1,2}$" )),
100
- resource .TestCheckResourceAttr ("data.google_netblock_ip_ranges.hc" , "cidr_blocks_ipv6.#" , "0" ),
101
- ),
102
- },
103
- {
104
- Config : testAccNetblockIpRangesConfig_lhc ,
105
- Check : resource .ComposeTestCheckFunc (
106
- // Legacy health checkers
107
- resource .TestCheckResourceAttr ("data.google_netblock_ip_ranges.lhc" , "cidr_blocks.#" , "3" ),
108
- resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.lhc" ,
109
- "cidr_blocks.0" , regexp .MustCompile ("^(?:[0-9a-fA-F./:]{1,4}){1,2}.*/[0-9]{1,3}$" )),
110
- resource .TestCheckResourceAttr ("data.google_netblock_ip_ranges.lhc" , "cidr_blocks_ipv4.#" , "3" ),
111
- resource .TestMatchResourceAttr ("data.google_netblock_ip_ranges.lhc" ,
112
- "cidr_blocks_ipv4.0" , regexp .MustCompile ("^(?:[0-9]{1,3}.){3}[0-9]{1,3}/[0-9]{1,2}$" )),
113
- resource .TestCheckResourceAttr ("data.google_netblock_ip_ranges.lhc" , "cidr_blocks_ipv6.#" , "0" ),
114
- ),
115
- },
116
32
},
117
33
})
118
34
}
119
35
120
36
const testAccNetblockIpRangesConfig = `
121
- data "google_netblock_ip_ranges" "cloud" {}
122
- `
123
-
124
- const testAccNetblockIpRangesConfig_google = `
125
- data "google_netblock_ip_ranges" "google" {
126
- range_type = "google-netblocks"
127
- }
128
- `
129
-
130
- const testAccNetblockIpRangesConfig_restricted = `
131
- data "google_netblock_ip_ranges" "restricted" {
132
- range_type = "restricted-googleapis"
133
- }
134
- `
135
-
136
- const testAccNetblockIpRangesConfig_dns = `
137
- data "google_netblock_ip_ranges" "dns" {
138
- range_type = "dns-forwarders"
139
- }
140
- `
141
-
142
- const testAccNetblockIpRangesConfig_iap = `
143
- data "google_netblock_ip_ranges" "iap" {
144
- range_type = "iap-forwarders"
145
- }
146
- `
147
-
148
- const testAccNetblockIpRangesConfig_hc = `
149
- data "google_netblock_ip_ranges" "hc" {
150
- range_type = "health-checkers"
151
- }
152
- `
153
-
154
- const testAccNetblockIpRangesConfig_lhc = `
155
- data "google_netblock_ip_ranges" "lhc" {
156
- range_type = "legacy-health-checkers"
157
- }
37
+ data "google_netblock_ip_ranges" "some" {}
158
38
`
0 commit comments