Commit Graph

1143 Commits

Author SHA1 Message Date
Benedict Wong
ee4eb2f35b Remove mContext from IpSecBaseTest
This commit removes the mContext from IpSecBaseTest, and replaces it
with InstrumentationRegistry.getContext().

Bug: 72950854
Test: Ran on devices, passing.
Change-Id: If6fa359825aa9d1f7d4c8d49aba7a34925c073ed
2019-05-22 11:08:26 -07:00
Benedict Wong
60b0a6432b Add reflected-packet based data tests
This commit adds tests that reflect outgoing packets, flipping the outer
src/dst headers to avoid the need to tear down and rebuild the outer
TUN.

This allows us to at least test that our implementation can interoperate
with itself.

Bug: 72950854
Test: this, passing
Change-Id: Ia969f78f4c1a0c0a017f5aad425a68852ff4433a
2019-05-22 11:08:26 -07:00
Benedict Wong
281d757df6 Cleanup IPsec CTS tests
This commit addresses comments from aosp/963067 and aosp/959617.

No behavioral/functional changes were made, only renames and minor style
nits addressed.

Bug: 72950854
Test: Ran on devices, working
Change-Id: I1702b91e245412f0142e9e47b7fb373b9b4e8126
2019-05-22 11:08:26 -07:00
Benedict Wong
5c79356068 Fix IPsec CTS tests for interface address checking
Fixes two potentially device/kernel specific, or flaky bugs:
1. Java interface checking by name seems to cache the lookup, resulting
in interface address checks occasionally failing (on delete).
2. Link-local addresses appear to be added on all links for some set of
kernels and devices.

This patch addresses both by only checking that the requested address
was added via a address-based NetworkInterface lookup.

Bug: 72950854
Test: Ran on sargo-eng on qt-dev/HEAD
Test: Manually verified that the addresses are indeed added/removed
Change-Id: I3babc72dfe72337c4d68facb1695aec15e504c90
Merged-In: I3babc72dfe72337c4d68facb1695aec15e504c90
(cherry picked from commit 4af108aacf)
2019-05-22 11:08:26 -07:00
Benedict Wong
a8d59c0183 Convert IPsec tests to JUnit4
This patch fixes an incompatibility where some tests in the same
hierarchy were using Junit3, and other Junit4

No functional test changes made

Bug: 72950854
Test: Ran on devices, working
Change-Id: I79d231e202ba25ad5f57b44b387bebd7f012aa95
Merged-In: I79d231e202ba25ad5f57b44b387bebd7f012aa95
(cherry picked from commit 0d08e91fe7)
2019-05-22 11:08:26 -07:00
paulhu
435166fa86 Enable instant app mode for CtsNetTestCases
1. Indicating CtsNetTestCases support instant app mode but
   ignore some tests that cannot run in instant app mode.
2. Move some tests which need to test on API 23 into
   CtsNetApi23TestCases module due to instant app package
   must target at least API 26.

Bug: 123366918
Test: atest CtsNetTestCases --instant
Test: atest CtsNetApi23TestCases
Test: atest FrameworksNetTests

Change-Id: I4e828cbc48143e36c1be38b91c3c698122d4be5a
Merged-In: I1d78349d14763c133e1eab020d26865f46ff19a3
Merged-In: I931369875c86a396a898682009337cef1b918ba4
Merged-In: Ia8a45d6d751be94f9f707f879ea6ce4e6a45fae1
2019-05-22 01:11:10 +08:00
junyulai
80ec50b8ae add cts for unprivileged keepalive slots
Currently, unprivileged Nat-T keepalives are limited to 1 slot
per uid. Add CTS to verify that the keepalive slots are limited
as customized for unprivileged requests.

Bug: 129371366
Test: atest android.net.cts
      .ConnectivityManagerTest#testSocketKeepaliveUnprivileged
      --generate-new-metrics 10

Change-Id: I60b9e9ae9cf2b63490493ced9738cd2f402c3f9b
2019-05-13 18:10:36 +08:00
junyulai
b41bc72ea3 [KA14] add cts for keepalive limit test.
Per SDK requirement, OEM is required to support minimum number of
concurrent keepalives. Implement CTS to verify this.

Bug: 129371366
Test: atest android.net.cts
      .ConnectivityManagerTest#testSocketKeepaliveLimit
      --generate-new-metrics 10

