How should I automate Azure AD login in my automated integration test? #6293
Labels
msal-browser
Related to msal-browser package
msal-react
Related to @azure/msal-react
Needs: Author Feedback
Awaiting response from issue author
no-issue-activity
Issue author has not responded in 5 days
question
Customer is asking for a clarification, use case or information.
Core Library
MSAL.js (@azure/msal-browser)
Core Library Version
2.38.0
Wrapper Library
MSAL React (@azure/msal-react)
Wrapper Library Version
none
Public or Confidential Client?
Confidential
Description
I am testing an app that relies on MSAL React! Our app uses UnauthenticatedTemplate and AuthenticatedTemplate components -- if the Unauthenticated component loads, our app immediately redirects to the logon.microsoft.com/tenantID URL. This redirect is what we are trying to prevent by having our e2e test first establish a valid session, and then after that, our e2e test navigates to our app hosted on localhost (and that app should detect we already have a session, and thus not redirect).
My team came to the conclusion today that client_credentials isn't the correct grant type for our use case. It's not similar enough to a user logging in. So we're exploring using a test user account credential with the password grant_type instead, now.
We're trying to get something like the below code working. The main problem we're having, is after getting the response back, how should we save the token into sessionStorage correctly? Saving to id_token as below is wrong - msal-react seems to save several token key names, and I am not sure how to generate that list of token keys properly
Cypress.Commands.add("aadAuthenticate", window => {
const clientId = "my-client-id";
const tenantId = "my-tenant-id";
const clientSecret = "my-secret";
});
MSAL Configuration
No response
Relevant Code Snippets
No response
Identity Provider
Azure AD / MSA
Source
Internal (Microsoft)
The text was updated successfully, but these errors were encountered: