Skip to content

Commit 6f4baa5

Browse files
committed
added flights for device ca https change
1 parent 6a2d3ec commit 6f4baa5

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

common/src/main/java/com/microsoft/identity/common/internal/ui/webview/AzureActiveDirectoryWebViewClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,9 @@ else if (isRedirectUrl(formattedURL)) {
343343
processWebCpEnrollmentUrl(view, url);
344344
} else if (mIsWebCpInWebViewFeatureEnabled && isWebCpAuthorizeUrl(url)) {
345345
processWebCpAuthorize(view, url);
346-
} else if (isDeviceCaRequest(url) && isHttpsScheme(url)) {
346+
} else if (isDeviceCaRequest(url) && isHttpsScheme(url) && isWebCpInWebviewFeatureEnabled(url)) {
347347
// Special handling for device CA requests due to a corner case in eSTS for webapps/confidential clients, which should be handled by the WebView.
348+
Logger.info(methodTag, "Navigation contains device CA request with https scheme.");
348349
processDeviceCaRequest(view, url);
349350
} else {
350351
Logger.info(methodTag,"This maybe a valid URI, but no special handling for this mentioned URI, hence deferring to WebView for loading.");

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,32 @@ public void testUrlOverrideHandlesWebsiteRequestUrl() {
172172
}
173173

174174
@Test
175+
@Config(shadows = {
176+
ShadowProcessUtil.class})
175177
public void testUrlOverrideHandlesHttpsDeviceCARequestUrl() {
178+
final IFlightsProvider mockFlightsProvider = Mockito.mock(IFlightsProvider.class);
179+
when(mockFlightsProvider.isFlightEnabled(CommonFlight.ENABLE_WEB_CP_IN_WEBVIEW)).thenReturn(true);
180+
181+
final MockCommonFlightsManager mockCommonFlightsManager = new MockCommonFlightsManager();
182+
mockCommonFlightsManager.setMockCommonFlightsProvider(mockFlightsProvider);
183+
CommonFlightsManager.INSTANCE.initializeCommonFlightsManager(mockCommonFlightsManager);
176184
assertTrue(mWebViewClient.shouldOverrideUrlLoading(mMockWebView, TEST_HTTPS_DEVICE_CA_URL_QUERY_STRING_PARAMETER));
185+
CommonFlightsManager.INSTANCE.resetFlightsManager();
177186
}
178187

188+
@Test
189+
@Config(shadows = {
190+
ShadowProcessUtil.class})
191+
public void testUrlHandlesHttpsDeviceCARequestUrlFlightOff() {
192+
final IFlightsProvider mockFlightsProvider = Mockito.mock(IFlightsProvider.class);
193+
when(mockFlightsProvider.isFlightEnabled(CommonFlight.ENABLE_WEB_CP_IN_WEBVIEW)).thenReturn(false);
194+
195+
final MockCommonFlightsManager mockCommonFlightsManager = new MockCommonFlightsManager();
196+
mockCommonFlightsManager.setMockCommonFlightsProvider(mockFlightsProvider);
197+
CommonFlightsManager.INSTANCE.initializeCommonFlightsManager(mockCommonFlightsManager);
198+
assertFalse(mWebViewClient.shouldOverrideUrlLoading(mMockWebView, TEST_HTTPS_DEVICE_CA_URL_QUERY_STRING_PARAMETER));
199+
CommonFlightsManager.INSTANCE.resetFlightsManager();
200+
}
179201

180202
@Test
181203
public void testUrlOverrideHandlesInstallRequest() {

0 commit comments

Comments
 (0)