Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding FMI Integration tests #5149

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Adding FMI Integration tests #5149

wants to merge 6 commits into from

Conversation

trwalke
Copy link
Member

@trwalke trwalke commented Feb 19, 2025

Fixes #

Changes proposed in this request

Testing

Performance impact

Documentation

  • All relevant documentation is updated.

[TestClass]
public class FmiIntegrationTests
{
private const string _fmiAppUrn = "urn:microsoft:identity:fmi";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style for constants is different I believe. SomeConstant

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add an analyzer for it

Copy link
Member

@bgavrilMS bgavrilMS Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It exists as suggestion today, I agree the UI isn't very clear about it (the 3 little dots0

image

You can make it a warning in the .editorconfig.

image

.ExecuteAsync()
.ConfigureAwait(false);

MsalAssert.AssertAuthResult(authResult);
Copy link
Member

@bgavrilMS bgavrilMS Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What you should really assert on is:

  • the cache key (internal and external)
  • the sub claim of the token
  • the aud claim of the token
  • other claims?

So I suggest you do all the checks inline.

Copy link
Member

@bgavrilMS bgavrilMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are not easy to read

"expectedAudience");
}

private static async Task<string> GetParentCredential(AssertionRequestOptions options)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the assertion logic to a private method. It seemed like too much code to have this in every test. This is also how JM has it in his spec

.BuildConcrete();

//Configure token cache serialization
confidentialApp.AppTokenCache.SetBeforeAccess(BeforeCacheAccess);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you pls use the static cache here? And update the TestBase to delete the static cache on every test.


//Fmi app/scenario parameters
var clientId = "4df2cbbb-8612-49c1-87c8-f334d6d065ad";
var scope = "api://AzureFMITokenExchange/.default";
Copy link
Member

@bgavrilMS bgavrilMS Feb 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no reason for these variables.

namespace Microsoft.Identity.Test.Integration.NetCore.HeadlessTests
{
/// <summary>
/// The tests in this file are demonstrations of the various authentication flows outlined in the "FMI protocol spec v1.0" Section 3.2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The tests in this file are demonstrations of the various authentication flows outlined in the "FMI protocol spec v1.0" Section 3.2
/// The tests in this file are demonstrations of the various authentication flows outlined in the "FMI protocol spec v1.0" Section 3.2
/// https://microsoft.sharepoint.com/:w:/t/aad/protocols/EThMH6es0UNKhsFlVgBiBegByuZQ6CnaCzzAdAV0excHVA?e=m5xXtV


//Fmi app/scenario parameters
var clientId = "4df2cbbb-8612-49c1-87c8-f334d6d065ad";
var scope = "022907d3-0f1b-48f7-badc-1ba6abab6d66/.default";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Maybe add a comment of what this resource represents


//Acquire Token
var authResult = await confidentialApp.AcquireTokenForClient(new[] { scope })
.WithFmiPath("SomeFmiPath/Path") //Sets fmi path in client credential request.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a different FMI path for the credential.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants