diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2019-08-28 20:22:44 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-08-28 20:22:44 +0000 |
commit | e7588d9fa3e2661ff0505172c96f5626c3016a91 (patch) | |
tree | dc3b2265d9e77876f5740f239d398debd86b7b34 /tests | |
parent | e8b5da4cd4f31ee92095648dd1c9a0cd0483869e (diff) | |
parent | 07969aeeab3a0caebef26d1b2921d53845101f56 (diff) |
Merge "Change system language, passpoint R2 failed to connect" into qt-qpr1-dev
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/hotspot2/OsuServerConnectionTest.java | 85 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProvisionerTest.java | 9 |
2 files changed, 87 insertions, 7 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/OsuServerConnectionTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/OsuServerConnectionTest.java index 843caf1a9..9fa92c9a3 100644 --- a/tests/wifitests/src/com/android/server/wifi/hotspot2/OsuServerConnectionTest.java +++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/OsuServerConnectionTest.java @@ -86,6 +86,7 @@ public class OsuServerConnectionTest { private static final String AUTH_TYPE = "ECDHE_RSA"; private static final String PROVIDER_NAME_VALID = "Boingo"; private static final String PROVIDER_NAME_INVALID = "Boingo1"; + private static final String TEST_PROVIDER_CHINESE_NAME = "宝音阁"; private static final int ENABLE_VERBOSE_LOGGING = 1; private static final int TEST_SESSION_ID = 1; @@ -144,7 +145,85 @@ public class OsuServerConnectionTest { trustManager.checkServerTrusted(new X509Certificate[1], AUTH_TYPE); verify(mOsuServerCallbacks).onServerValidationStatus(anyInt(), eq(true)); - assertTrue(mOsuServerConnection.validateProvider(Locale.US, PROVIDER_NAME_VALID)); + Map<String, String> providerNames = new HashMap<>(); + providerNames.put(Locale.US.getISO3Language(), PROVIDER_NAME_VALID); + assertTrue(mOsuServerConnection.validateProvider(providerNames)); + } finally { + session.finishMocking(); + } + } + + /** + * Verifies multiple languages of OsuProvider names are matched with cert + */ + @Test + public void verifyValidateProviderWithMultipleProviderLangs() throws Exception { + // static mocking + MockitoSession session = ExtendedMockito.mockitoSession().mockStatic( + ServiceProviderVerifier.class).startMocking(); + try { + when(ServiceProviderVerifier.getProviderNames(any(X509Certificate.class))).thenReturn( + mProviderIdentities); + establishServerConnection(); + TrustManager[] trustManagers = mTrustManagerCaptor.getValue(); + X509TrustManager trustManager = (X509TrustManager) trustManagers[0]; + trustManager.checkServerTrusted(new X509Certificate[1], AUTH_TYPE); + Map<String, String> friendlyNames = new HashMap<>(); + friendlyNames.put( + Locale.SIMPLIFIED_CHINESE.getISO3Language(), TEST_PROVIDER_CHINESE_NAME); + friendlyNames.put(Locale.US.getISO3Language(), PROVIDER_NAME_VALID); + + assertTrue(mOsuServerConnection.validateProvider(friendlyNames)); + } finally { + session.finishMocking(); + } + } + + /** + * Verifies wrong language of OsuProvider name is mismatched with cert + */ + @Test + public void verifyValidateProviderWithMismatchedProviderLang() throws Exception { + // static mocking + MockitoSession session = ExtendedMockito.mockitoSession().mockStatic( + ServiceProviderVerifier.class).startMocking(); + try { + when(ServiceProviderVerifier.getProviderNames(any(X509Certificate.class))).thenReturn( + mProviderIdentities); + establishServerConnection(); + TrustManager[] trustManagers = mTrustManagerCaptor.getValue(); + X509TrustManager trustManager = (X509TrustManager) trustManagers[0]; + trustManager.checkServerTrusted(new X509Certificate[1], AUTH_TYPE); + Map<String, String> friendlyNames = new HashMap<>(); + friendlyNames.put( + Locale.SIMPLIFIED_CHINESE.getISO3Language(), TEST_PROVIDER_CHINESE_NAME); + + assertFalse(mOsuServerConnection.validateProvider(friendlyNames)); + } finally { + session.finishMocking(); + } + } + + /** + * Verifies same language from different regions. + */ + @Test + public void verifyValidateProviderWithSameLangButDifferentRegion() throws Exception { + // static mocking + MockitoSession session = ExtendedMockito.mockitoSession().mockStatic( + ServiceProviderVerifier.class).startMocking(); + try { + when(ServiceProviderVerifier.getProviderNames(any(X509Certificate.class))).thenReturn( + mProviderIdentities); + establishServerConnection(); + TrustManager[] trustManagers = mTrustManagerCaptor.getValue(); + X509TrustManager trustManager = (X509TrustManager) trustManagers[0]; + trustManager.checkServerTrusted(new X509Certificate[1], AUTH_TYPE); + Map<String, String> friendlyNames = new HashMap<>(); + friendlyNames.put( + Locale.CANADA.getISO3Language(), PROVIDER_NAME_VALID); + + assertTrue(mOsuServerConnection.validateProvider(friendlyNames)); } finally { session.finishMocking(); } @@ -250,7 +329,9 @@ public class OsuServerConnectionTest { trustManager.checkServerTrusted(new X509Certificate[1], AUTH_TYPE); verify(mOsuServerCallbacks).onServerValidationStatus(anyInt(), eq(true)); - assertFalse(mOsuServerConnection.validateProvider(Locale.US, PROVIDER_NAME_INVALID)); + Map<String, String> providerNames = new HashMap<>(); + providerNames.put(Locale.US.getISO3Language(), PROVIDER_NAME_INVALID); + assertFalse(mOsuServerConnection.validateProvider(providerNames)); } finally { session.finishMocking(); } diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProvisionerTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProvisionerTest.java index 10ce65067..64a7f9e2d 100644 --- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProvisionerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProvisionerTest.java @@ -97,7 +97,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; -import java.util.Locale; import java.util.Map; import javax.net.ssl.SSLContext; @@ -224,8 +223,8 @@ public class PasspointProvisionerTest { mPasspointManager, mWifiMetrics); when(mOsuNetworkConnection.connect(any(WifiSsid.class), any(), any())).thenReturn(true); when(mOsuServerConnection.connect(any(URL.class), any(Network.class))).thenReturn(true); - when(mOsuServerConnection.validateProvider(any(Locale.class), - any(String.class))).thenReturn(true); + when(mOsuServerConnection.validateProvider( + anyMap())).thenReturn(true); when(mOsuServerConnection.canValidateServer()).thenReturn(true); mPasspointProvisioner.enableVerboseLogging(1); mOsuProvider = PasspointProvisioningTestUtil.generateOsuProvider(true); @@ -728,8 +727,8 @@ public class PasspointProvisionerTest { */ @Test public void verifyProviderVerificationFailure() throws RemoteException { - when(mOsuServerConnection.validateProvider(any(Locale.class), - any(String.class))).thenReturn(false); + when(mOsuServerConnection.validateProvider( + anyMap())).thenReturn(false); stopAfterStep(STEP_SERVER_CONNECT); // Wait for OSU server validation callback |