summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-08-27 21:04:20 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-08-27 21:04:20 +0000
commitedc209e114cb84977b592bd4ef2fe8203a68951c (patch)
treee8c030a47a296fef1d8ed354b9a30df951a722fd /tests
parent90a864d13085e37bb8798fa64984d2876870fbd4 (diff)
parent2ac7bbd85d016d5baf582cd6f04dda6f434a3c9f (diff)
Merge "[Enterprise] Fix hasEnterpriseConfigChanged method" into rvc-qpr-dev
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigurationUtilTest.java81
1 files changed, 81 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationUtilTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationUtilTest.java
index 8d7f5c6e6..0dd5b1214 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationUtilTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationUtilTest.java
@@ -16,6 +16,9 @@
package com.android.server.wifi;
+import static android.net.wifi.WifiEnterpriseConfig.OCSP_NONE;
+import static android.net.wifi.WifiEnterpriseConfig.OCSP_REQUIRE_CERT_STATUS;
+
import static org.junit.Assert.*;
import android.content.pm.UserInfo;
@@ -980,4 +983,82 @@ public class WifiConfigurationUtilTest extends WifiBaseTest {
return this;
}
}
+
+ /**
+ * Verify WifiEnterpriseConfig CA Certificate alias changes are detected.
+ */
+ @Test
+ public void testCaCertificateAliasChangesDetected() {
+ EnterpriseConfig eapConfig1 = new EnterpriseConfig(WifiEnterpriseConfig.Eap.TTLS)
+ .setPhase2(WifiEnterpriseConfig.Phase2.MSCHAPV2)
+ .setIdentity("username", "password");
+ eapConfig1.enterpriseConfig.setCaCertificateAlias("ALIAS_1");
+
+ EnterpriseConfig eapConfig2 = new EnterpriseConfig(WifiEnterpriseConfig.Eap.TTLS)
+ .setPhase2(WifiEnterpriseConfig.Phase2.MSCHAPV2)
+ .setIdentity("username", "password");
+ eapConfig2.enterpriseConfig.setCaCertificateAlias("ALIAS_2");
+
+ assertTrue(WifiConfigurationUtil.hasEnterpriseConfigChanged(eapConfig1.enterpriseConfig,
+ eapConfig2.enterpriseConfig));
+ }
+
+ /**
+ * Verify WifiEnterpriseConfig Client Certificate alias changes are detected.
+ */
+ @Test
+ public void testClientCertificateAliasChangesDetected() {
+ EnterpriseConfig eapConfig1 = new EnterpriseConfig(WifiEnterpriseConfig.Eap.TLS);
+ eapConfig1.enterpriseConfig.setCaCertificateAlias("ALIAS_1");
+ eapConfig1.enterpriseConfig.setClientCertificateAlias("CLIENT_ALIAS_1");
+
+ EnterpriseConfig eapConfig2 = new EnterpriseConfig(WifiEnterpriseConfig.Eap.TTLS);
+ eapConfig2.enterpriseConfig.setCaCertificateAlias("ALIAS_1");
+ eapConfig2.enterpriseConfig.setClientCertificateAlias("CLIENT_ALIAS_2");
+
+ assertTrue(WifiConfigurationUtil.hasEnterpriseConfigChanged(eapConfig1.enterpriseConfig,
+ eapConfig2.enterpriseConfig));
+ }
+
+ /**
+ * Verify WifiEnterpriseConfig OCSP changes are detected.
+ */
+ @Test
+ public void testOcspChangesDetected() {
+ EnterpriseConfig eapConfig1 = new EnterpriseConfig(WifiEnterpriseConfig.Eap.TTLS)
+ .setPhase2(WifiEnterpriseConfig.Phase2.MSCHAPV2)
+ .setIdentity("username", "password")
+ .setCaCerts(new X509Certificate[]{FakeKeys.CA_CERT0});
+ eapConfig1.enterpriseConfig.setOcsp(OCSP_NONE);
+
+ EnterpriseConfig eapConfig2 = new EnterpriseConfig(WifiEnterpriseConfig.Eap.TTLS)
+ .setPhase2(WifiEnterpriseConfig.Phase2.MSCHAPV2)
+ .setIdentity("username", "password")
+ .setCaCerts(new X509Certificate[]{FakeKeys.CA_CERT0});
+ eapConfig2.enterpriseConfig.setOcsp(OCSP_REQUIRE_CERT_STATUS);
+
+ assertTrue(WifiConfigurationUtil.hasEnterpriseConfigChanged(eapConfig1.enterpriseConfig,
+ eapConfig2.enterpriseConfig));
+ }
+
+ /**
+ * Verify WifiEnterpriseConfig subject match changes are detected.
+ */
+ @Test
+ public void testSubjectMatchChangesDetected() {
+ EnterpriseConfig eapConfig1 = new EnterpriseConfig(WifiEnterpriseConfig.Eap.TTLS)
+ .setPhase2(WifiEnterpriseConfig.Phase2.MSCHAPV2)
+ .setIdentity("username", "password")
+ .setCaCerts(new X509Certificate[]{FakeKeys.CA_CERT0});
+ eapConfig1.enterpriseConfig.setAltSubjectMatch("domain1.com");
+
+ EnterpriseConfig eapConfig2 = new EnterpriseConfig(WifiEnterpriseConfig.Eap.TTLS)
+ .setPhase2(WifiEnterpriseConfig.Phase2.MSCHAPV2)
+ .setIdentity("username", "password")
+ .setCaCerts(new X509Certificate[]{FakeKeys.CA_CERT0});
+ eapConfig1.enterpriseConfig.setAltSubjectMatch("domain2.com");
+
+ assertTrue(WifiConfigurationUtil.hasEnterpriseConfigChanged(eapConfig1.enterpriseConfig,
+ eapConfig2.enterpriseConfig));
+ }
}