Skip to content

Commit b52266e

Browse files
committed
updating tests
1 parent e614fe8 commit b52266e

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/azure-cli/azure/cli/command_modules/cognitiveservices/tests/latest/test_managed_network.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import unittest
77
import os
8+
import time
89

910
from azure.cli.testsdk import ScenarioTest, ResourceGroupPreparer, StorageAccountPreparer
1011

@@ -160,10 +161,22 @@ def test_outbound_rule_private_endpoint(self, resource_group, storage_account):
160161
'storage_id': storage_id
161162
})
162163

163-
# Create cognitive services account
164-
self.cmd('az cognitiveservices account create -n {sname} -g {rg} --kind {kind} --sku {sku} -l {location} --yes',
164+
# Create cognitive services account with system-assigned identity
165+
self.cmd('az cognitiveservices account create -n {sname} -g {rg} --kind {kind} --sku {sku} -l {location} --assign-identity --yes',
165166
checks=[self.check('name', '{sname}')])
166167

168+
# Get the managed identity principal ID
169+
identity = self.cmd('az cognitiveservices account show -n {sname} -g {rg}').get_output_in_json()
170+
principal_id = identity['identity']['principalId']
171+
self.kwargs['principal_id'] = principal_id
172+
173+
# Grant the CS account's identity "Contributor" on the storage account
174+
# (needs privateEndpointConnectionsApproval/action which Network Contributor lacks)
175+
self.cmd('az role assignment create --assignee-object-id {principal_id} --assignee-principal-type ServicePrincipal --role "Contributor" --scope {storage_id}')
176+
177+
# Wait for RBAC propagation
178+
time.sleep(60)
179+
167180
# Create managed network
168181
self.cmd('az cognitiveservices account managed-network create -n {sname} -g {rg} --managed-network allow_only_approved_outbound')
169182

@@ -187,7 +200,6 @@ def test_outbound_rule_private_endpoint(self, resource_group, storage_account):
187200
ret = self.cmd('az cognitiveservices account delete -n {sname} -g {rg}')
188201
self.assertEqual(ret.exit_code, 0)
189202

190-
# @unittest.skip("ServiceTag rule LRO polling returns 404 - service-side issue")
191203
@ResourceGroupPreparer(random_name_length=20, parameter_name_for_location='location')
192204
def test_outbound_rule_service_tag(self, resource_group):
193205
"""Test Service Tag outbound rule operations."""

0 commit comments

Comments
 (0)