Change-Id: I8be89116bed5c4dedb2ca42b6d633aa9e8c6a49a
2019-05-13 18:10:23 +08:00
Benedict Wong
81e51bce50 Merge "Enforce IPsec Tunnel mode for Android Q" 2019-05-10 17:41:04 +00:00
Benedict Wong
084c8b47b6 Enforce IPsec Tunnel mode for Android Q
This commit adds a second condition to whether the device is expected to
have the tunnel mode feature. If a device's first API/launch version is
Q or above, require IPsec tunnels

Bug: 72950854
Test: Ran on device with first API level < Q and == Q.
Change-Id: I7b849ad24a04b6b7899a80f1856236b5ceb5a839
2019-05-10 01:22:13 -07:00
Benedict Wong
54c0726220 Merge changes Ic4181fc8,Icffeed2e,I9fdba4a9
* changes:
  Add IPsec Tunnel mode data tests
  Add utilities to generate packets
  Add TunUtils as utility to reflect packets
2019-05-09 20:51:01 +00:00
Benedict Wong
64e64ff454 Add IPsec Tunnel mode data tests
This change adds single-direction tests for the IPsec Tunnel Mode API.
In the outbound direction, TUNs are used to capture outgoing packets,
and values are inspected. In the inbound direction, packets are built
manually, using the PacketUtils framework. Additional testing for
end-to-end integration tests will follow in aosp/941021 using packet
reflection via the TUN.

Bug: 72950854
Test: This; passing
Change-Id: Ic4181fc857fa880db5553314efa914f870dbe87c
2019-05-09 11:25:15 -07:00
Benedict Wong
75fb3d002e Add utilities to generate packets
This change adds utility methods to generate packets incrementally. It
supports UDP, ESP, IPv4, IPv6 packet generation.

For ESP, it exclusively does AES-CBC, HMAC-SHA256.

Bug: 72950854
Test: This
Change-Id: Icffeed2ebb2005d79faf04f48fd5126d1d6fb175
2019-05-09 11:25:06 -07:00
Benedict Wong
4243c834ce Merge "Check for IPSEC_TUNNELS feature before running CTS tests" 2019-05-08 20:04:06 +00:00
Benedict Wong
65845a7e50 Add TunUtils as utility to reflect packets
This patch adds a TunUtils class, allowing for packet capture over a TUN
interface, inspection of some basic header fields, and reflection of
packets with flipped src/dst headers.

Bug: 72950854
Test: Ran, passing
Change-Id: I9fdba4a905886c7a4820d86ef52c0cc1843215b2
2019-05-07 19:24:17 -07:00
Benedict Wong
437eb03a33 Check for IPSEC_TUNNELS feature before running CTS tests
If tunnel feature does is not present, skip tests.

Bug: 117183273
Test: This
Change-Id: I62fcc2cbca8bf3d2b70da5646303a7059a0df663
2019-05-07 19:24:14 -07:00
Sasha Smundak
b3af5c95b2 Convert hostsidetests/net/**/Android.mk file to Android.bp
See build/soong/README.md for more information.

Bug: 122332514
Test: atest CtsHostsideNetworkTests
(same failures as in baseline)
Change-Id: I5b6a22263331b19570b42f156d7ad5d59f8208b4
2019-04-29 13:18:42 -07:00
Luke Huang
4df605b6a4 Convert Android.mk to Android.bp for net cts
Bug: 130623306
Test: atest CtsNativeNetTestCases CtsNativeNetDnsTestCases
      atest CtsNetTestCases

Change-Id: Ifc69f6f83161a44b663e6afdf034963ad241a6b5
2019-04-23 09:27:27 +00:00
Chalard Jean
83e71f6401 Add a test for a bugfix in UrlQuerySanitizer
...so this does not happen again.
This is a test for the fix in Ic91660d974dce21f2affdcacaeffe9accf8451ac

Bug: 1866121
Test: This
Change-Id: Ib7ee866f65baf99b46a31e2115355a42a829421e
2019-04-22 21:58:46 +09:00
Varun Anand
1806a7da53 Merge "CTS tests related to VPN meteredness." 2019-04-15 13:45:57 +00:00
Luke Huang
f1dc4d4380 Minor changes for DnsResolverTest
Done for code-style nits from aosp/940128.

Bug: 129395490
Test: atest DnsResolverTest
Change-Id: Ia4db272cc1a4687b3749116375bac0efb37420d8
2019-04-12 10:34:14 +08:00
Luke Huang
ea5e4a5409 Merge "DnsResolver cts changes to match API council requests" 2019-04-12 00:45:18 +00:00
Lorenzo Colitti
75c73cda26 Merge "Add instant and ABI XML tags for hostside networking tests." 2019-04-11 23:52:10 +00:00
Varun Anand
d1008aa730 CTS tests related to VPN meteredness.
Tests cover scenarios related to whether VPN has explicitly declared its
underlying networks plus whether it is an always metered VPN.

