@@ -10,37 +10,43 @@ var _ resourceid.Formatter = RoleAssignmentId{}
10
10
11
11
func TestRoleAssignmentIDFormatter (t * testing.T ) {
12
12
testData := []struct {
13
- SubscriptionId string
14
- ResourceGroup string
15
- ManagementGroup string
16
- Name string
17
- TenantId string
18
- Expected string
13
+ SubscriptionId string
14
+ ResourceGroup string
15
+ ResourceProvider string
16
+ ResourceScope string
17
+ ManagementGroup string
18
+ Name string
19
+ TenantId string
20
+ Expected string
19
21
}{
20
22
{
21
23
SubscriptionId : "" ,
22
24
ResourceGroup : "" ,
25
+ ResourceScope : "" ,
23
26
ManagementGroup : "" ,
24
27
Name : "23456781-2349-8764-5631-234567890121" ,
25
28
TenantId : "" ,
26
29
},
27
30
{
28
31
SubscriptionId : "12345678-1234-9876-4563-123456789012" ,
29
32
ResourceGroup : "group1" ,
33
+ ResourceScope : "" ,
30
34
ManagementGroup : "managementGroup1" ,
31
35
Name : "23456781-2349-8764-5631-234567890121" ,
32
36
TenantId : "" ,
33
37
},
34
38
{
35
39
SubscriptionId : "12345678-1234-9876-4563-123456789012" ,
36
40
ResourceGroup : "" ,
41
+ ResourceScope : "" ,
37
42
ManagementGroup : "managementGroup1" ,
38
43
Name : "23456781-2349-8764-5631-234567890121" ,
39
44
TenantId : "" ,
40
45
},
41
46
{
42
47
SubscriptionId : "12345678-1234-9876-4563-123456789012" ,
43
48
ResourceGroup : "" ,
49
+ ResourceScope : "" ,
44
50
ManagementGroup : "" ,
45
51
Name : "23456781-2349-8764-5631-234567890121" ,
46
52
TenantId : "" ,
@@ -49,6 +55,7 @@ func TestRoleAssignmentIDFormatter(t *testing.T) {
49
55
{
50
56
SubscriptionId : "12345678-1234-9876-4563-123456789012" ,
51
57
ResourceGroup : "group1" ,
58
+ ResourceScope : "" ,
52
59
ManagementGroup : "" ,
53
60
Name : "23456781-2349-8764-5631-234567890121" ,
54
61
TenantId : "" ,
@@ -57,6 +64,7 @@ func TestRoleAssignmentIDFormatter(t *testing.T) {
57
64
{
58
65
SubscriptionId : "" ,
59
66
ResourceGroup : "" ,
67
+ ResourceScope : "" ,
60
68
ManagementGroup : "12345678-1234-9876-4563-123456789012" ,
61
69
Name : "23456781-2349-8764-5631-234567890121" ,
62
70
TenantId : "" ,
@@ -65,15 +73,26 @@ func TestRoleAssignmentIDFormatter(t *testing.T) {
65
73
{
66
74
SubscriptionId : "" ,
67
75
ResourceGroup : "" ,
76
+ ResourceScope : "" ,
68
77
ManagementGroup : "12345678-1234-9876-4563-123456789012" ,
69
78
Name : "23456781-2349-8764-5631-234567890121" ,
70
79
TenantId : "34567812-3456-7653-6742-345678901234" ,
71
80
Expected : "/providers/Microsoft.Management/managementGroups/12345678-1234-9876-4563-123456789012/providers/Microsoft.Authorization/roleAssignments/23456781-2349-8764-5631-234567890121|34567812-3456-7653-6742-345678901234" ,
72
81
},
82
+ {
83
+ SubscriptionId : "12345678-1234-9876-4563-123456789012" ,
84
+ ResourceGroup : "group1" ,
85
+ ResourceProvider : "Microsoft.Storage" ,
86
+ ResourceScope : "storageAccounts/nameStorageAccount" ,
87
+ ManagementGroup : "" ,
88
+ Name : "23456781-2349-8764-5631-234567890121" ,
89
+ TenantId : "34567812-3456-7653-6742-345678901234" ,
90
+ Expected : "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Storage/storageAccounts/nameStorageAccount/providers/Microsoft.Authorization/roleAssignments/23456781-2349-8764-5631-234567890121|34567812-3456-7653-6742-345678901234" ,
91
+ },
73
92
}
74
93
for _ , v := range testData {
75
94
t .Logf ("testing %+v" , v )
76
- actual , err := NewRoleAssignmentID (v .SubscriptionId , v .ResourceGroup , v .ManagementGroup , v .Name , v .TenantId )
95
+ actual , err := NewRoleAssignmentID (v .SubscriptionId , v .ResourceGroup , v .ResourceProvider , v . ResourceScope , v . ManagementGroup , v .Name , v .TenantId )
77
96
if err != nil {
78
97
if v .Expected == "" {
79
98
continue
@@ -140,6 +159,7 @@ func TestRoleAssignmentID(t *testing.T) {
140
159
Expected : & RoleAssignmentId {
141
160
SubscriptionID : "12345678-1234-9876-4563-123456789012" ,
142
161
ResourceGroup : "" ,
162
+ ResourceScope : "" ,
143
163
ManagementGroup : "" ,
144
164
Name : "23456781-2349-8764-5631-234567890121" ,
145
165
},
@@ -176,6 +196,30 @@ func TestRoleAssignmentID(t *testing.T) {
176
196
TenantId : "34567812-3456-7653-6742-345678901234" ,
177
197
},
178
198
},
199
+ {
200
+ Input : "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Storage/storageAccounts/nameStorageAccount/providers/Microsoft.Authorization/roleAssignments/23456781-2349-8764-5631-234567890121|34567812-3456-7653-6742-345678901234" ,
201
+ Expected : & RoleAssignmentId {
202
+ SubscriptionID : "12345678-1234-9876-4563-123456789012" ,
203
+ ResourceGroup : "group1" ,
204
+ ResourceProvider : "Microsoft.Storage" ,
205
+ ResourceScope : "storageAccounts/nameStorageAccount" ,
206
+ ManagementGroup : "" ,
207
+ Name : "23456781-2349-8764-5631-234567890121" ,
208
+ TenantId : "34567812-3456-7653-6742-345678901234" ,
209
+ },
210
+ },
211
+ {
212
+ Input : "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.AppPlatform/Spring/spring1/apps/app1/providers/Microsoft.Authorization/roleAssignments/23456781-2349-8764-5631-234567890121|34567812-3456-7653-6742-345678901234" ,
213
+ Expected : & RoleAssignmentId {
214
+ SubscriptionID : "12345678-1234-9876-4563-123456789012" ,
215
+ ResourceGroup : "group1" ,
216
+ ResourceProvider : "Microsoft.AppPlatform" ,
217
+ ResourceScope : "Spring/spring1/apps/app1" ,
218
+ ManagementGroup : "" ,
219
+ Name : "23456781-2349-8764-5631-234567890121" ,
220
+ TenantId : "34567812-3456-7653-6742-345678901234" ,
221
+ },
222
+ },
179
223
}
180
224
181
225
for _ , v := range testData {
@@ -199,15 +243,23 @@ func TestRoleAssignmentID(t *testing.T) {
199
243
}
200
244
201
245
if actual .SubscriptionID != v .Expected .SubscriptionID {
202
- t .Fatalf ("Expected %q but got %q for Role Assignment Name " , v .Expected .SubscriptionID , actual .SubscriptionID )
246
+ t .Fatalf ("Expected %q but got %q for Role Assignment Subscription ID " , v .Expected .SubscriptionID , actual .SubscriptionID )
203
247
}
204
248
205
249
if actual .ResourceGroup != v .Expected .ResourceGroup {
206
- t .Fatalf ("Expected %q but got %q for Role Assignment Name" , v .Expected .ResourceGroup , actual .ResourceGroup )
250
+ t .Fatalf ("Expected %q but got %q for Role Assignment Resource Group" , v .Expected .ResourceGroup , actual .ResourceGroup )
251
+ }
252
+
253
+ if actual .ResourceProvider != v .Expected .ResourceProvider {
254
+ t .Fatalf ("Expected %q but got %q for Role Assignment Resource Provider" , v .Expected .ResourceProvider , actual .ResourceProvider )
255
+ }
256
+
257
+ if actual .ResourceScope != v .Expected .ResourceScope {
258
+ t .Fatalf ("Expected %q but got %q for Role Assignment Resource Scope" , v .Expected .ResourceScope , actual .ResourceScope )
207
259
}
208
260
209
261
if actual .ManagementGroup != v .Expected .ManagementGroup {
210
- t .Fatalf ("Expected %q but got %q for Role Assignment Name " , v .Expected .ManagementGroup , actual .ManagementGroup )
262
+ t .Fatalf ("Expected %q but got %q for Role Assignment Management Group " , v .Expected .ManagementGroup , actual .ManagementGroup )
211
263
}
212
264
}
213
265
}
0 commit comments