Skip to content

Commit b0ffdc7

Browse files
Repro for #2737
1 parent e5b0968 commit b0ffdc7

File tree

3 files changed

+163
-0
lines changed

3 files changed

+163
-0
lines changed

provider/provider_test.go

+14
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@ func test(t *testing.T, dir string, opts ...optproviderupgrade.PreviewProviderUp
5555
assertpreview.HasNoDeletes(t, previewResult)
5656
}
5757

58+
func setupTest(t *testing.T, dir string) *pulumitest.PulumiTest {
59+
t.Helper()
60+
if testing.Short() {
61+
t.Skipf("Skipping in testing.Short() mode, assuming this is a CI run without cloud credentials")
62+
return nil
63+
}
64+
subscriptionID := getSubscriptionID(t)
65+
rpFactory := providers.ResourceProviderFactory(providerServer)
66+
pt := pulumitest.NewPulumiTest(t, dir,
67+
opttest.AttachProvider("azure", rpFactory))
68+
pt.SetConfig(t, "azure:subscriptionId", subscriptionID)
69+
return pt
70+
}
71+
5872
func TestUpgradeCoverage(t *testing.T) {
5973
providertest.ReportUpgradeCoverage(t)
6074
}

provider/provider_yaml_test.go

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"testing"
1111

1212
"github.com/pulumi/providertest/optproviderupgrade"
13+
"github.com/pulumi/providertest/pulumitest/assertup"
1314
)
1415

1516
func Test_appinsights(t *testing.T) {
@@ -100,3 +101,9 @@ func Test_hdinsight(t *testing.T) {
100101
test(t, filepath.Join("test-programs", "hdinsight"),
101102
optproviderupgrade.NewSourcePath(filepath.Join("test-programs", "hdinsight", "v6")))
102103
}
104+
105+
func Test_RoleManagementPolicy(t *testing.T) {
106+
pt := setupTest(t, filepath.Join("test-programs", "RoleManagementPolicy"))
107+
upResult := pt.Up(t)
108+
assertup.HasNoChanges(t, upResult)
109+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: RoleManagementPolicy
2+
runtime: yaml
3+
4+
resources:
5+
exampleResourceGroup:
6+
type: azure:core:ResourceGroup
7+
properties:
8+
location: East US
9+
10+
policy:
11+
type: azure:pim:RoleManagementPolicy
12+
properties:
13+
scope: /subscriptions/06414010-48ba-4c6f-ac65-479ecad05c44/resourceGroups/${exampleResourceGroup.name}
14+
roleDefinitionId: "/subscriptions/06414010-48ba-4c6f-ac65-479ecad05c44/providers/Microsoft.Authorization/roleDefinitions/roleDefinition.id"
15+
activeAssignmentRules:
16+
expirationRequired: false
17+
eligibleAssignmentRules:
18+
expirationRequired: false
19+
activationRules:
20+
requireApproval: true
21+
approvalStage:
22+
primaryApprovers:
23+
- objectId: 06414010-48ba-4c6f-ac65-479ecad05c44
24+
type: Group
25+
notificationRules:
26+
activeAssignments:
27+
adminNotifications:
28+
notificationLevel: All
29+
defaultRecipients: true
30+
eligibleAssignments:
31+
adminNotifications:
32+
notificationLevel: All
33+
defaultRecipients: true
34+
eligibleActivations:
35+
adminNotifications:
36+
notificationLevel: All
37+
defaultRecipients: true
38+
# request from issue, missing expected Expiration_Admin_Assignment:
39+
# {
40+
# "id": "/subscriptions/<subscription-id>/resourceGroups/test-weu-fnd-jump-box-tmp0371/providers/Microsoft.Compute/virtualMachines/vm-test-weu-fnd-jump-box-tmp0371/providers/Microsoft.Authorization/roleManagementPolicies/1c0163c0-47e6-4577-8991-ea5c82e286e4",
41+
# "name": "1c0163c0-47e6-4577-8991-ea5c82e286e4",
42+
# "properties":
43+
# {
44+
# "rules":
45+
# [
46+
# {
47+
# "id": "Expiration_Admin_Eligibility",
48+
# "isExpirationRequired": false,
49+
# "maximumDuration": "P365D",
50+
# "ruleType": "RoleManagementPolicyExpirationRule",
51+
# "target":
52+
# {
53+
# "caller": "Admin",
54+
# "enforcedSettings": [],
55+
# "inheritableSettings": [],
56+
# "level": "Eligibility",
57+
# "operations": ["All"],
58+
# "targetObjects": [],
59+
# },
60+
# },
61+
# {
62+
# "id": "Approval_EndUser_Assignment",
63+
# "ruleType": "RoleManagementPolicyApprovalRule",
64+
# "setting":
65+
# {
66+
# "approvalMode": "SingleStage",
67+
# "approvalStages":
68+
# [
69+
# {
70+
# "primaryApprovers":
71+
# [{ "id": "<group-id>", "userType": "Group" }],
72+
# },
73+
# ],
74+
# "isApprovalRequired": true,
75+
# "isApprovalRequiredForExtension": false,
76+
# "isRequestorJustificationRequired": true,
77+
# },
78+
# "target":
79+
# {
80+
# "caller": "EndUser",
81+
# "enforcedSettings": [],
82+
# "inheritableSettings": [],
83+
# "level": "Assignment",
84+
# "operations": ["All"],
85+
# "targetObjects": [],
86+
# },
87+
# },
88+
# {
89+
# "id": "Notification_Admin_Admin_Eligibility",
90+
# "isDefaultRecipientsEnabled": true,
91+
# "notificationLevel": "Critical",
92+
# "notificationType": "Email",
93+
# "recipientType": "Admin",
94+
# "ruleType": "RoleManagementPolicyNotificationRule",
95+
# "target":
96+
# {
97+
# "caller": "Admin",
98+
# "enforcedSettings": [],
99+
# "inheritableSettings": [],
100+
# "level": "Eligibility",
101+
# "operations": ["All"],
102+
# "targetObjects": [],
103+
# },
104+
# },
105+
# {
106+
# "id": "Notification_Admin_Admin_Assignment",
107+
# "isDefaultRecipientsEnabled": true,
108+
# "notificationLevel": "Critical",
109+
# "notificationType": "Email",
110+
# "recipientType": "Admin",
111+
# "ruleType": "RoleManagementPolicyNotificationRule",
112+
# "target":
113+
# {
114+
# "caller": "Admin",
115+
# "enforcedSettings": [],
116+
# "inheritableSettings": [],
117+
# "level": "Assignment",
118+
# "operations": ["All"],
119+
# "targetObjects": [],
120+
# },
121+
# },
122+
# {
123+
# "id": "Notification_Admin_EndUser_Assignment",
124+
# "isDefaultRecipientsEnabled": true,
125+
# "notificationLevel": "Critical",
126+
# "notificationType": "Email",
127+
# "recipientType": "Admin",
128+
# "ruleType": "RoleManagementPolicyNotificationRule",
129+
# "target":
130+
# {
131+
# "caller": "EndUser",
132+
# "enforcedSettings": [],
133+
# "inheritableSettings": [],
134+
# "level": "Assignment",
135+
# "operations": ["All"],
136+
# "targetObjects": [],
137+
# },
138+
# },
139+
# ],
140+
# },
141+
# "type": "Microsoft.Authorization/roleManagementPolicies",
142+
# }

0 commit comments

Comments
 (0)