1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
# coding: utf-8
#-------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#--------------------------------------------------------------------------
# TEST SCENARIO COVERAGE
# ----------------------
# Methods Total : 8
# Methods Covered : 8
# Examples Total : 8
# Examples Tested : 8
# Coverage % : 100
# ----------------------
import unittest
import azure.mgmt.msi
from devtools_testutils import AzureMgmtTestCase, ResourceGroupPreparer
AZURE_LOCATION = 'eastus'
class MgmtManagedServiceIdentityClientTest(AzureMgmtTestCase):
def setUp(self):
super(MgmtManagedServiceIdentityClientTest, self).setUp()
self.mgmt_client = self.create_mgmt_client(
azure.mgmt.msi.ManagedServiceIdentityClient
)
@ResourceGroupPreparer(location=AZURE_LOCATION)
def test_msi(self, resource_group):
SERVICE_NAME = "myapimrndxyz"
USER_ASSIGNED_IDENTITY_NAME = "useridentityname"
IDENTITY_NAME = "identityname"
# IdentityCreate[put]
# BODY = {
# "location": "eastus",
# "tags": {
# "key1": "value1",
# "key2": "value2"
# }
# }
LOCATION = "eastus"
TAGS = {
"key1": "value1",
"key2": "value2"
}
result = self.mgmt_client.user_assigned_identities.create_or_update(resource_group.name, USER_ASSIGNED_IDENTITY_NAME, LOCATION, TAGS)
# IdentityGet[get]
result = self.mgmt_client.user_assigned_identities.get(resource_group.name, USER_ASSIGNED_IDENTITY_NAME)
# IdentityListByResourceGroup[get]
result = self.mgmt_client.user_assigned_identities.list_by_resource_group(resource_group.name)
# IdentityListBySubscription[get]
result = self.mgmt_client.user_assigned_identities.list_by_subscription()
""" TODO: dont have system_assigned_identities module
# MsiOperationsList[get]
result = self.mgmt_client.system_assigned_identities.get_by_scope(IDENTITY_NAME)
# MsiOperationsList[get]
result = self.mgmt_client.system_assigned_identities.get_by_scope(IDENTITY_NAME)
"""
# IdentityUpdate[patch]
# BODY = {
# "location": "eastus",
# "tags": {
# "key1": "value1",
# "key2": "value2"
# }
# }
LOCATION = "eastus"
TAGS = {
"key1": "value1",
"key2": "value2"
}
result = self.mgmt_client.user_assigned_identities.update(resource_group.name, USER_ASSIGNED_IDENTITY_NAME, LOCATION, TAGS)
# IdentityDelete[delete]
result = self.mgmt_client.user_assigned_identities.delete(resource_group.name, USER_ASSIGNED_IDENTITY_NAME)
#------------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()
|