Skip to content

Commit

Permalink
fix: don't compare TTL when checking if record matches
Browse files Browse the repository at this point in the history
  • Loading branch information
b12f committed Aug 13, 2024
1 parent f11ba09 commit 4c35288
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hostingde/record_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (r *recordResource) Create(ctx context.Context, req resource.CreateRequest,

var returnedRecord DNSRecord
for _, responseRecord := range recordResp.Response.Records {
if responseRecord.Name == record.Name && responseRecord.Type == record.Type && responseRecord.TTL == record.TTL {
if responseRecord.Name == record.Name && responseRecord.Type == record.Type {
if responseRecord.Content == record.Content {
returnedRecord = responseRecord
break;
Expand Down Expand Up @@ -255,7 +255,7 @@ func (r *recordResource) Update(ctx context.Context, req resource.UpdateRequest,

var returnedRecord DNSRecord
for _, responseRecord := range recordResp.Response.Records {
if responseRecord.Name == record.Name && responseRecord.Type == record.Type && responseRecord.TTL == record.TTL {
if responseRecord.Name == record.Name && responseRecord.Type == record.Type {
if responseRecord.Content == record.Content {
returnedRecord = responseRecord
break;
Expand Down
28 changes: 28 additions & 0 deletions hostingde/record_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ resource "hostingde_record" "test_mx" {
content = "mail.example2.test"
priority = 10
}
resource "hostingde_record" "test_mx" {
zone_id = hostingde_zone.test.id
name = "example2.test"
type = "MX"
content = "mail.example2.test"
priority = 10
}
`,
Check: resource.ComposeAggregateTestCheckFunc(
// Verify name attribute.
Expand Down Expand Up @@ -142,6 +149,27 @@ resource "hostingde_record" "test_mx" {
resource.TestCheckResourceAttr("hostingde_record.test_mx", "priority", "20"),
),
},
// Update and Read testing for TXT records
{
Config: providerConfig + `
resource "hostingde_zone" "test" {
name = "example2.test"
type = "NATIVE"
email = "[email protected]"
}
resource "hostingde_record" "test_dkim" {
zone_id = hostingde_zone.test.id
name = "default._domainkey.example2.test"
type = "TXT"
content = "v=DKIM1;k=rsa;p=MiibiJanbGKQHKIg9W0baqefaaocaq8amiibcGkcaqeaYLA9Hw3tVOxVzqXWZAj4sz9ICT1hu3e6+fWlwNIgE6tIpTCyRJtiSIUDqB8TLTIBoxIs+QQBXZi+QUi3Agu6OSY2RiV0EwO8+OooQod9PerFTC/AQE51CxUV4KpQWVPxebWRxfwvm+vXIVeUBuj7EkKfYxjPELV0lSLxV/mMyBuYED6Df+REogzcSVNBIrV74QDXBal/25J62e8wRNXzJwhUtx/JhdBOjsHBvuw9hy6rZsVJL9eXayWyGRV6qmsLRzsRSBs+mDrgmKk4dugADd11+A03ics3i8hplRoWDkqnNKz1qy4f5TsV6v9283IANrAzRfHwX8EvNiFsBz+ZCQIDAQAB"
ttl = 300
}
`,
Check: resource.ComposeAggregateTestCheckFunc(
// Verify content attribute.
resource.TestCheckResourceAttr("hostingde_record.test_dkim", "content", "v=DKIM1;k=rsa;p=MiibiJanbGKQHKIg9W0baqefaaocaq8amiibcGkcaqeaYLA9Hw3tVOxVzqXWZAj4sz9ICT1hu3e6+fWlwNIgE6tIpTCyRJtiSIUDqB8TLTIBoxIs+QQBXZi+QUi3Agu6OSY2RiV0EwO8+OooQod9PerFTC/AQE51CxUV4KpQWVPxebWRxfwvm+vXIVeUBuj7EkKfYxjPELV0lSLxV/mMyBuYED6Df+REogzcSVNBIrV74QDXBal/25J62e8wRNXzJwhUtx/JhdBOjsHBvuw9hy6rZsVJL9eXayWyGRV6qmsLRzsRSBs+mDrgmKk4dugADd11+A03ics3i8hplRoWDkqnNKz1qy4f5TsV6v9283IANrAzRfHwX8EvNiFsBz+ZCQIDAQAB"),
),
},
// Delete testing automatically occurs in TestCase
},
})
Expand Down

0 comments on commit 4c35288

Please sign in to comment.