Skip to content
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

Enable ARM to the Private Link connection Cmdlets #18358

Merged
merged 5 commits into from
Jun 15, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,13 @@ public void TestStoragePrivateEndpoint()
{
TestRunner.RunTestScript("Test-StoragePrivateEndpoint");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.sdnnrp)]
public void TestResourceManagerPrivateEndpoint()
{
TestRunner.RunTestScript("Test-ResourceManagerPrivateEndpoint");
}
}
}
57 changes: 57 additions & 0 deletions src/Network/Network.Test/ScenarioTests/PrivateLinkServiceTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,61 @@ function Test-PrivateLinkServiceInEdgeZone
# Cleanup
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
Test operation for ResourceManagerPrivateEndpoint.
#>
function Test-ResourceManagerPrivateEndpoint
{
# Setup
$rgname = "testPS"
$rmplname = "RMPL"
$location = "eastus"
$sub = getSubscription
# Dependency parameters
$IpConfigurationName = "IpConfigurationName"
$vnetName = Get-ResourceName
$plsConnectionName = Get-ResourceName
$endpointName = Get-ResourceName

try
{
New-AzResourceGroup -Name $rgname -Location $location

#Create ResourceManagementPrivateLink
#$rmpl = New-AzResourceManagementPrivateLink -ResourceGroupName $rgName -Name $rmplname -Location $location

$rmplid = "/subscriptions/$sub/resourceGroups/$rgname/providers/Microsoft.Authorization/resourceManagementPrivateLinks/$rmplname"
$PrivateLinkResource = Get-AzPrivateLinkResource -PrivateLinkResourceId $rmplid

#Vnet Configuration
$SubnetConfig = New-AzVirtualNetworkSubnetConfig -Name "Subnet" -AddressPrefix "11.0.1.0/24" -PrivateEndpointNetworkPolicies "Disabled"
$VNet = New-AzVirtualNetwork -ResourceGroupName $rgName -Name $vnetName -Location $location -AddressPrefix "11.0.0.0/16" -Subnet $SubnetConfig

# Create Private Endpoint
$PLSConnection = New-AzPrivateLinkServiceConnection -Name $plsConnectionName -PrivateLinkServiceId $rmplid -GroupId "ResourceManagement"
$privateEndpoint = New-AzPrivateEndpoint -ResourceGroupName $rgName -Name $endpointName -Location $location -Subnet $VNet.subnets[0] -PrivateLinkServiceConnection $PLSConnection -ByManualRequest

$pecGet = Get-AzPrivateEndpointConnection -PrivateLinkResourceId $rmplid
Assert-NotNull $pecGet;
Assert-AreEqual "Pending" $pecGet.PrivateLinkServiceConnectionState.Status

# Approve Private Endpoint Connection
$pecApprove = Approve-AzPrivateEndpointConnection -ResourceId $pecGet.Id
Assert-NotNull $pecApprove;
Start-TestSleep 15000
$pecApprove = Get-AzPrivateEndpointConnection -ResourceId $pecGet.Id
Assert-AreEqual "Approved" $pecApprove.PrivateLinkServiceConnectionState.Status

# Remove Private Endpoint Connection
$pecRemove = Remove-AzPrivateEndpointConnection -ResourceId $pecGet.Id -PassThru -Force
Assert-AreEqual true $pecRemove
}
finally
{
#Cleanup
Clean-ResourceGroup $rgname;
}
}
Loading