-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch EventHubsExporterIntegrationTest to managed identity (#43181)
- Loading branch information
1 parent
3bf1aea
commit 8ae755a
Showing
3 changed files
with
57 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...gure/src/test/java/com/azure/monitor/opentelemetry/autoconfigure/TokenCredentialUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.monitor.opentelemetry.autoconfigure; | ||
|
||
import com.azure.core.credential.TokenCredential; | ||
import com.azure.core.test.InterceptorManager; | ||
import com.azure.core.test.utils.MockTokenCredential; | ||
import com.azure.identity.AzurePowerShellCredentialBuilder; | ||
import com.azure.identity.DefaultAzureCredentialBuilder; | ||
|
||
class TokenCredentialUtil { | ||
|
||
/** | ||
* Gets a token credential for use in tests. | ||
* @param interceptorManager the interceptor manager | ||
* @return the TokenCredential | ||
*/ | ||
static TokenCredential getTestTokenCredential(InterceptorManager interceptorManager) { | ||
if (interceptorManager.isLiveMode()) { | ||
return new AzurePowerShellCredentialBuilder().build(); | ||
} else if (interceptorManager.isRecordMode()) { | ||
return new DefaultAzureCredentialBuilder().build(); | ||
} else { | ||
return new MockTokenCredential(); | ||
} | ||
} | ||
|
||
} |