Skip to content

Add support for Private DNS VirtualNetwork links #8623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/PrivateDns/PrivateDns.Test/ScenarioTests/Common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ function Get-RandomZoneName
return $prefix + ".pstest.test" ;
}

function Get-RandomLinkName
{
$prefix = getAssetName;
return $prefix + ".testlink" ;
}

function Get-TxtOfSpecifiedLength([int] $length)
{
$returnValue = "";
Expand All @@ -77,4 +83,23 @@ function Get-TxtOfSpecifiedLength([int] $length)
$returnValue += "a";
}
return $returnValue;
}

function Create-VirtualNetworkLink([bool] $registrationEnabled)
{
$zoneName = Get-RandomZoneName
$linkName = Get-RandomLinkName
$resourceGroup = TestSetup-CreateResourceGroup

$createdZone = New-AzPrivateDnsZone -Name $zoneName -ResourceGroupName $resourceGroup.ResourceGroupName -Tag @{tag1="value1"}
$createdVirtualNetwork = TestSetup-CreateVirtualNetwork $resourceGroup
if($registrationEnabled)
{
$createdLink = New-AzPrivateDnsVirtualNetworkLink -ZoneName $zoneName -ResourceGroupName $resourceGroup.ResourceGroupName -Name $linkName -Tag @{tag1="value1"} -VirtualNetworkId $createdVirtualNetwork.Id -EnableRegistration
}
else
{
$createdLink = New-AzPrivateDnsVirtualNetworkLink -ZoneName $zoneName -ResourceGroupName $resourceGroup.ResourceGroupName -Name $linkName -Tag @{tag1="value1"} -VirtualNetworkId $createdVirtualNetwork.Id
}
return $createdLink
}
148 changes: 148 additions & 0 deletions src/PrivateDns/PrivateDns.Test/ScenarioTests/LinkTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------


namespace Microsoft.Azure.Commands.PrivateDns.Test.ScenarioTests
{
using Microsoft.Azure.ServiceManagement.Common.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

public class LinkTests : PrivateDnsTestsBase
{
public XunitTracingInterceptor Logger;

public LinkTests(Xunit.Abstractions.ITestOutputHelper output)
{
Logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(Logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestLinkCrud()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-LinkCrud");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestLinkCrudWithPiping()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-LinkCrudWithPiping");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRegistrationLinkCreate()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-RegistrationLinkCreate");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestLinkAlreadyExistsCreateThrow()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-LinkAlreadyExistsCreateThrow");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestUpdateLinkRegistrationStatusWithPiping()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-UpdateLinkRegistrationStatusWithPiping");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestUpdateLinkRegistrationStatusWithPipingResourceId()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-UpdateLinkRegistrationStatusWithResourceId");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestUpdateLinkWithEtagMismatchThrow()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-UpdateLinkWithEtagMismatchThrow");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDeleteLinkWithResourceId()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-DeleteLinkWithResourceId");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestUpdateLinkWithEtagMismatchOverwrite()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-UpdateLinkWithEtagMismatchOverwrite");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestUpdateLinkZoneNotExistsThrow()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-UpdateLinkZoneNotExistsThrow");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestUpdateLinkLinkNotExistsThrow()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-UpdateLinkLinkNotExistsThrow");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestUpdateLinkWithNoChangesShouldNotThrow()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-UpdateLinkWithNoChangesShouldNotThrow");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetLinkZoneNotExistsThrow()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-GetLinkZoneNotExistsThrow");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetLinkLinkNotExistsThrow()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-GetLinkLinkNotExistsThrow");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRemoveLinkZoneNotExistsShouldNotThrow()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-RemoveLinkZoneNotExistsShouldNotThrow");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRemoveLinkLinkNotExistsShouldNotThrow()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-RemoveLinkLinkNotExistsShouldNotThrow");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestListLinks()
{
PrivateDnsTestsBase.NewInstance.RunPowerShellTest(Logger, "Test-ListLinks");
}
}
}
Loading