diff options
author | Hai Shalom <haishalom@google.com> | 2020-03-02 14:14:58 -0800 |
---|---|---|
committer | Hai Shalom <haishalom@google.com> | 2020-03-03 11:14:18 -0800 |
commit | d2f78320591cfc19e27cae75720ccbf15b5cfeb5 (patch) | |
tree | 59c7c34216d273b1beebd1d1db7b58c4678c9534 /tests | |
parent | b25e55d892f91decd1be0bcbf6fce592a3ea636b (diff) |
[Passpoint] Match HomeOIs to Home Provider
Match HomeOIs in HomeSP/HomeOIList as Home Provider.
If a HomeOI is listed in the provider, match against the RCOI
advertised in the roaming consortium elements. Also consider
the Required flag, as per the specification.
Bug: 117981456
Test: atest PasspointProviderTest ANQPMatcherTest
Change-Id: I513f83a6d545b9ae7da5577ee163ce7d186f006e
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/hotspot2/ANQPMatcherTest.java | 64 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java | 125 |
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)); + } } |