diff options
author | Chiachang Wang <chiachangwang@google.com> | 2020-06-08 16:20:38 +0000 |
---|---|---|
committer | Remi NGUYEN VAN <reminv@google.com> | 2020-07-03 14:56:21 +0900 |
commit | b002fd1e07d040b9c08852f63cfee2dbb7e811fe (patch) | |
tree | 210ef04d4283cf7c105ed123730511c2e0fae1a0 /tests | |
parent | b8ac953af4ffc4a82fdc9a58f76fd96756c3cf49 (diff) |
Update CapportData in CapportApiProbeResult to be nullable
If capport API does not send any valid rely, the capportData
could be null in CapportApiProbeResult. Thus, take null
capportData for invalid case.
Bug: 154196512
Bug: 139034276
Bug: 151796056
Test: atest NetworkStackTests
Merged-In: I99cbff2eb1a9ab87a42011038d911fe15e7344a4
Change-Id: I99cbff2eb1a9ab87a42011038d911fe15e7344a4
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java b/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java index 00fe17c..a3ef532 100644 --- a/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java +++ b/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java @@ -1152,7 +1152,29 @@ public class NetworkMonitorTest { } @Test - public void testIsCaptivePortal_CapportApiIsPortal() throws Exception { + public void testIsCaptivePortal_CapportApiIsPortalWithNullPortalUrl() throws Exception { + assumeTrue(CaptivePortalDataShimImpl.isSupported()); + setSslException(mHttpsConnection); + final long bytesRemaining = 10_000L; + final long secondsRemaining = 500L; + // Set content without partal url. + setApiContent(mCapportApiConnection, "{'captive': true," + + "'venue-info-url': '" + TEST_VENUE_INFO_URL + "'," + + "'bytes-remaining': " + bytesRemaining + "," + + "'seconds-remaining': " + secondsRemaining + "}"); + setPortal302(mHttpConnection); + + runNetworkTest(makeCapportLPs(), CELL_METERED_CAPABILITIES, VALIDATION_RESULT_PORTAL, + 0 /* probesSucceeded*/, TEST_LOGIN_URL); + + verify(mCapportApiConnection).getResponseCode(); + + verify(mHttpConnection, times(1)).getResponseCode(); + verify(mCallbacks, never()).notifyCaptivePortalDataChanged(any()); + } + + @Test + public void testIsCaptivePortal_CapportApiIsPortalWithValidPortalUrl() throws Exception { assumeTrue(CaptivePortalDataShimImpl.isSupported()); setSslException(mHttpsConnection); final long bytesRemaining = 10_000L; |