Skip to content
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 @@ -86,6 +86,7 @@ def register_providers():
_register_one_provider('Microsoft.App/managedEnvironments', '2024-02-02-preview', True)
_register_one_provider('Microsoft.FluidRelay/fluidRelayServers', '2025-03-10-preview', True)
_register_one_provider('Microsoft.VideoIndexer/accounts', '2025-04-01', True)
_register_one_provider('Microsoft.Security/privateLinks', '2025-09-01-preview', True)


def _register_one_provider(provider, api_version, support_list_or_not, resource_get_api_version=None, support_connection_operation=True): # pylint: disable=line-too-long
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"target_resource_name": {
"value": "clitestsecuritypl"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"target_resource_name": {
"defaultValue": "security-privatelink",
"type": "String"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Security/privateLinks",
"apiVersion": "2025-09-01-preview",
"name": "[parameters('target_resource_name')]",
"location": "global",
"properties": {}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2265,6 +2265,97 @@ def test_private_endpoint_connection_video_indexer(self, resource_group, storage
vi_name = self.create_random_name(prefix='clitestvideoindexer', length=24)
self._test_private_endpoint_connection_scenario(resource_group, storage_account, vi_name)

class SecurityPrivateLinkNetworkARMTemplateBasedScenarioTest(ScenarioTest):
def _test_private_endpoint_connection_scenario(self, resource_group, target_resource_name):
from azure.mgmt.core.tools import resource_id
resource_type = 'Microsoft.Security/privateLinks'
self.kwargs.update({
'target_resource_name': target_resource_name,
'target_resource_id': resource_id(subscription=self.get_subscription_id(),
resource_group=resource_group,
namespace=resource_type.split('/')[0],
type=resource_type.split('/')[1],
name=target_resource_name),
'rg': resource_group,
'resource_type': resource_type,
'vnet': self.create_random_name('cli-vnet-', 24),
'subnet': self.create_random_name('cli-subnet-', 24),
'pe': self.create_random_name('cli-pe-', 24),
'pe_connection': self.create_random_name('cli-pec-', 24)
})

split_resource_type = resource_type.split('/')
resource_type_name = split_resource_type[0].split('.')[1].lower()
resource_type_kind = split_resource_type[1].lower()
param_file_name = "{}_{}_parameters.json".format(resource_type_name, resource_type_kind)
template_file_name = "{}_{}_template.json".format(resource_type_name, resource_type_kind)
self.kwargs.update({
'param_path': os.path.join(TEST_DIR, 'private_endpoint_arm_templates', param_file_name),
'template_path': os.path.join(TEST_DIR, 'private_endpoint_arm_templates', template_file_name)
})
self.cmd('az deployment group create -g {rg} -p "@{param_path}" target_resource_name={target_resource_name} -f "{template_path}"')

self.cmd('az network vnet create -n {vnet} -g {rg} --subnet-name {subnet} -o json',
checks=self.check('length(newVNet.subnets)', 1))
self.cmd('az network vnet subnet update -n {subnet} --vnet-name {vnet} -g {rg} '
'--disable-private-endpoint-network-policies true -o json',
checks=self.check('privateEndpointNetworkPolicies', 'Disabled'))

target_private_link_resource = self.cmd('az network private-link-resource list --name {target_resource_name} --resource-group {rg} --type {resource_type} -o json').get_output_in_json()
self.kwargs.update({
'group_id': target_private_link_resource[0]['properties']['groupId']
})
# Create a private endpoint connection
pe = self.cmd(
'az network private-endpoint create -g {rg} -n {pe} --vnet-name {vnet} --subnet {subnet} '
'--connection-name {pe_connection} --private-connection-resource-id {target_resource_id} '
'--group-id {group_id} -o json').get_output_in_json()
self.kwargs['pe_id'] = pe['id']
self.kwargs['pe_name'] = self.kwargs['pe_id'].split('/')[-1]

# Show the connection at the target resource side
list_private_endpoint_conn = self.cmd('az network private-endpoint-connection list --name {target_resource_name} --resource-group {rg} --type {resource_type} -o json').get_output_in_json()
self.kwargs.update({
"pec_id": list_private_endpoint_conn[0]['id']
})

self.kwargs.update({
"pec_name": self.kwargs['pec_id'].split('/')[-1]
})
self.cmd('az network private-endpoint-connection show --id {pec_id} -o json',
checks=self.check('id', '{pec_id}'))
self.cmd('az network private-endpoint-connection show --resource-name {target_resource_name} --name {pec_name} --resource-group {rg} --type {resource_type} -o json')
self.cmd('az network private-endpoint-connection show --resource-name {target_resource_name} -n {pec_name} -g {rg} --type {resource_type} -o json')

# Test approval/rejection
self.kwargs.update({
'approval_desc': 'You are approved!',
'rejection_desc': 'You are rejected!'
})
self.cmd(
'az network private-endpoint-connection approve --resource-name {target_resource_name} --resource-group {rg} --name {pec_name} --type {resource_type} '
'--description "{approval_desc}" -o json', checks=[
self.check('properties.privateLinkServiceConnectionState.status', 'Approved')
])
self.cmd('az network private-endpoint-connection reject --id {pec_id} '
'--description "{rejection_desc}" -o json',
checks=[
self.check('properties.privateLinkServiceConnectionState.status', 'Rejected')
])
self.cmd(
'az network private-endpoint-connection list --name {target_resource_name} --resource-group {rg} --type {resource_type} -o json',
checks=[
self.check('length(@)', 1)
])

# Test delete
self.cmd('az network private-endpoint-connection delete --id {pec_id} -y -o json')

@live_only()
@ResourceGroupPreparer(name_prefix="test_private_endpoint_connection_security_privatelink", location="westus")
def test_private_endpoint_connection_security_privatelink(self, resource_group):
name = self.create_random_name(prefix='clitestsecuritypl', length=24)
self._test_private_endpoint_connection_scenario(resource_group, name)

class NetworkPrivateLinkDigitalTwinsScenarioTest(ScenarioTest):
@ResourceGroupPreparer(
Expand Down