Skip to content

Commit

Permalink
Enable ARM to the Private Link connection Cmdlets (#18358)
Browse files Browse the repository at this point in the history
* enable Private link support

* both set to true

* Add testcase

* Add recording

Co-authored-by: Vishakha Narvekar <[email protected]>
  • Loading branch information
Vishakha-Git and Vishakha Narvekar authored Jun 15, 2022
1 parent cdeb8f0 commit acae733
Show file tree
Hide file tree
Showing 4 changed files with 2,040 additions and 1 deletion.
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

0 comments on commit acae733

Please sign in to comment.