Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public IMDSManagedIdentitySource(MsalRequest msalRequest,
}

StringBuilder builder = new StringBuilder(environmentVariables.getEnvironmentVariable(Constants.AZURE_POD_IDENTITY_AUTHORITY_HOST));
builder.append("/" + IMDS_TOKEN_PATH);
builder.append(IMDS_TOKEN_PATH);
try {
imdsEndpoint = new URI(builder.toString());
} catch (URISyntaxException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,27 @@ void managedIdentityTest_DifferentScopes_RequestsNewToken(ManagedIdentitySourceT
class ManagedIdentityBehaviorTests extends BaseManagedIdentityTest {
//Tests covering specific behavior/scenarios/use cases/etc. for Managed Identity flows

@Test
void managedIdentityTest_AzurePodIdentityAuthorityHostBuildsImdsEndpointWithoutDoubleSlash() throws Exception {
String authorityHost = "http://127.0.0.1:80";
EnvironmentVariablesHelper environmentVariables = new EnvironmentVariablesHelper(IMDS, null);
environmentVariables.mockedEnvironmentVariables.put(
Constants.AZURE_POD_IDENTITY_AUTHORITY_HOST, authorityHost);
ManagedIdentityApplication.setEnvironmentVariables(environmentVariables);
initHttpClientMock(IMDS);
initManagedIdentityApplication(ManagedIdentityId.systemAssigned());

when(httpClientMock.send(any()))
.thenReturn(expectedResponse(HttpStatus.HTTP_OK,
getSuccessfulResponse(ManagedIdentityTestConstants.RESOURCE)));

acquireTokenCommon(ManagedIdentityTestConstants.RESOURCE).get();

ArgumentCaptor<HttpRequest> captor = ArgumentCaptor.forClass(HttpRequest.class);
verify(httpClientMock).send(captor.capture());
assertEquals("/metadata/identity/oauth2/token", captor.getValue().url().getPath());
}

@ParameterizedTest
@MethodSource("com.microsoft.aad.msal4j.ManagedIdentityTestDataProvider#createDataError")
void managedIdentityTest_WithClaims(ManagedIdentitySourceType source, String endpoint) throws Exception {
Expand Down
Loading