Skip to content

Commit 4bf9dff

Browse files
committed
Remove tests that rely on agent identity flow behavior
1 parent 3c3abfc commit 4bf9dff

1 file changed

Lines changed: 3 additions & 99 deletions

File tree

  • msal4j-sdk/src/integrationtest/java/com/microsoft/aad/msal4j

msal4j-sdk/src/integrationtest/java/com/microsoft/aad/msal4j/AgenticIT.java

Lines changed: 3 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,31 @@
2020

2121
/**
2222
* Integration tests for agentic (agent identity) scenarios using MSAL Java APIs.
23-
* Tests the MSAL-level APIs for the agent identity flow
24-
* (specifically the FMI portions that are available on this branch).
23+
* Tests FMI credential acquisition via assertion callbacks and cache isolation.
2524
*
2625
* <p>These tests use MSAL token acquisition APIs (unlike AgenticRawHttpIT which uses raw HTTP).
2726
*
2827
* <p>Test configuration:
2928
* <ul>
30-
* <li>Blueprint app: {@link #BLUEPRINT_CLIENT_ID}</li>
29+
* <li>RMA app: {@link #RMA_CLIENT_ID}</li>
3130
* <li>Agent app: {@link #AGENT_APP_ID}</li>
3231
* <li>Tenant: {@link #TENANT_ID}</li>
3332
* </ul>
3433
*
3534
* <p>Flows tested (FMI-only, no FIC/user_fic on this branch):
3635
* <ul>
37-
* <li>Agent gets app token using FMI-sourced assertion (Leg 2 of agent identity)</li>
3836
* <li>Assertion callback receives correct context (AssertionRequestOptions)</li>
39-
* <li>Cache isolation between different assertion-based flows</li>
37+
* <li>Cache isolation between different fmi_path values</li>
4038
* </ul>
4139
*/
4240
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
4341
class AgenticIT {
4442

4543
// Lab test configuration
46-
private static final String BLUEPRINT_CLIENT_ID = "aab5089d-e764-47e3-9f28-cc11c2513821";
4744
private static final String RMA_CLIENT_ID = "3bf56293-fbb5-42bd-a407-248ba7431a8c";
4845
private static final String TENANT_ID = "10c419d4-4a50-45b2-aa4e-919fb84df24f";
4946
private static final String AGENT_APP_ID = "ab18ca07-d139-4840-8b3b-4be9610c6ed5";
50-
private static final String TOKEN_EXCHANGE_SCOPE = "api://AzureADTokenExchange/.default";
5147
private static final String FMI_EXCHANGE_SCOPE = "api://AzureFMITokenExchange/.default";
52-
private static final String GRAPH_SCOPE = "https://graph.microsoft.com/.default";
5348
private static final String AZURE_REGION = "westus3";
5449

5550
private static final String AUTHORITY = "https://login.microsoftonline.com/" + TENANT_ID + "/";
@@ -71,40 +66,6 @@ void init() throws KeyStoreException, NoSuchProviderException,
7166
assertNotNull(certificate, "Lab certificate not found. Ensure the lab cert is installed.");
7267
}
7368