For each of these scenarios, we ensure VPN meteredness based on its
capabilities and ConnectivityManager#isActiveNetworkMetered matches.

Bug: 123727651
Test: atest HostsideVpnTests
Change-Id: I3030e5468a55bbc32be2a753f098dcf7f0256af8
2019-04-11 14:32:21 -07:00
Lorenzo Colitti
ad17ee9e92 Add instant and ABI XML tags for hostside networking tests.
These are not multi-ABI because the behaviour does not depend on
the ABI of the app. Some of the APIs are ultimately backed by JNI
code in the system server, but that only depends on the system
server's ABI, not the app's.

Enable instant mode because these applications are subject to the
same network restrictions as other apps.

Fix: 123364589
Test: atest CtsHostsideNetworkTests
Test: cts-tradefed run commandAndExit cts --enable-parameterized-modules --module-parameter instant_app -m CtsHostsideNetworkTests
Change-Id: Ib3c4cd365ffe95889d51a236f035ea84516f0abd
2019-04-11 20:43:59 +09:00
Luke Huang
4b1fab0dd0 DnsResolver cts changes to match API council requests
Bug: 129261432
Test: atest DnsResolverTest
Change-Id: I803f10218a01614ba7fb26597971853e602273c6
2019-04-10 15:39:21 +08:00
Adam Vartanian
5227dbe606 Add test for SslError.getCertificate()
Bug: 129200144
Test: cts -m CtsNetTestCases -t android.net.http.cts
Change-Id: I1b23746865a4bffc90847b30384defd2c7d49879
2019-04-09 15:46:20 +01:00
Treehugger Robot
3604dbe2de Merge "Add FrameworksNetCommonTests to CTS" 2019-04-04 12:29:44 +00:00
Mark Chien
e8fb173b7d Merge "[KA09] add cts test for tcp keepalive offload" 2019-04-03 09:36:52 +00:00
Remi NGUYEN VAN
16fc55e30d Add FrameworksNetCommonTests to CTS
The common tests include tests that must be both in CTS and unit tests.

Bug: 129199908
Test: atest CtsNetTestCases, IpPrefixCommonTest is run and passes.
Change-Id: Id16f40247cca9a6c5bba573006b84547727f1bab
2019-04-03 18:06:33 +09:00
markchien
5dc1681823 [KA09] add cts test for tcp keepalive offload
Add a test case to make sure tcp keepalive offload starts
correctly.

Bug: 114151147
Test: atest ConnectivityManagerTest#testCreateTcpKeepalive
Change-Id: Iaf1c2fab755f3df8e866b4988f64c25906e1737a
2019-04-03 13:50:39 +08:00
Junyu Lai
553872fc04 Merge "Fix tests in TrafficStatsTest that are affected by adb over network" 2019-04-02 02:00:25 +00:00
Lorenzo Colitti
718025ed2c Merge "Add test coverage for ICMP echo constants." 2019-04-01 15:08:44 +00:00
junyulai
c1419d913d Fix tests in TrafficStatsTest that are affected by adb over network
If the adb TCP port is opened, this test may be run by adb over
network. Huge amount of data traffic might go through the
network and accounted into total packets stats. The upper bound
check would be meaningless.

Bug: 126320702
Test: atest android.net.cts.TrafficStatsTest 10 trials for both cases

Change-Id: Iaee455826dc01741c6a3a9f5f8096361c69a1e7c
2019-04-01 11:12:16 +08:00
Lorenzo Colitti
950e10572b Add test coverage for ICMP echo constants.
Bug: 129251251
Test: atest android.net.ipv6.cts.PingTest com.android.cts.net.HostsideVpnTests
Change-Id: Icca18e0870588ca250225ce79cf30dbd8c361e84
2019-03-30 02:11:46 +09:00
Luke Huang
8fd0506401 Add more test for async DNS api
Bug: 129395490
Test: atest DnsResolverTest
Change-Id: I4d2cdc2be577846c08dfe994da60965f983acb97
2019-03-29 17:09:57 +08:00
Luke Huang
92f1edd2f0 Improve cancellation test for async DNS API
After having a lock between callback and cancellationsignal,
errno with EBADF should not happen.

