-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1577 from microsoft/feature/java-cae
CAE support for java
- Loading branch information
Showing
16 changed files
with
209 additions
and
44 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
5 changes: 4 additions & 1 deletion
5
...ctions/java/lib/src/main/java/com/microsoft/kiota/authentication/AccessTokenProvider.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
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
48 changes: 48 additions & 0 deletions
48
...rc/test/java/com/microsoft/kiota/authentication/AzureIdentityAccessTokenProviderTest.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,48 @@ | ||
/* | ||
* This Java source file was generated by the Gradle 'init' task. | ||
*/ | ||
package com.microsoft.kiota.authentication; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import reactor.core.publisher.Mono; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.util.HashMap; | ||
|
||
import com.azure.core.credential.AccessToken; | ||
import com.azure.core.credential.TokenCredential; | ||
import com.azure.core.credential.TokenRequestContext; | ||
import com.microsoft.kiota.HttpMethod; | ||
import com.microsoft.kiota.RequestInformation; | ||
|
||
class AzureIdentityAccessTokenProviderTest { | ||
@Test | ||
void testAddsClaimsToTheTokenContext() throws URISyntaxException { | ||
final var credentialMock = mock(TokenCredential.class); | ||
when(credentialMock.getToken(any(TokenRequestContext.class))).thenAnswer(r -> { | ||
final var context = (TokenRequestContext) r.getArgument(0); | ||
assertEquals(context.getClaims(), "{\"access_token\":{\"nbf\":{\"essential\":true, \"value\":\"1652813508\"}}}"); | ||
return Mono.just(mock(AccessToken.class)); | ||
}); | ||
final var authenticationProvider = new AzureIdentityAuthenticationProvider(credentialMock, null, "User.Read"); | ||
final var testRequest = new RequestInformation() {{ | ||
this.httpMethod = HttpMethod.GET; | ||
this.setUri(new URI("https://graph.microsoft.com/v1.0/me")); | ||
}}; | ||
final var additionalContext = new HashMap<String, Object>() {{ | ||
this.put("claims", "eyJhY2Nlc3NfdG9rZW4iOnsibmJmIjp7ImVzc2VudGlhbCI6dHJ1ZSwgInZhbHVlIjoiMTY1MjgxMzUwOCJ9fX0="); | ||
}}; | ||
authenticationProvider.authenticateRequest(testRequest, additionalContext); | ||
|
||
verify(credentialMock, times(1)).getToken(any(TokenRequestContext.class)); | ||
} | ||
} |
13 changes: 0 additions & 13 deletions
13
...tication/java/azure/lib/src/test/java/com/microsoft/kiota/authentication/LibraryTest.java
This file was deleted.
Oops, something went wrong.
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.