forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Passwordless feature does't set the cloud-type correctly and pipe…
…line fail (Azure#31600) Fix Passwordless feature does't set the cloud-type correctly and pipeline fail
- Loading branch information
1 parent
d87a764
commit 644f835
Showing
23 changed files
with
257 additions
and
74 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
62 changes: 62 additions & 0 deletions
62
...om/azure/identity/providers/jdbc/implementation/token/AccessTokenResolverOptionsTest.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,62 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.identity.providers.jdbc.implementation.token; | ||
|
||
import com.azure.identity.AzureAuthorityHosts; | ||
import com.azure.identity.providers.jdbc.implementation.enums.AuthProperty; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import java.util.Properties; | ||
import java.util.stream.Stream; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertArrayEquals; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
||
class AccessTokenResolverOptionsTest { | ||
|
||
@Test | ||
void testDefaultConstructor() { | ||
AccessTokenResolverOptions accessTokenResolverOptions = new AccessTokenResolverOptions(); | ||
assertNull(accessTokenResolverOptions.getClaims()); | ||
assertNull(accessTokenResolverOptions.getScopes()); | ||
assertNull(accessTokenResolverOptions.getTenantId()); | ||
} | ||
|
||
@Test | ||
void testConstructorWithProperties() { | ||
Properties properties = new Properties(); | ||
properties.setProperty(AuthProperty.TENANT_ID.getPropertyKey(), "fake-tenant-id"); | ||
properties.setProperty(AuthProperty.CLAIMS.getPropertyKey(), "fake-claims"); | ||
properties.setProperty(AuthProperty.SCOPES.getPropertyKey(), "fake-scopes"); | ||
|
||
AccessTokenResolverOptions accessTokenResolverOptions = new AccessTokenResolverOptions(properties); | ||
assertEquals("fake-claims", accessTokenResolverOptions.getClaims()); | ||
assertArrayEquals(new String[]{"fake-scopes"}, accessTokenResolverOptions.getScopes()); | ||
assertEquals("fake-tenant-id", accessTokenResolverOptions.getTenantId()); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("provideAuthorityHostScopeMap") | ||
void testDifferentAuthorties(String authorityHost, String scope) { | ||
Properties properties = new Properties(); | ||
AuthProperty.AUTHORITY_HOST.setProperty(properties, authorityHost); | ||
AccessTokenResolverOptions accessTokenResolverOptions = new AccessTokenResolverOptions(properties); | ||
assertArrayEquals(new String[]{scope}, accessTokenResolverOptions.getScopes()); | ||
} | ||
|
||
private static Stream<Arguments> provideAuthorityHostScopeMap() { | ||
return Stream.of( | ||
Arguments.of(null, "https://ossrdbms-aad.database.windows.net/.default"), | ||
Arguments.of("", "https://ossrdbms-aad.database.windows.net/.default"), | ||
Arguments.of(AzureAuthorityHosts.AZURE_PUBLIC_CLOUD, "https://ossrdbms-aad.database.windows.net/.default"), | ||
Arguments.of(AzureAuthorityHosts.AZURE_CHINA, "https://ossrdbms-aad.database.chinacloudapi.cn/.default"), | ||
Arguments.of(AzureAuthorityHosts.AZURE_GERMANY, "https://ossrdbms-aad.database.cloudapi.de/.default"), | ||
Arguments.of(AzureAuthorityHosts.AZURE_GOVERNMENT, "https://ossrdbms-aad.database.usgovcloudapi.net/.default") | ||
); | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.