Skip to content

Commit e0d0243

Browse files
committed
Address PR
1 parent e65ba62 commit e0d0243

File tree

1 file changed

+8
-8
lines changed
  • tests/Microsoft.Identity.Test.Integration.netcore/HeadlessTests

1 file changed

+8
-8
lines changed

tests/Microsoft.Identity.Test.Integration.netcore/HeadlessTests/Agentic.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,18 @@ public class Agentic
2020
const string AgentIdentity = "d84da24a-2ea2-42b8-b5ab-8637ec208024";
2121
const string UserUpn = "aui1@msidlabtoint.onmicrosoft.com";
2222
private const string TokenExchangeUrl = "api://AzureADTokenExchange/.default";
23+
private const string Scope = "https://graph.microsoft.com/.default";
2324

2425
[TestMethod]
2526
public async Task AgentUserIdentityGetsTokenForGraphTest()
2627
{
2728
await AgentUserIdentityGetsTokenForGraphAsync().ConfigureAwait(false);
28-
await AgentUserIdentityGetsTokenForGraphAsync().ConfigureAwait(false);
2929
}
3030

3131
[TestMethod]
3232
public async Task AgentGetsAppTokenForGraphTest()
3333
{
3434
await AgentGetsAppTokenForGraph().ConfigureAwait(false);
35-
await AgentGetsAppTokenForGraph().ConfigureAwait(false);
3635
}
3736

3837
private static async Task AgentGetsAppTokenForGraph()
@@ -45,7 +44,7 @@ private static async Task AgentGetsAppTokenForGraph()
4544
.WithClientAssertion((AssertionRequestOptions _) => GetAppCredentialAsync(AgentIdentity))
4645
.Build();
4746

48-
var result = await cca.AcquireTokenForClient(["https://graph.microsoft.com/.default"])
47+
var result = await cca.AcquireTokenForClient([Scope])
4948
.ExecuteAsync()
5049
.ConfigureAwait(false);
5150

@@ -63,14 +62,10 @@ private static async Task AgentUserIdentityGetsTokenForGraphAsync()
6362
.WithClientAssertion((AssertionRequestOptions _) => GetAppCredentialAsync(AgentIdentity))
6463
.Build();
6564

66-
var result = await (cca as IByUsernameAndPassword).AcquireTokenByUsernamePassword(["https://graph.microsoft.com/.default"], UserUpn, "no_password")
65+
var result = await (cca as IByUsernameAndPassword).AcquireTokenByUsernamePassword([Scope], UserUpn, "no_password")
6766
.OnBeforeTokenRequest(
6867
async (request) =>
6968
{
70-
// Already in the request:
71-
// - client_id = agentIdentity;
72-
// - client_assertion is the AA FIC
73-
7469
string userFicAssertion = await GetUserFic().ConfigureAwait(false);
7570
request.BodyParameters["user_federated_identity_credential"] = userFicAssertion;
7671
request.BodyParameters["grant_type"] = "user_fic";
@@ -87,6 +82,11 @@ private static async Task AgentUserIdentityGetsTokenForGraphAsync()
8782
)
8883
.ExecuteAsync()
8984
.ConfigureAwait(false);
85+
86+
IAccount account = await cca.GetAccountAsync(result.Account.HomeAccountId.Identifier).ConfigureAwait(false);
87+
var result2 = await cca.AcquireTokenSilent([Scope], account).ExecuteAsync().ConfigureAwait(false);
88+
89+
Assert.IsTrue(result2.AuthenticationResultMetadata.TokenSource == TokenSource.Cache, "Token should be from cache");
9090
}
9191

9292
private static async Task<string> GetAppCredentialAsync(string fmiPath)

0 commit comments

Comments
 (0)