Skip to content

Commit

Permalink
[Az.Dns] Add NAPTR support and tests (#26239)
Browse files Browse the repository at this point in the history
* Add NAPTR support and tests

* Updated the test results

* Update recordings and merge main

* Update changelog and help sections for NAPTR record type

* Updating signatures in staticanalysis exceptions and typo fixes in samples

* Updated the typo in doc and updated the sdk version to 1.2.2

* Fix the changelog as per the documentation

* Remove empty line

---------

Co-authored-by: Sandeep Kadagathur Vadiraj <[email protected]>
  • Loading branch information
WhiteHorseV and Sandeep Kadagathur Vadiraj authored Oct 31, 2024
1 parent 90206f7 commit 4f9e087
Show file tree
Hide file tree
Showing 67 changed files with 12,603 additions and 11,576 deletions.
14 changes: 14 additions & 0 deletions src/Dns/Dns.Test/ScenarioTests/RecordsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,20 @@ public void TestRecordSetPTRNonEmpty()
TestRunner.RunTestScript("Test-RecordSetPTRNonEmpty");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRecordSetNAPTR()
{
TestRunner.RunTestScript("Test-RecordSetNAPTR");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRecordSetNAPTRNonEmpty()
{
TestRunner.RunTestScript("Test-RecordSetNAPTRNonEmpty");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRecordSetnewAlreadyExists()
Expand Down
81 changes: 81 additions & 0 deletions src/Dns/Dns.Test/ScenarioTests/RecordsTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,87 @@ function Test-RecordSetMXNonEmpty
Remove-AzResourceGroup -Name $resourceGroup.ResourceGroupName -Force
}

<#
.SYNOPSIS
Full Record Set CRUD cycle
#>
function Test-RecordSetNAPTR
{
$zoneName = Get-RandomZoneName
$recordName = getAssetname
$resourceGroup = TestSetup-CreateResourceGroup
$zone = $resourceGroup | New-AzDnsZone -Name $zoneName

$record = $zone | New-AzDnsRecordSet -Name $recordName -Ttl 100 -RecordType NAPTR

# add two records, remove one, remove another no-op
$record = $record | Add-AzDnsRecordConfig -Order 10 -Preference 20 -Flags "U" -Services "SIP+D2U" -Regexp "" -Replacement "_sip._udp.example.com."
$record = $record | Add-AzDnsRecordConfig -Order 20 -Preference 30 -Flags "A" -Services "EAU+SIP" -Regexp "!^.*$!mailto:[email protected]!" -Replacement "."
$record = $record | Remove-AzDnsRecordConfig -Order 10 -Preference 20 -Flags "U" -Services "SIP+D2U" -Regexp "" -Replacement "_sip._udp.example.com."
$record = $record | Remove-AzDnsRecordConfig -Order 30 -Preference 30 -Flags "A" -Services "EAU+SIP" -Regexp "!^.*$!mailto:[email protected]!" -Replacement "."

$record | Set-AzDnsRecordSet
$getResult = Get-AzDnsRecordSet -Name $recordName -ZoneName $zoneName -ResourceGroupName $resourceGroup.ResourceGroupName -RecordType NAPTR

Assert-AreEqual 1 $getResult.Records.Count
Assert-AreEqual 20 $getResult.Records[0].Order
Assert-AreEqual 30 $getResult.Records[0].Preference
Assert-AreEqual "A" $getResult.Records[0].Flags
Assert-AreEqual "EAU+SIP" $getResult.Records[0].Services
Assert-AreEqual "!^.*$!mailto:[email protected]!" $getResult.Records[0].Regexp
Assert-AreEqual "." $getResult.Records[0].Replacement

$listResult = Get-AzDnsRecordSet -ZoneName $zoneName -ResourceGroupName $resourceGroup.ResourceGroupName -RecordType NAPTR

Assert-AreEqual 1 $listResult[0].Records.Count
Assert-AreEqual 20 $getResult.Records[0].Order
Assert-AreEqual 30 $getResult.Records[0].Preference
Assert-AreEqual "A" $getResult.Records[0].Flags
Assert-AreEqual "EAU+SIP" $getResult.Records[0].Services
Assert-AreEqual "!^.*$!mailto:[email protected]!" $getResult.Records[0].Regexp
Assert-AreEqual "." $getResult.Records[0].Replacement

$removed = $listResult[0] | Remove-AzDnsRecordSet -Confirm:$false -PassThru

Assert-True { $removed }

Remove-AzDnsZone -Name $zoneName -ResourceGroupName $resourceGroup.ResourceGroupName -Confirm:$false
Remove-AzResourceGroup -Name $resourceGroup.ResourceGroupName -Force
}

<#
.SYNOPSIS
Full Record Set CRUD cycle
#>
function Test-RecordSetNAPTRNonEmpty
{
$zoneName = Get-RandomZoneName
$recordName = getAssetname
$resourceGroup = TestSetup-CreateResourceGroup
$zone = $resourceGroup | New-AzDnsZone -Name $zoneName

$records = @();
$records += New-AzDnsRecordConfig -Order 10 -Preference 20 -Flags "U" -Services "SIP+D2U" -Regexp "" -Replacement "_sip._udp.example.com."
$record = $zone | New-AzDnsRecordSet -Name $recordName -Ttl 100 -RecordType NAPTR -DnsRecords $records

$getResult = Get-AzDnsRecordSet -Name $recordName -ZoneName $zoneName -ResourceGroupName $resourceGroup.ResourceGroupName -RecordType NAPTR

Assert-AreEqual 1 $getResult.Records.Count
Assert-AreEqual 10 $getResult.Records[0].Order
Assert-AreEqual 20 $getResult.Records[0].Preference
Assert-AreEqual "U" $getResult.Records[0].Flags
Assert-AreEqual "SIP+D2U" $getResult.Records[0].Services
Assert-AreEqual "" $getResult.Records[0].Regexp
Assert-AreEqual "_sip._udp.example.com." $getResult.Records[0].Replacement

$removed = $getResult[0] | Remove-AzDnsRecordSet -Confirm:$false -PassThru

Assert-True { $removed }

Remove-AzDnsZone -Name $zoneName -ResourceGroupName $resourceGroup.ResourceGroupName -Confirm:$false
Remove-AzResourceGroup -Name $resourceGroup.ResourceGroupName -Force
}

<#
.SYNOPSIS
Full Record Set CRUD cycle
Expand Down
Loading

0 comments on commit 4f9e087

Please sign in to comment.