summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHai Shalom <haishalom@google.com>2020-03-03 22:18:43 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-03-03 22:18:43 +0000
commit43c5a6ba46c3b3c67c219a7e6bb1a6d9e93e5d77 (patch)
treec68764fb6851324235c827ccbf0613f2092807ef /tests
parent15d889dc2c5f8b7ce539407c2e8e13359dea70f6 (diff)
parentd2f78320591cfc19e27cae75720ccbf15b5cfeb5 (diff)
Merge "[Passpoint] Match HomeOIs to Home Provider" into rvc-dev
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/hotspot2/ANQPMatcherTest.java64
-rw-r--r--tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java125
2 files changed, 187 insertions, 2 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/ANQPMatcherTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/ANQPMatcherTest.java
index a3a2bd19a..b7bb8afc1 100644
--- a/tests/wifitests/src/com/android/server/wifi/hotspot2/ANQPMatcherTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/ANQPMatcherTest.java
@@ -97,7 +97,7 @@ public class ANQPMatcherTest extends WifiBaseTest {
*/
@Test
public void matchRoamingConsortiumWithNullElement() throws Exception {
- assertFalse(ANQPMatcher.matchRoamingConsortium(null, new long[0]));
+ assertFalse(ANQPMatcher.matchRoamingConsortium(null, new long[0], false));
}
/**
@@ -111,7 +111,7 @@ public class ANQPMatcherTest extends WifiBaseTest {
long oi = 0x1234L;
RoamingConsortiumElement element =
new RoamingConsortiumElement(Arrays.asList(new Long[] {oi}));
- assertTrue(ANQPMatcher.matchRoamingConsortium(element, new long[] {oi}));
+ assertTrue(ANQPMatcher.matchRoamingConsortium(element, new long[] {oi}, false));
}
/**
@@ -360,4 +360,64 @@ public class ANQPMatcherTest extends WifiBaseTest {
DomainNameElement element = new DomainNameElement(Arrays.asList(domains));
assertFalse(ANQPMatcher.matchDomainName(element, null, imsiParam, simImsi));
}
+
+ /**
+ * Verify that match is found when HomeOI contains some of the RCOIs advertised by an AP marked
+ * as not required.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void matchAnyHomeOi() throws Exception {
+ long[] providerOis = new long[] {0x1234L, 0x5678L, 0xabcdL};
+ Long[] anqpOis = new Long[] {0x1234L, 0x5678L, 0xdeadL, 0xf0cdL};
+ RoamingConsortiumElement element =
+ new RoamingConsortiumElement(Arrays.asList(anqpOis));
+ assertTrue(ANQPMatcher.matchRoamingConsortium(element, providerOis, false));
+ }
+
+ /**
+ * Verify that no match is found when HomeOI does not contain any of the RCOIs advertised by an
+ * AP marked as not required.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void matchAnyHomeOiNegative() throws Exception {
+ long[] providerOis = new long[] {0x1234L, 0x5678L, 0xabcdL};
+ Long[] anqpOis = new Long[] {0xabc2L, 0x1232L};
+ RoamingConsortiumElement element =
+ new RoamingConsortiumElement(Arrays.asList(anqpOis));
+ assertFalse(ANQPMatcher.matchRoamingConsortium(element, providerOis, false));
+ }
+
+ /**
+ * Verify that match is found when HomeOI contains all of the RCOIs advertised by an AP marked
+ * as required.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void matchAllHomeOi() throws Exception {
+ long[] providerOis = new long[] {0x1234L, 0x5678L, 0xabcdL};
+ Long[] anqpOis = new Long[] {0x1234L, 0x5678L, 0xabcdL, 0xdeadL, 0xf0cdL};
+ RoamingConsortiumElement element =
+ new RoamingConsortiumElement(Arrays.asList(anqpOis));
+ assertTrue(ANQPMatcher.matchRoamingConsortium(element, providerOis, true));
+ }
+
+ /**
+ * Verify that match is not found when HomeOI does not contain all of the RCOIs advertised by an
+ * AP marked as required.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void matchAllHomeOiNegative() throws Exception {
+ long[] providerOis = new long[] {0x1234L, 0x5678L, 0xabcdL};
+ Long[] anqpOis = new Long[] {0x1234L, 0x5678L, 0xdeadL, 0xf0cdL};
+ RoamingConsortiumElement element =
+ new RoamingConsortiumElement(Arrays.asList(anqpOis));
+ assertFalse(ANQPMatcher.matchRoamingConsortium(element, providerOis, true));
+ }
}
diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java
index 4ebc6bd23..0f8b1b0ca 100644
--- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java
@@ -1456,4 +1456,129 @@ public class PasspointProviderTest extends WifiBaseTest {
assertEquals(PasspointMatch.HomeProvider,
mProvider.match(anqpElementMap, mRoamingConsortium));
}
+
+ /**
+ * Verify that matching Any HomeOI results in a Home Provider match
+ *
+ * @throws Exception
+ */
+ @Test
+ public void matchAnyHomeOi() throws Exception {
+ // Setup test provider.
+ PasspointConfiguration config = generateTestPasspointConfiguration(
+ CredentialType.USER, false);
+ Long[] anqpOis = new Long[] {0x1234L, 0xdeadL, 0xf0cdL};
+
+ // Configuration was created with TEST_FQDN as the FQDN
+ HomeSp homeSp = config.getHomeSp();
+ homeSp.setMatchAnyOis(TEST_RC_OIS);
+ homeSp.setRoamingConsortiumOis(null);
+ config.setHomeSp(homeSp);
+ mProvider = createProvider(config);
+
+ // Setup Domain Name ANQP element to TEST_FQDN2 and TEST_FQDN3
+ Map<ANQPElementType, ANQPElement> anqpElementMap = new HashMap<>();
+ anqpElementMap.put(ANQPElementType.ANQPDomName,
+ createDomainNameElement(new String[] {TEST_FQDN2, TEST_FQDN3}));
+ // Setup RCOIs advertised by the AP
+ anqpElementMap.put(ANQPElementType.ANQPRoamingConsortium,
+ createRoamingConsortiumElement(anqpOis));
+
+ assertEquals(PasspointMatch.HomeProvider,
+ mProvider.match(anqpElementMap, mRoamingConsortium));
+ }
+
+ /**
+ * Verify that non-matching Any HomeOI results in a None Provider match
+ *
+ * @throws Exception
+ */
+ @Test
+ public void matchAnyHomeOiNegative() throws Exception {
+ // Setup test provider.
+ PasspointConfiguration config = generateTestPasspointConfiguration(
+ CredentialType.USER, false);
+ Long[] anqpOis = new Long[] {0x12a4L, 0xceadL, 0xf0cdL};
+
+ // Configuration was created with TEST_FQDN as the FQDN
+ HomeSp homeSp = config.getHomeSp();
+ homeSp.setMatchAnyOis(TEST_RC_OIS);
+ homeSp.setRoamingConsortiumOis(null);
+ config.setHomeSp(homeSp);
+ mProvider = createProvider(config);
+
+ // Setup Domain Name ANQP element to TEST_FQDN2 and TEST_FQDN3
+ Map<ANQPElementType, ANQPElement> anqpElementMap = new HashMap<>();
+ anqpElementMap.put(ANQPElementType.ANQPDomName,
+ createDomainNameElement(new String[] {TEST_FQDN2, TEST_FQDN3}));
+ // Setup RCOIs advertised by the AP
+ anqpElementMap.put(ANQPElementType.ANQPRoamingConsortium,
+ createRoamingConsortiumElement(anqpOis));
+
+ assertEquals(PasspointMatch.None,
+ mProvider.match(anqpElementMap, mRoamingConsortium));
+ }
+
+ /**
+ * Verify that matching All HomeOI results in a Home Provider match
+ *
+ * @throws Exception
+ */
+ @Test
+ public void matchAllHomeOi() throws Exception {
+ // Setup test provider.
+ PasspointConfiguration config = generateTestPasspointConfiguration(
+ CredentialType.USER, false);
+ Long[] anqpOis = new Long[] {0x1234L, 0x2345L, 0xabcdL, 0xdeadL, 0xf0cdL};
+
+ // Configuration was created with TEST_FQDN as the FQDN
+ HomeSp homeSp = config.getHomeSp();
+ homeSp.setMatchAllOis(TEST_RC_OIS);
+ homeSp.setRoamingConsortiumOis(null);
+ config.setHomeSp(homeSp);
+ mProvider = createProvider(config);
+
+ // Setup Domain Name ANQP element to TEST_FQDN2 and TEST_FQDN3
+ Map<ANQPElementType, ANQPElement> anqpElementMap = new HashMap<>();
+ anqpElementMap.put(ANQPElementType.ANQPDomName,
+ createDomainNameElement(new String[] {TEST_FQDN2, TEST_FQDN3}));
+ // Setup RCOIs advertised by the AP
+ anqpElementMap.put(ANQPElementType.ANQPRoamingConsortium,
+ createRoamingConsortiumElement(anqpOis));
+
+ assertEquals(PasspointMatch.HomeProvider,
+ mProvider.match(anqpElementMap, mRoamingConsortium));
+ }
+
+ /**
+ * Verify that non-matching All HomeOI results in a None Provider match
+ *
+ * @throws Exception
+ */
+ @Test
+ public void matchAllHomeOiNegative() throws Exception {
+ // Setup test provider.
+ PasspointConfiguration config = generateTestPasspointConfiguration(
+ CredentialType.USER, false);
+ // 0x1234 matches, but 0x2345 does not
+ Long[] anqpOis = new Long[] {0x1234L, 0x5678L, 0xdeadL, 0xf0cdL};
+
+ // Configuration was created with TEST_FQDN as the FQDN
+ HomeSp homeSp = config.getHomeSp();
+ homeSp.setMatchAllOis(TEST_RC_OIS);
+ homeSp.setRoamingConsortiumOis(null);
+ config.setHomeSp(homeSp);
+ mProvider = createProvider(config);
+
+ // Setup Domain Name ANQP element to TEST_FQDN2 and TEST_FQDN3
+ Map<ANQPElementType, ANQPElement> anqpElementMap = new HashMap<>();
+ anqpElementMap.put(ANQPElementType.ANQPDomName,
+ createDomainNameElement(new String[] {TEST_FQDN2, TEST_FQDN3}));
+ // Setup RCOIs advertised by the AP
+ anqpElementMap.put(ANQPElementType.ANQPRoamingConsortium,
+ createRoamingConsortiumElement(anqpOis));
+
+ assertEquals(PasspointMatch.None,
+ mProvider.match(anqpElementMap, mRoamingConsortium));
+ }
}