Skip to content

Commit

Permalink
Feature/resource id management (#339)
Browse files Browse the repository at this point in the history
* Added support for Terraform Internal ID EA to AAAA, PTR, SRV, TXT.

* Added support for Terraform Internal ID EA to dns view and zone auth.

* - Added Prerequisites for TF_ACC test cases.
- Added Dependencies to test files.
- Updated record search with new field internal ID
  • Loading branch information
JchhatbarInfoblox authored Apr 5, 2024
1 parent 50dea20 commit e14444b
Show file tree
Hide file tree
Showing 32 changed files with 1,679 additions and 641 deletions.
11 changes: 10 additions & 1 deletion infoblox/datasource_infoblox_a_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ func TestAccDataSourceARecord(t *testing.T) {
}

var testAccDataSourceARecordsRead = fmt.Sprintf(`
resource "infoblox_zone_auth" "test" {
fqdn = "test.com"
}
resource "infoblox_a_record" "foo"{
dns_view="default"
fqdn="test-name.test.com"
ip_addr="10.0.0.20"
depends_on = [infoblox_zone_auth.test]
}
data "infoblox_a_record" "acctest" {
Expand All @@ -48,6 +53,9 @@ func TestAccDataSourceARecordSearchByEA(t *testing.T) {
Steps: []resource.TestStep{
resource.TestStep{
Config: fmt.Sprintf(`
resource "infoblox_zone_auth" "test" {
fqdn = "test.com"
}
resource "infoblox_a_record" "arec1"{
ip_addr = "10.4.0.18"
fqdn = "sample.test.com"
Expand All @@ -56,6 +64,7 @@ func TestAccDataSourceARecordSearchByEA(t *testing.T) {
ext_attrs = jsonencode({
"Location": "Las Vegas"
})
depends_on = [infoblox_zone_auth.test]
}
data "infoblox_a_record" "ds1" {
Expand All @@ -70,7 +79,7 @@ func TestAccDataSourceARecordSearchByEA(t *testing.T) {
resource.TestCheckResourceAttr("data.infoblox_a_record.ds1", "results.0.ip_addr", "10.4.0.18"),
resource.TestCheckResourceAttr("data.infoblox_a_record.ds1", "results.0.fqdn", "sample.test.com"),
resource.TestCheckResourceAttr("data.infoblox_a_record.ds1", "results.0.comment", "test sample A-record"),
resource.TestCheckResourceAttr("data.infoblox_a_record.ds1", "results.0.ext_attrs", "{\"Location\":\"Las Vegas\"}"),
resource.TestCheckResourceAttrPair("data.infoblox_a_record.ds1", "results.0.ext_attrs.Location", "infoblox_a_record.arec1", "ext_attrs.Location"),
),
},
},
Expand Down
10 changes: 9 additions & 1 deletion infoblox/datasource_infoblox_aaaa_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ func TestAccDataSourceAAAARecord(t *testing.T) {
}

var testAccDataSourceAAAARecordsRead = fmt.Sprintf(`
resource "infoblox_zone_auth" "test" {
fqdn = "test.com"
}
resource "infoblox_aaaa_record" "foo"{
dns_view="default"
fqdn="aaaa-test.test.com"
ipv6_addr="2002:1111::7"
depends_on = [infoblox_zone_auth.test]
}
data "infoblox_aaaa_record" "acctest" {
Expand All @@ -48,6 +52,9 @@ func TestAccDataSourceAAAARecordSearchByEA(t *testing.T) {
Steps: []resource.TestStep{
resource.TestStep{
Config: fmt.Sprintf(`
resource "infoblox_zone_auth" "test" {
fqdn = "test.com"
}
resource "infoblox_aaaa_record" "qarec1"{
ipv6_addr = "2002:1f93:0:4::11"
fqdn = "sampleqa.test.com"
Expand All @@ -56,6 +63,7 @@ func TestAccDataSourceAAAARecordSearchByEA(t *testing.T) {
ext_attrs = jsonencode({
"Location": "Norway"
})
depends_on = [infoblox_zone_auth.test]
}
data "infoblox_aaaa_record" "dqa1" {
Expand All @@ -71,7 +79,7 @@ func TestAccDataSourceAAAARecordSearchByEA(t *testing.T) {
resource.TestCheckResourceAttr("data.infoblox_aaaa_record.dqa1", "results.0.ipv6_addr", "2002:1f93:0:4::11"),
resource.TestCheckResourceAttr("data.infoblox_aaaa_record.dqa1", "results.0.fqdn", "sampleqa.test.com"),
resource.TestCheckResourceAttr("data.infoblox_aaaa_record.dqa1", "results.0.comment", "test sample AAAA-record"),
resource.TestCheckResourceAttr("data.infoblox_aaaa_record.dqa1", "results.0.ext_attrs", "{\"Location\":\"Norway\"}"),
resource.TestCheckResourceAttrPair("data.infoblox_aaaa_record.dqa1", "results.0.ext_attrs.Location", "infoblox_aaaa_record.qarec1", "ext_attrs.Location"),
),
},
},
Expand Down
12 changes: 10 additions & 2 deletions infoblox/datasource_infoblox_cname_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ func TestAccDataSourceCNameRecord(t *testing.T) {
}

var testAccDataSourceCNameRecordsRead = fmt.Sprintf(`
resource "infoblox_zone_auth" "test" {
fqdn = "test.com"
}
resource "infoblox_cname_record" "foo"{
dns_view="default"
alias="test.test.com"
canonical="test-name.test.com"
canonical="test-name.test.com"
depends_on = [infoblox_zone_auth.test]
}
data "infoblox_cname_record" "acctest" {
Expand All @@ -49,6 +53,9 @@ func TestAccDataSourceCNameRecordSearchByEA(t *testing.T) {
Steps: []resource.TestStep{
resource.TestStep{
Config: fmt.Sprintf(`
resource "infoblox_zone_auth" "test" {
fqdn = "test.com"
}
resource "infoblox_cname_record" "cname1"{
canonical = "somewhere.in.the.net"
alias = "samplecname.test.com"
Expand All @@ -57,6 +64,7 @@ func TestAccDataSourceCNameRecordSearchByEA(t *testing.T) {
ext_attrs = jsonencode({
"Site": "test site one"
})
depends_on = [infoblox_zone_auth.test]
}
data "infoblox_cname_record" "dcname1" {
Expand All @@ -71,7 +79,7 @@ func TestAccDataSourceCNameRecordSearchByEA(t *testing.T) {
resource.TestCheckResourceAttr("data.infoblox_cname_record.dcname1", "results.0.canonical", "somewhere.in.the.net"),
resource.TestCheckResourceAttr("data.infoblox_cname_record.dcname1", "results.0.alias", "samplecname.test.com"),
resource.TestCheckResourceAttr("data.infoblox_cname_record.dcname1", "results.0.comment", "test sample CName-record"),
resource.TestCheckResourceAttr("data.infoblox_cname_record.dcname1", "results.0.ext_attrs", "{\"Site\":\"test site one\"}"),
resource.TestCheckResourceAttrPair("data.infoblox_cname_record.dcname1", "results.0.ext_attrs.Site", "infoblox_cname_record.cname1", "ext_attrs.Site"),
),
},
},
Expand Down
2 changes: 1 addition & 1 deletion infoblox/datasource_infoblox_dns_view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestAccDataSourceDNSViewSearchByEA(t *testing.T) {
resource.TestCheckResourceAttr("data.infoblox_dns_view.accview", "results.0.name", "customview"),
resource.TestCheckResourceAttr("data.infoblox_dns_view.accview", "results.0.network_view", "default"),
resource.TestCheckResourceAttr("data.infoblox_dns_view.accview", "results.0.comment", "new dns view example"),
resource.TestCheckResourceAttr("data.infoblox_dns_view.accview", "results.0.ext_attrs", "{\"Site\":\"Main DNS Site\"}"),
resource.TestCheckResourceAttrPair("data.infoblox_dns_view.accview", "results.0.ext_attrs.Site", "infoblox_dns_view.dview1", "ext_attrs.Site"),
),
},
},
Expand Down
27 changes: 24 additions & 3 deletions infoblox/datasource_infoblox_mx_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ func TestAccDataSourceMXRecord(t *testing.T) {
resource.TestCheckResourceAttr("data.infoblox_mx_record.rec1", "results.0.fqdn", "test-name.test.com"),
resource.TestCheckResourceAttr("data.infoblox_mx_record.rec1", "results.0.mail_exchanger", "mx-test.test.com"),
resource.TestCheckResourceAttr("data.infoblox_mx_record.rec1", "results.0.preference", "25"),
//resource.TestCheckResourceAttr("data.infoblox_mx_record.rec1", "ttl", ""),
resource.TestCheckResourceAttr("data.infoblox_mx_record.rec1", "results.0.comment", ""),

resource.TestCheckResourceAttr("data.infoblox_mx_record.rec2", "results.0.dns_view", "nondefault_view"),
Expand All @@ -28,19 +27,24 @@ func TestAccDataSourceMXRecord(t *testing.T) {
resource.TestCheckResourceAttr("data.infoblox_mx_record.rec2", "results.0.preference", "25"),
resource.TestCheckResourceAttr("data.infoblox_mx_record.rec2", "results.0.ttl", "10"),
resource.TestCheckResourceAttr("data.infoblox_mx_record.rec2", "results.0.comment", "non-empty comment"),
resource.TestCheckResourceAttr("data.infoblox_mx_record.rec2", "results.0.ext_attrs", "{\"Site\":\"None\"}"),
resource.TestCheckResourceAttrPair("data.infoblox_mx_record.rec2", "results.0.ext_attrs.Site", "infoblox_mx_record.rec2", "ext_attrs.Site"),
),
},
},
})
}

