Skip to content

Commit c01f461

Browse files
authored
Reset flights between tests, Fixes AB#3413737 (#2794)
The testcase testUrlOverrideHandlesNonceRedirectUrl was failing because there was a new testcase introduced in the class where we were setting flights but we missed resetting them before the next testcase runs. Fix : Resetting flights between the UTs Additional fix : There was a change that was relying on the state of flights set in previous tests which was incorrect. Correcting this as well. Fixes [AB#3413737](https://identitydivision.visualstudio.com/fac9d424-53d2-45c0-91b5-ef6ba7a6bf26/_workitems/edit/3413737)
1 parent 6353bd7 commit c01f461

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

common/src/test/java/com/microsoft/identity/common/internal/ui/webview/AzureActiveDirectoryWebViewClientTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import com.microsoft.identity.common.java.ui.webview.authorization.IAuthorizationCompletionCallback;
6363
import com.microsoft.identity.common.shadows.ShadowProcessUtil;
6464

65+
import org.junit.After;
6566
import org.junit.Assert;
6667
import org.junit.Before;
6768
import org.junit.Test;
@@ -159,6 +160,11 @@ public void onPageLoaded(final String url) {
159160
}
160161
}
161162

163+
@After
164+
public void cleanUp(){
165+
CommonFlightsManager.INSTANCE.resetFlightsManager();
166+
}
167+
162168
@Test(expected = IllegalArgumentException.class)
163169
public void testUrlOverrideHandlesEmptyString() {
164170
assertTrue(mWebViewClient.shouldOverrideUrlLoading(mMockWebView, ""));
@@ -489,6 +495,11 @@ public void testOnReceivedSslError_Legacy() {
489495
final SslError mockError = Mockito.mock(android.net.http.SslError.class);
490496
final IAuthorizationCompletionCallback mockCallback = Mockito.mock(IAuthorizationCompletionCallback.class);
491497
when(mockError.getUrl()).thenReturn("https://example.com");
498+
final IFlightsManager mockFlightsManager = Mockito.mock(IFlightsManager.class);
499+
final IFlightsProvider mockFlightsProvider = Mockito.mock(IFlightsProvider.class);
500+
when(mockFlightsProvider.isFlightEnabled(eq(CommonFlight.SHOULD_PRESERVE_WEBVIEW_FLOW_ON_SSL_ERROR))).thenReturn(false);
501+
when(mockFlightsManager.getFlightsProvider(anyLong())).thenReturn(mockFlightsProvider);
502+
CommonFlightsManager.INSTANCE.initializeCommonFlightsManager(mockFlightsManager);
492503
final AzureActiveDirectoryWebViewClient mockWebViewClient = new AzureActiveDirectoryWebViewClient(
493504
mActivity,
494505
mockCallback,

0 commit comments

Comments
 (0)