active-directory-aspnetcore-webapp-openidconnect-v2 icon indicating copy to clipboard operation
active-directory-aspnetcore-webapp-openidconnect-v2 copied to clipboard

Please add an example of how to test

Open jamiemccrindle opened this issue 5 years ago • 1 comments

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

The issue was found for the following scenario:

Please add an 'x' for the scenario(s) where you found an issue

  1. Web app that signs in users
    1. [x] with a work and school account in your organization: 1-WebApp-OIDC/1-1-MyOrg
    2. [x] with any work and school account: /1-WebApp-OIDC/1-2-AnyOrg
    3. [x] with any work or school account or Microsoft personal account: 1-WebApp-OIDC/1-3-AnyOrgOrPersonal
    4. [x] with users in National or sovereign clouds 1-WebApp-OIDC/1-4-Sovereign
    5. [x] with B2C users 1-WebApp-OIDC/1-5-B2C
  2. Web app that calls Microsoft Graph
    1. [x] Calling graph with the Microsoft Graph SDK: 2-WebApp-graph-user/2-1-Call-MSGraph
    2. [x] With specific token caches: 2-WebApp-graph-user/2-2-TokenCache
    3. [x] Calling Microsoft Graph in national clouds: 2-WebApp-graph-user/2-4-Sovereign-Call-MSGraph
  3. [x] Web app calling several APIs 3-WebApp-multi-APIs
  4. [x] Web app calling your own Web API 4-WebApp-your-API
  5. Web app restricting users
    1. [x] by Roles: 5-WebApp-AuthZ/5-1-Roles
    2. [x] by Groups: 5-WebApp-AuthZ/5-2-Groups
  6. [ ] Deployment to Azure
  7. [ ] Other (please describe)

Repro-ing the issue

Repro steps

N/A

Expected behavior

N/A

Actual behavior

N/A

Possible Solution

Add test cases e.g. using WebApplicationFactory

Additional context/ Error codes / Screenshots

N/A

Any log messages given by the failure

N/A

OS and Version?

N/A

Versions

N/A

Attempting to troubleshooting yourself:

I tried to use the examples here: https://docs.microsoft.com/en-us/aspnet/core/test/integration-tests?view=aspnetcore-3.1#mock-authentication but Azure AD auth fails before the Test handler can run.

Mention any other details that might be useful

You guys are awesome. Thanks so much for the examples.

jamiemccrindle avatar Mar 06 '20 18:03 jamiemccrindle

Hi @jamiemccrindle, we are planning in creating a chapter to talk about unit test in this tutorial. In the mean time, you have these tests from MSAL library as a reference.

TiagoBrenck avatar Mar 10 '20 00:03 TiagoBrenck

This is quite belated and possibly not relevant anymore but for anyone interested please follow the tutorial series here.

Closing.

derisen avatar Dec 08 '22 20:12 derisen