var testAccDataSourceMXRecordsRead = fmt.Sprintf(`
resource "infoblox_zone_auth" "test" {
fqdn = "test.com"
}
resource "infoblox_mx_record" "rec1" {
dns_view = "default"
fqdn = "test-name.test.com"
mail_exchanger = "mx-test.test.com"
preference = 25
depends_on = [infoblox_zone_auth.test]
}
data "infoblox_mx_record" "rec1" {
Expand All @@ -54,6 +58,17 @@ data "infoblox_mx_record" "rec1" {
depends_on = [infoblox_mx_record.rec1]
}
resource "infoblox_dns_view" "view" {
name = "nondefault_view"
network_view = "default"
}
resource "infoblox_zone_auth" "test2" {
fqdn = "test.com"
view = "nondefault_view"
depends_on = [infoblox_dns_view.view]
}
resource "infoblox_mx_record" "rec2" {
dns_view = "nondefault_view"
fqdn = "test-name2.test.com"
Expand All @@ -65,6 +80,7 @@ resource "infoblox_mx_record" "rec2" {
ext_attrs = jsonencode({
"Site": "None"
})
depends_on = [infoblox_zone_auth.test2]
}
data "infoblox_mx_record" "rec2" {
Expand All @@ -86,6 +102,10 @@ func TestAccDataSourceMXRecordSearchByEA(t *testing.T) {
Steps: []resource.TestStep{
resource.TestStep{
Config: fmt.Sprintf(`
resource "infoblox_zone_auth" "test" {
fqdn = "test.com"
}
resource "infoblox_mx_record" "mx1"{
fqdn = "samplemx.test.com"
mail_exchanger = "exdemo.test.com"
Expand All @@ -96,6 +116,7 @@ func TestAccDataSourceMXRecordSearchByEA(t *testing.T) {
ext_attrs = jsonencode({
"Site": "Some automated site"
})
depends_on = [infoblox_zone_auth.test]
}
data "infoblox_mx_record" "dmx1" {
Expand All @@ -111,7 +132,7 @@ func TestAccDataSourceMXRecordSearchByEA(t *testing.T) {
resource.TestCheckResourceAttr("data.infoblox_mx_record.dmx1", "results.0.preference", "30"),
resource.TestCheckResourceAttr("data.infoblox_mx_record.dmx1", "results.0.fqdn", "samplemx.test.com"),
resource.TestCheckResourceAttr("data.infoblox_mx_record.dmx1", "results.0.comment", "new sample mx-record"),
resource.TestCheckResourceAttr("data.infoblox_mx_record.dmx1", "results.0.ext_attrs", "{\"Site\":\"Some automated site\"}"),
resource.TestCheckResourceAttrPair("data.infoblox_mx_record.dmx1", "results.0.ext_attrs.Site", "infoblox_mx_record.mx1", "ext_attrs.Site"),
),
},
},
Expand Down
4 changes: 2 additions & 2 deletions infoblox/datasource_infoblox_network_container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestAccDataSourceNetworkContainer(t *testing.T) {
resource.TestCheckResourceAttr("data.infoblox_ipv4_network_container.ds1", "results.#", "1"),
resource.TestCheckResourceAttr("data.infoblox_ipv4_network_container.ds1", "results.0.cidr", "10.4.20.0/24"),
resource.TestCheckResourceAttr("data.infoblox_ipv4_network_container.ds1", "results.0.comment", "network container #1"),
resource.TestCheckResourceAttr("data.infoblox_ipv4_network_container.ds1", "results.0.ext_attrs", "{\"Location\":\"North Pole\"}"),
resource.TestCheckResourceAttrPair("data.infoblox_ipv4_network_container.ds1", "results.0.ext_attrs.Location", "infoblox_ipv4_network_container.nc1", "ext_attrs.Location"),
),
},
},
Expand Down Expand Up @@ -67,7 +67,7 @@ func TestAccDataSourceNetworkCOntainerSearchByEA(t *testing.T) {
resource.TestCheckResourceAttr("data.infoblox_ipv4_network_container.ds1", "results.#", "1"),
resource.TestCheckResourceAttr("data.infoblox_ipv4_network_container.ds1", "results.0.cidr", "10.4.20.0/24"),
resource.TestCheckResourceAttr("data.infoblox_ipv4_network_container.ds1", "results.0.comment", "network container #1"),
resource.TestCheckResourceAttr("data.infoblox_ipv4_network_container.ds1", "results.0.ext_attrs", "{\"Location\":\"North Pole\"}"),
resource.TestCheckResourceAttrPair("data.infoblox_ipv4_network_container.ds1", "results.0.ext_attrs.Location", "infoblox_ipv4_network_container.nc1", "ext_attrs.Location"),
),
},
},
Expand Down
2 changes: 1 addition & 1 deletion infoblox/datasource_infoblox_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestAccDataSourceNetworkReadByEA(t *testing.T) {
resource.TestCheckResourceAttr("data.infoblox_ipv4_network.acctest", "results.0.network_view", "default"),
resource.TestCheckResourceAttr("data.infoblox_ipv4_network.acctest", "results.0.cidr", "10.4.20.0/24"),
resource.TestCheckResourceAttr("data.infoblox_ipv4_network.acctest", "results.0.comment", "Created by terraform-provider-infoblox acceptance test"),
resource.TestCheckResourceAttr("data.infoblox_ipv4_network.acctest", "results.0.ext_attrs", "{\"Building\":\"AcceptanceTerraform\"}"),
resource.TestCheckResourceAttrPair("data.infoblox_ipv4_network.acctest", "results.0.ext_attrs.Building", "infoblox_ipv4_network.test_network", "ext_attrs.Building"),
),
},
},
Expand Down
2 changes: 1 addition & 1 deletion infoblox/datasource_infoblox_network_view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestAccDataSourceNetworkViewReadByEA(t *testing.T) {
resource.TestCheckResourceAttr("data.infoblox_network_view.acctest", "results.#", "1"),
resource.TestCheckResourceAttr("data.infoblox_network_view.acctest", "results.0.name", "testNetworkView"),
resource.TestCheckResourceAttr("data.infoblox_network_view.acctest", "results.0.comment", "test comment 1"),
resource.TestCheckResourceAttr("data.infoblox_network_view.acctest", "results.0.ext_attrs", "{\"Location\":\"AcceptanceTerraform\"}"),
resource.TestCheckResourceAttrPair("data.infoblox_network_view.acctest", "results.0.ext_attrs.Location", "infoblox_network_view.test_network_view", "ext_attrs.Location"),
),
},
},
Expand Down
71 changes: 54 additions & 17 deletions infoblox/datasource_infoblox_ptr_record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,38 @@ func TestAccDataSourcePTRRecord(t *testing.T) {
resource.TestCheckResourceAttr("data.infoblox_ptr_record.ds1", "results.0.ip_addr", "2002:1f93::10"),
resource.TestCheckResourceAttr("data.infoblox_ptr_record.ds1", "results.0.ttl", "300"),
resource.TestCheckResourceAttr("data.infoblox_ptr_record.ds1", "results.0.comment", "workstation #1"),
resource.TestCheckResourceAttr("data.infoblox_ptr_record.ds1", "results.0.ext_attrs", "{\"Location\":\"the main office\"}"),
resource.TestCheckResourceAttrPair("data.infoblox_ptr_record.ds1", "results.0.ext_attrs.Location", "infoblox_ptr_record.rec1", "ext_attrs.Location"),

resource.TestCheckResourceAttr("data.infoblox_ptr_record.ds2", "results.0.dns_view", "default"),
resource.TestCheckResourceAttr("data.infoblox_ptr_record.ds2", "results.0.ptrdname", "rec2.test.com"),
resource.TestCheckResourceAttr("data.infoblox_ptr_record.ds2", "results.0.ip_addr", "10.0.0.101"),
resource.TestCheckResourceAttr("data.infoblox_ptr_record.ds2", "results.0.ttl", "301"),
resource.TestCheckResourceAttr("data.infoblox_ptr_record.ds2", "results.0.comment", "workstation #2"),
resource.TestCheckResourceAttr("data.infoblox_ptr_record.ds2", "results.0.ext_attrs", "{\"Location\":\"the external office\"}"),
resource.TestCheckResourceAttrPair("data.infoblox_ptr_record.ds2", "results.0.ext_attrs.Location", "infoblox_ptr_record.rec2", "ext_attrs.Location"),
),
},
},
})
}

