Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make test run with any auth method
Browse files Browse the repository at this point in the history
thomas11 committed Jan 24, 2025
1 parent d60527b commit af07a66
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions examples/examples_nodejs_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright 2016-2020, Pulumi Corporation. All rights reserved.
//go:build nodejs || all
// +build nodejs all

package examples

@@ -329,22 +330,28 @@ func TestRecoveryServicesProtectedItemTs(t *testing.T) {
integration.ProgramTest(t, &test)
}

func TestAccPIMRoleManagementPolicies(t *testing.T) {
func TestPIMRoleManagementPolicies(t *testing.T) {
skipIfShort(t)

// A randomly chosen Role Management Policy, from the list obtained by
// az rest --method get --url https://management.azure.com/subscriptions/0282681f-7a9e-424b-80b2-96babd57a8a1/providers/Microsoft.Authorization/roleManagementPolicies\?api-version\=2020-10-01
const policyId = "7ed63469-c833-4fba-9032-803ce289eabc"

// Set up standard azidentity auth for the azure sdk.
// If ARM_CLIENT_SECRET is set, service principal auth is configured and we use it.
// Otherwise, we use the default Azure credential, which attempts to use managed identity and CLI.
clientSecret := os.Getenv("ARM_CLIENT_SECRET")
if clientSecret != "" {
os.Setenv("AZURE_TENANT_ID", os.Getenv("ARM_TENANT_ID"))
os.Setenv("AZURE_CLIENT_ID", os.Getenv("ARM_CLIENT_ID"))
os.Setenv("AZURE_CLIENT_SECRET", clientSecret)
}

// Retrieve the `maximumDuration` property of the randomly chosen Expiration_Admin_Eligibility rule.
// Used in ExtraRuntimeValidation to assert that the rule has the expected duration.
// Uses the Azure SDK to be able to retrieve the actual value from Azure, independent of Pulumi.
get_Expiration_Admin_Eligibility_RuleDuration := func() string {
cred, err := azidentity.NewClientSecretCredential(
os.Getenv("ARM_TENANT_ID"),
os.Getenv("ARM_CLIENT_ID"),
os.Getenv("ARM_CLIENT_SECRET"),
nil)
cred, err := azidentity.NewDefaultAzureCredential(nil)
require.NoError(t, err)

sub := os.Getenv("ARM_SUBSCRIPTION_ID")
@@ -373,7 +380,6 @@ func TestAccPIMRoleManagementPolicies(t *testing.T) {

test := getJSBaseOptions(t).
With(integration.ProgramTestOptions{
DebugLogLevel: 9,
Verbose: true,
Dir: filepath.Join(getCwd(t), "pim-rolemanagementpolicies"),
Config: map[string]string{"policy": policyId},

0 comments on commit af07a66

Please sign in to comment.