Commit Graph

3778 Commits

Author SHA1 Message Date
Aaron Huang
ced49fd763 Change to use Dependencies in IpSecService Tests
The interface IpSecServiceConfiguration is refactored to static
class Dependencies. Refine the tests to use Dependencies.

Bug: 204153604
Test: FrameworksNetTests
Change-Id: Ie2b79b1d948a19f64600ed9ea3b60b192dd92dfd
2021-11-27 00:27:33 +08:00
paulhu
b2d5b054d3 Save uid netd network permissions
PermissionMonitor only saves netd network permissions by appId.
Then apply same permision to uids which are same appId. But
UIDS_ALLOWED_ON_RESTRICTED_NETWORKS can allow single uid has
restricted network permission. Thus, save the netd network
permissions by uid that can apply different permission to each
uid.

Bug: 192431153
Test: atest FrameworksNetTests
Change-Id: I942cbe0fa30758a7497c47a1b684ed70c4e3b09e
2021-11-26 14:47:01 +08:00
Treehugger Robot
8edbc35d56 Merge "Stop skipping VPN tests when running ADB over TCP." am: b031a2265e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1669610

Change-Id: I7a829bc84282c940abae5e0930a9c2cbe4cc7099
2021-11-26 03:47:07 +00:00
Treehugger Robot
b031a2265e Merge "Stop skipping VPN tests when running ADB over TCP." 2021-11-26 03:30:45 +00:00
Davor Majdandzic
2cdbbc1a32 Competing network interfaces
NetworkRequest is expecting transport type Ethernet or test. This
causes the test 'testApiCallbacks' to fail for devices that have a
non-test Ethernet network since that network is being chosen instead of
the expected test Ethernet network.

Remove network capability TRANSPORT_ETHERNET from CaptivePortalApiTest.

Bug: 204329523
Test: atest android.net.cts.CaptivePortalApiTest#testApiCallbacks