var testAccDataSourcePTRRecordsRead = `
resource "infoblox_dns_view" "view" {
name = "nondefault_dnsview1"
}
resource "infoblox_zone_auth" "test" {
fqdn = "test.com"
view = "nondefault_dnsview1"
depends_on = [infoblox_dns_view.view]
}
resource "infoblox_zone_auth" "itest" {
fqdn = "2002:1f93::/64"
view = "nondefault_dnsview1"
zone_format = "IPV6"
depends_on = [infoblox_dns_view.view]
}
resource "infoblox_ptr_record" "rec1" {
ptrdname = "rec1.test.com"
dns_view = "nondefault_dnsview1"
Expand All @@ -44,27 +61,38 @@ resource "infoblox_ptr_record" "rec1" {
ext_attrs = jsonencode({
"Location" = "the main office"
})
depends_on = [infoblox_zone_auth.test, infoblox_zone_auth.itest]
}
data "infoblox_ptr_record" "ds1" {
filters = {
ptrdname = "rec1.test.com"
view = "nondefault_dnsview1"
ipv6addr = "2002:1f93::10"
}
filters = {
ptrdname = "rec1.test.com"
view = "nondefault_dnsview1"
ipv6addr = "2002:1f93::10"
}
depends_on = [infoblox_ptr_record.rec1]
}
depends_on = [infoblox_ptr_record.rec1]
resource "infoblox_zone_auth" "test1" {
fqdn = "test.com"
}
resource "infoblox_zone_auth" "itest1" {
fqdn = "10.0.0.0/24"
zone_format = "IPV4"
depends_on = [infoblox_zone_auth.test1]
}
resource "infoblox_ptr_record" "rec2" {
ptrdname = "rec2.test.com"
// the default 'dns_view'
ip_addr = "10.0.0.101"
comment = "workstation #2"
ttl = 301
ext_attrs = jsonencode({
"Location" = "the external office"
})
ptrdname = "rec2.test.com"
// the default 'dns_view'
ip_addr = "10.0.0.101"
comment = "workstation #2"
ttl = 301
ext_attrs = jsonencode({
"Location" = "the external office"
})
depends_on = [infoblox_zone_auth.test1, infoblox_zone_auth.itest1]
}
data "infoblox_ptr_record" "ds2" {
Expand All @@ -85,6 +113,14 @@ func TestAccDataSourcePTRRecordSearchByEA(t *testing.T) {
Steps: []resource.TestStep{
resource.TestStep{
Config: fmt.Sprintf(`
resource "infoblox_zone_auth" "test" {
fqdn = "test.com"
}
resource "infoblox_zone_auth" "itest" {
fqdn = "10.0.0.0/24"
zone_format = "IPV4"
depends_on = [infoblox_zone_auth.test]
}
resource "infoblox_ptr_record" "ptr1"{
ptrdname = "decoyptr.test.com"
ip_addr = "10.0.0.89"
Expand All @@ -93,6 +129,7 @@ func TestAccDataSourcePTRRecordSearchByEA(t *testing.T) {
ext_attrs = jsonencode({
"Location" = "PTR test location"
})
depends_on = [infoblox_zone_auth.itest, infoblox_zone_auth.test]
}
data "infoblox_ptr_record" "dptr1" {
Expand All @@ -107,7 +144,7 @@ func TestAccDataSourcePTRRecordSearchByEA(t *testing.T) {
resource.TestCheckResourceAttr("data.infoblox_ptr_record.dptr1", "results.0.ip_addr", "10.0.0.89"),
resource.TestCheckResourceAttr("data.infoblox_ptr_record.dptr1", "results.0.ptrdname", "decoyptr.test.com"),
resource.TestCheckResourceAttr("data.infoblox_ptr_record.dptr1", "results.0.comment", "new sample ptr-record"),
resource.TestCheckResourceAttr("data.infoblox_ptr_record.dptr1", "results.0.ext_attrs", "{\"Location\":\"PTR test location\"}"),
resource.TestCheckResourceAttrPair("data.infoblox_ptr_record.dptr1", "results.0.ext_attrs.Location", "infoblox_ptr_record.ptr1", "ext_attrs.Location"),
),
},
},
Expand Down
Loading

0 comments on commit e14444b

Please sign in to comment.