[msal-react] How should I automate Azure AD login in my automated integration test?
See original GitHub issueCore Library
MSAL.js v2 (@azure/msal-browser)
Core Library Version
2.21.0
Wrapper Library
MSAL React (@azure/msal-react)
Wrapper Library Version
1.2.0
Description
I am working on an automated test (e.g. using Cypress or Selenium) that needs to initially get pass the Azure AD login screen.
In this test, I am able to make a POST request to https://login.microsoftonline.com/my-tenantId/oauth2/v2.0/token
with the grant type client_credentials
and a client_id and client_secret. I get a token back.
However, I don’t understand how I should save this token into the sessionStorage so that when my Cypress test visits localhost:8080
, I avoid the redirect to login again. I would prefer my test to not use an email/password to login (and instead use the client credentials).
When I look at how msal-react updates the sessionStorage in my real-world browser runtime, I see quite a few MSAL tokens being saved into session storage. I don’t understand if I need to get all of these using POST requests.
Am I going about automating this the wrong way? Would love some guidance or direction on which documentation I should read for my use case. Thanks!
MSAL Configuration
No response
Relevant Code Snippets
No response
Identity Provider
Azure AD / MSA
Source
External (Customer)
Issue Analytics
- State:
- Created 2 years ago
- Comments:15 (8 by maintainers)
Top GitHub Comments
Yes, please mark it resolved. Appreciate your support, @hectormmg !
@whatjakecodes I’ve been looking further into your approach, and I think you should check out the testing doc we have on using
loadExternalTokens
API. What you originally wanted to do is achievable through this advanced API.