Bug: 129317069
Test: atest DnsResolverTest
Change-Id: I08e800b078d40345eb3f46da1323db251c8dcd47
2019-03-28 21:06:30 +08:00
Lorenzo Colitti
3852fd92f5 Fix expected reverse lookup of Google DNS IP addresses
DnsTest.testDnsWorks expects that reverse lookup for the Google
public DNS servers will return something with google.com in the
name. This no longer works because the reverse DNS entries have
changed to dns.google.

Bug: 129452237
Test: atest android.net.cts.DnsTest.testDnsWorks
Change-Id: Iee8bfe418bf6003e5c78df77d75f6f9745249267
2019-03-28 17:41:13 +09:00
Luke Huang
acadb939b5 Improve test and fix doulbe-close fd problem for async DNS API cts
1. Change test cases for enlarging buffer size of FrameworkListener.
2. Remove test procedure which caused doulbe-close fd.

Bug: 129317069
Bug: 126307309
Test: atest CtsNativeNetDnsTestCases MultinetworkApiTest
Change-Id: I8d871cebca6fa7e298a874ba430ec0aaa05c0eed
2019-03-26 20:33:43 +08:00
Treehugger Robot
d01197426b Merge "Enable instant and ABI XML tags for native networking tests." 2019-03-25 06:31:59 +00:00
Lorenzo Colitti
f011d5f95b Enable instant and ABI XML tags for native networking tests.
These tests include native code so mark them as multi_abi. They
also pass in instant mode so mark them instant_app.

Fix: 123367032
Fix: 123367595
Test: atest CtsNativeNetDnsTestCases CtsNativeNetTestCases
Test: cts-tradefed run commandAndExit cts --enable-parameterized-modules --module-parameter instant_app -m CtsNativeNetDnsTestCases
Test: cts-tradefed run commandAndExit cts --enable-parameterized-modules --module-parameter instant_app -m CtsNativeNetTestCases
Change-Id: Id66705ecb012a07aa34318f41afb1840dd25b9e3
2019-03-25 13:41:38 +09:00
Junyu Lai
c5ceda2354 Merge changes Ic19b3b64,I26ca370f
* changes:
  Add cts test cases for NetworkCallback.onBlockedStatusChanged
  Export API of listening for network change events in app2
2019-03-25 02:00:36 +00:00
junyulai
27e1316c33 Add cts test cases for NetworkCallback.onBlockedStatusChanged
Bug: 118862340
Test: atest HostsideNetworkCallbackTests

Change-Id: Ic19b3b648a94adf4449393beb9b30ad7a7dc2283
2019-03-22 19:17:01 +08:00
Luke Huang
bb891d5a24 Merge "Add cancel test cases for async DNS API" 2019-03-22 03:26:21 +00:00
junyulai
d05db41eb7 Export API of listening for network change events in app2
Currently, due to foreground app will never get blocked by
NetworkPolicyManagerService, so onBlockedStatusChanged cannot be
tested under cts net app.

Thus, listen for network change events in app2 allows subsequent
tests on NetworkCallbacks.

Bug: 118862340
Test: m -j cts
Change-Id: I26ca370fc6ae4dd3f32ce6cf448bae83f3fbfbcc
2019-03-22 10:19:38 +08:00
Paul Hu
d2a4a1cd8d Merge "Fix API Review issues." 2019-03-21 17:19:26 +00:00
Luke Huang
361584140b Add cancel test cases for async DNS API
Bug: 124882626
Test: built, flashed, booted
      atest DnsResolverTest

Change-Id: I9b496821e422f71009319eeefc6f3c6c1e249111
2019-03-17 15:37:15 +00:00
Luke Huang
24c8d2ab38 Alter CTS tests for change of async DNS API
Bug: 124882626
Test: built, flashed, booted
      atest DnsResolverTest

Change-Id: If823a27773cc778fba49db02045b77222c4cd1af
2019-03-17 15:37:05 +00:00
Luke Huang
26cc1b4a04 Improve test for the changing of DnsResolver
1. Done for some code-style nits.
2. Update tests because AnswerCallback of DnsResolver is changed.

Bug: 124882626
Test: built, flashed, booted
      atest DnsResolverTest

Change-Id: Ie862c7ea5077f56fd9a4d96baf3f466b65db93d8
2019-03-17 14:19:32 +00:00
paulhu
3953e40365 Fix API Review issues.
Modify the method name in LinkProperties.

Bug: 126699682
Test: make cts passed.
Change-Id: I3729e8915a8eff36e8de9035b5bf1571f8609e42
2019-03-14 10:30:06 +08:00