74-
/**
75-
* Agent gets an app-only token for Graph using an FMI-sourced client assertion.
76-
* This tests Leg 2 of the agent identity flow:
77-
* 1. Blueprint CCA acquires FMI credential (fmi_path = agentAppId)
78-
* 2. Agent CCA uses that credential as client_assertion to get Graph token
79-
*/
80-
@Test
81-
void agentGetsAppToken_UsingFmiAssertion() throws Exception {
82-
// The assertion callback simulates what an SDK or middleware would do:
83-
// it calls the blueprint app to get an FMI credential for the agent
84-
Function<AssertionRequestOptions, String> assertionProvider = options -> {
85-
try {
86-
return acquireFmiCredentialForAgent(AGENT_APP_ID);
87-
} catch (Exception e) {
88-
throw new RuntimeException("Failed to acquire FMI credential", e);
89-
}
90-
};
91-
92-
IClientCredential credential = ClientCredentialFactory.createFromCallback(assertionProvider);
93-
94-
ConfidentialClientApplication agentCca = ConfidentialClientApplication.builder(AGENT_APP_ID, credential)
95-
.authority(AUTHORITY)
96-
.build();
97-
98-
IAuthenticationResult result = agentCca.acquireToken(ClientCredentialParameters
99-
.builder(Collections.singleton(GRAPH_SCOPE))
100-
.build())
101-
.get();
102-
103-
assertNotNull(result, "Auth result should not be null");
104-
assertNotNull(result.accessToken(), "Access token should not be null");
105-
assertFalse(result.accessToken().isEmpty(), "Access token should not be empty");
106-
}
107-
10869
/**
10970
* Verifies that the context-aware assertion callback receives the correct fmiPath
11071
* when the ClientCredentialParameters include an fmiPath.
@@ -154,40 +115,6 @@ void assertionCallback_ReceivesFmiPathContext() throws Exception {
154115
assertNotNull(result.accessToken(), "Access token should not be null");
155116
}
156117

157-
/**
158-
* Verifies that the agent CCA can acquire a token and it gets cached,
159-
* then the second request is a cache hit.
160-
*/
161-
@Test
162-
void agentAppToken_CacheHit() throws Exception {
163-
Function<AssertionRequestOptions, String> assertionProvider = options -> {
164-
try {
165-
return acquireFmiCredentialForAgent(AGENT_APP_ID);
166-
} catch (Exception e) {
167-
throw new RuntimeException("Failed to acquire FMI credential", e);
168-
}
169-
};
170-
171-
IClientCredential credential = ClientCredentialFactory.createFromCallback(assertionProvider);
172-
173-
ConfidentialClientApplication agentCca = ConfidentialClientApplication.builder(AGENT_APP_ID, credential)
174-
.authority(AUTHORITY)
175-
.build();
176-
177-
ClientCredentialParameters params = ClientCredentialParameters
178-
.builder(Collections.singleton(GRAPH_SCOPE))
179-
.build();
180-
181-
IAuthenticationResult result1 = agentCca.acquireToken(params).get();
182-
IAuthenticationResult result2 = agentCca.acquireToken(params).get();
183-
184-
// Second call should be a cache hit
185-
assertEquals(result1.accessToken(), result2.accessToken(),
186-
"Second request should be a cache hit returning the same token");
187-
assertEquals(1, agentCca.tokenCache.accessTokens.size(),
188-
"Should have only one cache entry");
189-
}
190-
191118
/**
192119
* Verifies that tokens acquired with different fmi_paths are isolated in cache
193120
* even when using the same agent CCA.
@@ -231,29 +158,6 @@ void agentFmiToken_CacheIsolation_DifferentFmiPaths() throws Exception {
231158
"Tokens for different fmi_paths should be different");
232159
}
233160

234-
/**
235-
* Helper: acquires an FMI credential from the blueprint app for the given agent app ID.
236-
* Uses the agent token exchange scope (api://AzureADTokenExchange).
237-
*/
238-
private String acquireFmiCredentialForAgent(String agentAppId) throws Exception {
239-
IClientCertificate clientCert = ClientCredentialFactory.createFromCertificate(privateKey, certificate);
240-
241-
ConfidentialClientApplication blueprintCca = ConfidentialClientApplication.builder(
242-
BLUEPRINT_CLIENT_ID, clientCert)
243-
.authority(AUTHORITY)
244-
.sendX5c(true)
245-
.azureRegion(AZURE_REGION)
246-
.build();
247-
248-
ClientCredentialParameters params = ClientCredentialParameters
249-
.builder(Collections.singleton(TOKEN_EXCHANGE_SCOPE))
250-
.fmiPath(agentAppId)
251-
.build();
252-
253-
IAuthenticationResult result = blueprintCca.acquireToken(params).get();
254-
return result.accessToken();
255-
}
256-
257161
/**
258162
* Helper: acquires an FMI credential from the RMA using a certificate.
259163
* Uses the FMI-specific exchange scope (api://AzureFMITokenExchange).

0 commit comments

Comments
 (0)