Signed-off-by: Davor Majdandzic <davor.majdandzic@aptiv.com>
Change-Id: Ie7b4d00c08f1497044e63462f1d899d1f3dea2df
2021-11-25 17:37:45 +01:00
Ken Chen
335c0d4249 [NETD-BPF#4] Move bpf_shared.h from netd to module
The header file is referenced by the part going to be mainlined in Netd.
Note that some platform visibility is required with this commit, since
users of bpf_shared.h is currently located in platform. The visibility
can be removed when all users are moved out of platform.

Bug: 202086915
Test: m; flash; boot
Test: cd system/netd && atest
Test: cd packages/modules/Connectivity && atest
Test: atest FrameworksNetTests
Change-Id: I5c16511b6a2d4eb80dfd93157cbc98d5030bd5ac
2021-11-23 11:53:46 +08:00
Treehugger Robot
0061457a54 Merge "Fix a possible flake in disconnectFromWiFi" am: 1c4a66ddc4
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1892098

Change-Id: I6df297447ade42e38963855809c499c55b6ea85c
2021-11-22 07:53:43 +00:00
Treehugger Robot
1c4a66ddc4 Merge "Fix a possible flake in disconnectFromWiFi" 2021-11-22 07:34:57 +00:00
Remi NGUYEN VAN
b7fd5bd3e1 Merge "Update NSD tests without AsyncChannel" am: 469d941752
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1823893

Change-Id: I897bdce6cdaf4ea390d8ce6be03b87bacd6da82e
2021-11-22 06:19:18 +00:00
Remi NGUYEN VAN
469d941752 Merge "Update NSD tests without AsyncChannel" 2021-11-22 05:58:15 +00:00
Aaron Huang
4fc403c3b0 Merge "Use real ProxyTracker in ConnectivityServiceTest" am: c7037475fa
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1885529

Change-Id: Id685a51b37d59a822aaa9307f9d4b55053211612
2021-11-22 05:41:34 +00:00
Aaron Huang
c7037475fa Merge "Use real ProxyTracker in ConnectivityServiceTest" 2021-11-22 05:25:28 +00:00
Remi NGUYEN VAN
e03f77170a Remove unused service and test dependencies am: f96ecf2708
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1895317

Change-Id: I677a6b4c0b68648b4fab0e6f67edc88aa8be77b2
2021-11-19 15:59:07 +00:00
Remi NGUYEN VAN
f96ecf2708 Remove unused service and test dependencies
Nothing uses StateMachine in service-connectivity, and
FrameworksNetTestsLib pulled a lot of unused dependencies with
services.core and services.net.

Remove unused dependencies. This helps measure code coverage more
accurately.

Bug: 207020032
Test: atest ConnectivityCoverageTests
Change-Id: I39857865594a3263c4b1deeda23312c8e4f86a77
2021-11-19 21:14:39 +09:00
Xin Li
c96c26077b Merge "Merge sc-qpr1-dev-plus-aosp-without-vendor@7810918" into stage-aosp-master 2021-11-18 21:29:06 +00:00
Treehugger Robot
2c75c0444d Merge "Disable CtsNetTestCases if needed" 2021-11-18 11:43:07 +00:00
Remi NGUYEN VAN
cd4b4ee973 Update NSD tests without AsyncChannel
Update the tests to use the newer NsdManager based on Binder interfaces
instead of AsyncChannel.

Bug: 190249673
Test: atest NsdManagerTest NsdServiceTest
Change-Id: I0991b598331e335a0bc211f010da7f034fb2441b
2021-11-18 18:22:45 +09:00
Taras Antoshchuk
bc3f86dfa3 Disable CtsNetTestCases if needed
Apply NetworkStackNextEnableDefaults to CtsNetTestCases to disable it
in branches where NetworkStackNext and related targets should not be
built.

Test: presubmit
Change-Id: I850b4294aa4c3c01f8871760185ca7fedc0f8584
2021-11-15 17:40:42 +01:00
Chalard Jean
dece0d805f S- not to crash on NetworkInfo(null) or setDetailedState(null)
When NetworkInfo(null) or setDetailedState(null, any, any) are
called, S used to not crash but plant a null bomb for later
which may explode in some calls (notably, parceling) : see the
bug referenced below for details.

To help catching these errors earlier a patch was made to crash
as soon as one of these methods is called with a null argument,
but this will also crash incorrect use on existing code that
may never actually step on the mine, crashing code that used not
to crash. For safety, implement the new behavior only on T.

Bug: 145972387
Test: NetworkInfoTest
Change-Id: Ib710497d83b2d26439c2bd4d2f572310db97d6fd
2021-11-15 21:18:25 +09:00
Aaron Huang
e3879abb07 Use real ProxyTracker in ConnectivityServiceTest
Currently CS test uses a mock ProxyTracker object to verify that
the sendProxyBroadcast() is called. Also, if the network is a
default network then sendProxyBroadcast() will be indirectly
called in setDefaultProxy(). This only verifies that the method
is called but it doesn't verify that the broadcast is sent.

Instead of testing setDefaultProxy() is called, it is better to
verify that the broadcast is actually sent. Therefore, use a
real ProxyTracker in the test to verify the broadcast is sent.

Test: FrameworksNetTests:ConnectivityServiceTest
Change-Id: Id5c9e07e8326f24bd2665b4bb08f96d6d57d999c
2021-11-15 20:01:12 +08:00
Chalard Jean
05c291e5a3 Fix a possible flake in disconnectFromWiFi
1. There is a theoretical issue where the callback is not yet
   registered when wifi is disabled, but there is no evidence
   of it actually happening
2. 2 minutes timeout makes no sense for these tests that have a
   total 1 minute timeout anyway

Bug: 196387278
Test: CtsNetTestCases
Change-Id: I120af9b312ca34431d0e62dd85233fcdaa1b09b9
2021-11-15 11:58:07 +00:00
Maciej Żenczykowski
ff81692077 Merge changes from topics "rename-libbpfmapjni", "rename-libtetherutiljni"
* changes:
  Rename libbpfmapjni and include bpf common util library
  Rename tethering jni and get the jni by its package name
2021-11-11 13:19:48 +00:00
Treehugger Robot
7eb9f88a6e Merge "replace R + 1 with S" 2021-11-11 07:26:39 +00:00
Remi NGUYEN VAN
4638c093ed Merge "Fix NetworkCapabilitiesTest on S" 2021-11-11 04:42:36 +00:00
Remi NGUYEN VAN
daa03defee Fix NetworkCapabilitiesTest on S
Mark NetworkCapabilitiesTest as ConnectivityModuleTest so that it is
only run in MTS with the Connectivity module installed, and fix
parceling tests to use the right number of fields in that case.

NetworkCapabilitiesTest is only useful to test the Connectivity module,
and not other modules like NetworkStack, as it is a unit test of a class
in the Connectivity module.

Bug: 205901761
Test: atest NetworkCapabilitiesTest
Change-Id: I10ba0f866bc7a39b2c90bdde12a79feefea2d5ee
2021-11-11 12:30:07 +09:00
Maciej Żenczykowski
8834250ef8 replace R + 1 with S
Test: TreeHugger
Bug: 170424293
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I43f53268b6c1605d928ce3431cc95b8a66b6c052
2021-11-10 18:20:01 -08:00
Xin Li
e41bbea995 Merge sc-qpr1-dev-plus-aosp-without-vendor@7810918
Bug: 205056467
Merged-In: I745ef4d42ecaf06bb81d9dbe0b7162267fea65a8
Change-Id: I7b2a1fc519124cfc10806dde5fd543504a51e072
2021-11-10 08:06:18 +00:00
markchien
f967b11087 Rename tethering jni and get the jni by its package name
tetherutiljni is renamed to com_android_networkstack_tethering_jni_util

Bug: 205088391
Test: atest TetheringTests
      atest CtsTetheringTest
      atest TetheringPrivilegedTests
Change-Id: Ifd1f4473625e33d3ebe190c9f8a2b5d54aa1ff49
2021-11-10 14:07:24 +08:00
Remi NGUYEN VAN
959d2cb6bd Don't rematch all requests when adding new ones
With the network selection rewrite in S, rematching a single request can
now easily be done; this can be used as an optimization in
handleRegisterNetworkRequests to avoid rematching all requests when
registering a new one.

This can be disabled by a flag that is unset by default,
REMATCH_ALL_REQUESTS_ON_REGISTER.

Test: atest ConnectivityServiceTest
Change-Id: If76f79b41ac88863974f7025624667134bea2570
2021-11-08 19:17:57 +09:00
Treehugger Robot
27979bd116 Merge "Include the failing stats in stats failure assertions." 2021-11-08 06:20:39 +00:00
Lorenzo Colitti
5156e787f3 Include the failing stats in stats failure assertions.
Currently debugging IpSecManagerTest counter test failures is
difficult because the assertion message does not say how many
bytes/packets were expected.

Add this information to the assertion message.

Bug: 204860049
Test: test-only change
Change-Id: I4e12be9a58a688fcee3362dceb31d9f21e981d6c
2021-11-08 13:25:45 +09:00
Les Lee
b5ee639fe0 Merge "Add test case to test normalize" 2021-11-06 00:54:14 +00:00
Les Lee
5299a2b307 Add test case to test normalize
Bug: 194939211
Test: atest -c NetworkTemplateTest
Change-Id: I2f5790b9217357ddcf3f466cec1b2b1afbb47210
2021-11-05 16:59:10 +08:00
Remi NGUYEN VAN
defc74fb2f Merge "Use ConnectivityCheckTargetPreparer in CTS" 2021-11-05 04:27:47 +00:00
Remi NGUYEN VAN
1d1b1fe999 Merge "Move fromStableParcelable to KeepaliveController" 2021-11-04 06:19:17 +00:00
Kimberly Kreider
200e42063c Merge "Replace "mts" with "mts-tethering"." 2021-11-01 23:43:53 +00:00
Treehugger Robot
a200fe8c1c Merge "Shorten a timeout" 2021-11-01 12:19:28 +00:00
Chalard Jean
31ac212428 Merge "Replace mDeps with a custom object" 2021-11-01 10:31:53 +00:00
Chalard Jean
f63e4597a3 Shorten a timeout
This timeout is not very useful but will be incurred every
time

Test: ConnectivityServiceTest
Change-Id: Ia7c76c7c7a148f14844d098be267e16c215776f5
2021-11-01 19:30:10 +09:00
Lucas Lin
5bf4cd9a73 Merge "Add tests for testing if [start|finish]Op is called or not" 2021-11-01 08:33:36 +00:00
Chalard Jean
21f4f70d46 Replace mDeps with a custom object
Mockito's mocks are not thread-safe. The dependencies object
is used both on the test thread (to set it up) and in the CS
handler thread. This can't work with a mock.

Bug: 195626111
Test: ConnectivityServiceTest
Change-Id: Ia989dd71c3133513a90bc1d1957419fb1b74c300
2021-11-01 16:30:56 +09:00
Remi NGUYEN VAN
5d99aa78f7 Move fromStableParcelable to KeepaliveController
TcpKeepaliveController is the only user of
KeepalivePacketDataUtil.fromStableParcelable. Because of
fromStableParcelable, networkstack-client needs to depend on
net-utils-framework-commonm, which pulls a lot of unnecessary classes.
This is particularly problematic considering that networkstack-client
may need to be redistributed as a prebuilt.

Move the method to TcpKeepaliveController, simplifying dependencies.
This also shows that fromStableParcelable could be removed altogether
(or moved to tests) if TcpKeepaliveController built a
TcpKeepalivePacketData class directly.

Test: atest ConnectivityCoverageTests
Change-Id: I554318f6bcd07c73d153598a0231e9fcaf912e90
2021-11-01 13:23:27 +09:00
Remi NGUYEN VAN
9c358cd831 Use ConnectivityCheckTargetPreparer in CTS
The preparer does basic checks for device configuration before any test
is run, so that wrong device configuration can be identified at the
module level, rather than fail individual test cases.

If test devices are not properly configured with a wifi configuration
and data-enabled SIM cards, the run will fail before starting the test
module.

As the preparer uses much of CtsNetUtils code for connecting to wifi,
refactor that code out of CtsNetUtils.

Test: atest CtsNetCasesLatestSdk
Change-Id: I1214b6d6916e836bcd68d15c50486092c7fb9a6e
2021-10-28 15:15:53 +09:00
Remi NGUYEN VAN
9a689f81f4 Add RequiresDevice to relevant tests
Replace SkipPresubmit with RequiresDevice on relevant tests, as
RequiresDevices is more standard and more specific.

This allows creating test configurations using virtual devices which are
not necessarily in presubmit.

Bug: 201014262
Test: TH needs to verify test mapping run with new annotation
Change-Id: I6758d2a41a9a987a5244e47e4795bc49889c4d61
2021-10-28 09:49:42 +09:00
Aaron Huang
2685c929f4 Add a test for metered/non-metered mobile network
NetworkTemplate.buildTemplateMobileWithRatType() supports
to build a template with metered filter, so a mobile network
is metered or non-metered should be tested.

This commit also rename buildMobile3gState to buildMobileState
because originally this method uses NetworkInfo to simulate the
network type. The NetworkInfo related codes were removed.
Currently, setMobileRatTypeAndWaitForIdle is used to simulate
the network type in test.

Ignore-AOSP-First: The parent of this change contains a CL will
conflict with internal tree so ignore AOSP first.
Bug: 183776809
Test: this
Change-Id: I8e54e2acb06db81fb0eaf330c4fd7cb391b01ff3
2021-10-26 12:16:18 +00:00
Aaron Huang
eaca5b1982 Add a test for NetworkIdentity.getMetered()
NetworkIdentity has adapted NET_CAPABILITY_TEMPORARILY_NOT_METERED
network capability so add a test case for it.

Ignore-AOSP-First: The parent of this change contains a CL will
conflict with internal tree so ignore AOSP first.
Bug: 183776809
Test: this
Change-Id: I2ca2a8b4db664b76a5a5ee82fcff451efd87c8ff
2021-10-26 12:16:03 +00:00
Lucas Lin
c5e61cc540 Merge changes Ib2d54e53,Ieb606d2b
* changes:
  Test if underlying networks are the same as what VpnService sets
  Convert VpnTest to JUnit4
2021-10-26 06:07:19 +00:00
lucaslin
cacd5b0d2a Test if underlying networks are the same as what VpnService sets
If VpnService set null as the underlying networks, then the
underlying networks will be set as system defeult network.
If VpnService set an empty array as the underlying networks, then
the underlying networks of VPN will not be set to any networks.
If VpnService set a network which is not null or an empty array,
then the underlying networks of VPN should be the same as this
one.

Bug: 191918368
Test: atest CtsHostsideNetworkTests:HostsideVpnTests
Change-Id: Ib2d54e53960e5f899cb8d4cfaa6705ca676354ca
2021-10-26 10:55:41 +08:00
lucaslin
d2de904def Convert VpnTest to JUnit4
This is to fix the error in errorprone target, the error message
is: [JUnit4ClassUsedInJUnit3] Assume cannot be used inside a
JUnit3 class. Convert your class to JUnit4 style.
The error method is: assumeTrue()

Bug: 191918368
Test: atest CtsHostsideNetworkTests:HostsideVpnTests
Change-Id: Ieb606d2ba31cc19510425114c76fd77417227f2c
2021-10-26 10:55:25 +08:00
lucaslin
d4e7b00b2b Add tests for testing if [start|finish]Op is called or not
Add a test for testing if [start|finish]Op will be called when
[start|stop]VpnProfile is called.
Also add a test to ensure that the startOp will not be called
again when seamless handover is happened.

Bug: 197135981
Test: atest FrameworksNetTests:VpnTest
Change-Id: I778ea4edf7c4a2d20b3b8e1877e7942feac5372a
2021-10-26 03:46:46 +08:00