AzureAD / microsoft-authentication-library-for-js

Microsoft Authentication Library (MSAL) for JS

Home Page:http://aka.ms/aadv2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to force a `InteractionRequiredAuthError`? For integration testing

hterik opened this issue · comments

Core Library

MSAL.js (@azure/msal-browser)

Wrapper Library

MSAL React (@azure/msal-react)

Public or Confidential Client?

Public

Description

Hi
I'm in a situation where our application behaves very strange when msal throws a InteractionRequiredAuthError and application attempts to solve it with acquireTokenRedirect.
The problem is that Interaction required only happens once every few days and the whole flow becomes very difficult to troubleshoot and reproduce.

Is there any way one can force such an error? Just unit testing the scenarios is not enough, because how acquireTokenPopup/ acquireTokenRedirect behave together with the browser and interaction with Azure is also very tightly coupled.

Source

External (Customer)

If you're testing manually you can delete the refresh token from local/session storage and set CacheLookupPolicy to "RefreshToken".

If you're attempting to write tests I recommend mocking the call.

@hterik This issue has been automatically marked as stale because it is marked as requiring author feedback but has not had any activity for 5 days. If your issue has been resolved please let us know by closing the issue. If your issue has not been resolved please leave a comment to keep this open. It will be closed automatically in 7 days if it remains stale.