Commit graph android_packages_modules_Co.../tests
Message SHA1
Merge "Rename isStrictMode to better names"
Jean Chalard   authored and   Gerrit Code Review   commited 2023-01-06 06:14:26 +00:00
a8e13ec811
Remove mSubscriberIdMatchRule from NetworkTemplate
Currently, mSubscriberIdMatchRule is only used in NetworkTemplate
and it depends on if mMatchSubscriberIds is empty or not. Thus,
remove it since is not really necessary and replace it with
checking matchSubscriberIds if needed.

Bug: 238843364
Test: build, FrameworksNetTests
      CtsNetTestCases
Change-Id: Ic66d2ff2826846778b004bb15a4718a62fa1f470

Aaron Huang   commited 2022-12-28 12:09:09 +08:00
4854d055bb
Merge changes I3dd45b29,Ic177015f
* changes:
  Require IPSEC_TUNNEL_MIGRATION feature flag to migrate transforms
  Support IPsec transform migration

Yan Yan   authored and   Gerrit Code Review   commited 2022-12-22 19:22:46 +00:00
67c7cd81a7
Rename isStrictMode to better names
"isStrictMode" is a poor name to set whether the private DNS
probe succeeded.

Test: ConnectivityServiceTest
Change-Id: I5d0d7ebabc5791b4b6cb7c1cce54b515d2e7e9d9

Chalard Jean   authored and   Jean Chalard   commited 2022-12-22 08:25:16 +00:00
d8ba034066
Require IPSEC_TUNNEL_MIGRATION feature flag to migrate transforms
Bug: 169169973
Test: atest IpSecServiceParameterizedTest (new tests added)
Change-Id: I3dd45b29163cd1e0cdbef08cb8aabdb629cf73bc

Yan Yan   commited 2022-12-21 23:12:48 +00:00
a48dcd9d1f
Support IPsec transform migration
This commit adds methods to support migrating tunnel mode
IpSecTransform to new source/destination addresses.

Bug: 169171001
Test: atest FrameworksNetTests (new tests added)
Change-Id: Ic177015fba5b62d3f73009633118109d3631086f

Yan Yan   commited 2022-12-21 23:12:35 +00:00
e114b38f07
Merge changes from topics "ADD_JVMOVERLOADS", "VPN_NETWORK_PREFERENCE"
* changes:
  Add HostsideVpnTests for testing setVpnDefaultForUids()
  Add CTS for ConnectivityManager#setVpnDefaultForUids()
  Create a new API to make a set of UIDs use only VPN by default

Lucas Lin   authored and   Gerrit Code Review   commited 2022-12-21 01:13:47 +00:00
e0e9b0c701
Merge "wire bpf_base_test into netd_updatable_unit_test"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2022-12-20 18:36:15 +00:00
236013b328
Merge "Ensure MTU is set for new interfaces."
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2022-12-20 14:51:33 +00:00
986fe9604b
Ensure MTU is set for new interfaces.
Setting the MTU for an interface should not be skipped when the
interface names are different. This occurs when a VPN network creates
a new interface with identical MTU.

Bug: 246398088
Test: atest ConnectivityServiceTest
Test: Manual test: Connect to VPN network and switch networks
Test: Confirm MTU of interface is set correctly with `adb shell ip addr`
Change-Id: I811a01feca2fb2130c57c6c924145314180434c5

Hansen Kurli   commited 2022-12-20 09:28:36 +00:00
0425203152
Add HostsideVpnTests for testing setVpnDefaultForUids()
The test will check if the VPN will be the only default network
for the app after ConnectivityManager#setVpnDefaultForUids() is
called.

Bug: 231749077
Test: atest CtsHostsideNetworkTests:HostsideVpnTests
Change-Id: I02758ad7d948342797b6a4b00dfec3acdf44775d

lucaslin   commited 2022-12-20 09:02:15 +00:00
cf52cee443
Add CTS for ConnectivityManager#setVpnDefaultForUids()
This test checks
- If the NullPointerException will be thrown or not when the
  given uid ragnes is null.
- If the SecurityException will be thrown or not when the caller
  doesn't have related permission.

Bug: 231749077
Test: atest CtsNetTestCases
      atest CtsNetTestCasesLatestSdk
Change-Id: Ia1e625bc1f791ee9928ba00d76af9979ba52b2db

lucaslin   commited 2022-12-20 06:57:01 +00:00
220332b9c5
wire bpf_base_test into netd_updatable_unit_test
The 3 pre-existing //system/netd tests are:
  TEST_F(BpfBasicTest, TestCgroupMounted)
  TEST_F(BpfBasicTest, TestTagSocket)
  TEST_F(BpfBasicTest, TestCloseSocketWithoutUntag)
which are directly related to BpfHandler.cpp implementation,
as it implements:
  Status BpfHandler::init(const char* cg2_path)
  BpfHandler::tagSocket()
  BpfHandler::untagSocket()

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1c01ae90904faaea54b427495c7a5deab8b1b900

Maciej Żenczykowski   commited 2022-12-20 00:41:05 +00:00
70d30ec49d
Merge "bpf_existence_test - add U support"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2022-12-19 19:10:12 +00:00
c62bfff71b
Merge "remove TestTrafficControllerSetUp & TestSocketFilterSetUp"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-12-19 18:46:08 +00:00
9aa2315be1
Create a new API to make a set of UIDs use only VPN by default
Create a new API - setVpnNetworkPreference() for the caller to
set VPN as the preference network.

VPN will be disconnected when its underlying network is gone.
To prevent packets going through an underlying network when the
underlying network is back but VPN is not connected yet, set VPN
as the only preferred network for specific apps.

Bug: 231749077
Test: 1. atest FrameworksNetTests
      2. Create a test app to register default network and check if
         the VPN is the only default network for the test app.
Change-Id: Iabcd38e2fec2aefedbf78d20e338f222d83a9e7f

lucaslin   commited 2022-12-19 05:35:04 +00:00
3ba7cc25c0
remove TestTrafficControllerSetUp & TestSocketFilterSetUp
This is (as yet) dead code copied over from //system/netd,
but not yet plumbed into any p/m/C Android.bp file/test.

Update the bpf_shared.h include to netd.h now that that has been
renamed, see:
  https://android-review.git.corp.google.com/c/platform/packages/modules/Connectivity/+/2335387

MTS test bpf_existence_test.cpp already does a better job
of testing for bpf program/map existence, see
  MAINLINE_FOR_T_PLUS
  MAINLINE_FOR_T_4_14_PLUS

Test: N/A, this file is not yet compiled
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2ccfd86e352118f6f76e91ec20e10a9285414490

Maciej Żenczykowski   commited 2022-12-18 20:30:32 +00:00
3b67343ddb
rename bpf_shared.h to netd.h
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2e1569c8d70e98f9a3fdbab41fd2ba7f7b84dd37

Maciej Żenczykowski   commited 2022-12-18 20:02:52 +00:00
513474c1a7
bpf_existence_test - add U support
The logic about testing API levels was wrong: it simply isn't
meaningful to say it doesn't support and needs to be updated for U+.

This test *always* needs to be kept up to date wrt. any changes
we make to mainline provided bpf programs and maps.

That's why the test is in the same git repo and is MTS not CTS.

Additionally we *can* make (and have made) changes to programs/maps
available on older API levels as well, so it's not even set in stone
for older API levels either.

Getting rid of the api level checks simplifies things.

As does moving the 4.9+ check into the test logic itself.
This has the added benefit of not skipping the test on S
simply because kernel is < 4.9 [not that's valid, but...].

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ib0400f4534254b7a35a96d364720a7c800953456

Maciej Żenczykowski   commited 2022-12-18 12:58:36 +00:00
2e4c752084
copy in bpf_base_test.cpp from system/netd
Test: N/A
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1bf320f838c7cc203dd72bc5b48aee92288bbb81

Maciej Żenczykowski   commited 2022-12-15 22:16:09 +00:00
438e4a8526
Merge changes If187d023,I41c557d6
* changes:
  Add MdnsAnnouncer
  Also use other compressed names in DNS compression

Treehugger Robot   authored and   Gerrit Code Review   commited 2022-12-15 04:31:37 +00:00
c12fede943
Rename getBypassable to isBypassable
Bug: 262336021
Bug: 256775913
Test: atest FrameworksNetTests
Change-Id: I5ac8f4f9a2a64189fc66d3c14af6da201a35e3e2

chiachangwang   authored and   Chiachang Wang   commited 2022-12-15 04:22:43 +00:00
2ed983512c
Add MdnsAnnouncer
MdnsAnnouncer is a implementations of MdnsPacketRepeater, which sends a
packet at various intervals.

It will be used to send initial advertisements when a service is
registered or there is a network change.

Bug: 241738458
Test: atest
Change-Id: If187d023dd48d9b575431759cc6b67460bc0d33b

Remi NGUYEN VAN   commited 2022-12-15 10:56:15 +09:00
a066e55bc5
Also use other compressed names in DNS compression
The previous implementation of writeLabels would not include a
compressed name in the label dictionary, so if a packet had
"something.local", "a.service.local" and "b.service.local",
"service.local" would not be compressed because "a.service.local"
already used compression (for .local).

Fix this and add a test.

Bug: 254166302
Test: atest
Change-Id: I41c557d6debd11acb4c0813735ef7af7323f45d7

Remi NGUYEN VAN   commited 2022-12-15 10:49:57 +09:00
e274170ac6
Merge changes I9cd2b861,I4e5f779b
* changes:
  Use compression for mDNS NSEC record data
  Add MdnsProber

Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2022-12-15 01:41:58 +00:00
df91219a9b
Merge "Ensure default network before testing"
Junyu Lai   authored and   Gerrit Code Review   commited 2022-12-14 10:14:53 +00:00
cccbc497e3
Ensure default network before testing
The testBlockedStatusCallback will get the default network,
and use it to verify upcoming callbacks. However, sometimes
the wifi network will be disconnected by previous executed
tests and becoming connected during the test, and fail the
test.

Thus, ensure wifi is the default network if it is supported
before testing.

Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest#testBlockedStatusCallback \
      --rerun-until-failure 200
Fix: 260560020
Change-Id: Icd79005dbcf5966beb2f2caf271a32b3f772f475

Junyu Lai   commited 2022-12-14 14:13:14 +08:00
52405f7f66
Use compression for mDNS NSEC record data
Although RFC3845 2.1.1 specifies that NSEC records should not use
compression for the Next DomainName field, RFC6762 18.14 specifies that
compression should also be used for NSEC RDATA. The legacy mDNS
implementation does use compression for that field.

Bug: 241738458
Test: atest
Change-Id: I9cd2b8618b01bb569a7f1d13dc3bfd09a0433300

Remi NGUYEN VAN   commited 2022-12-14 11:36:56 +09:00
f1fdca69a5
Add MdnsProber
MdnsProber is an implementation of MdnsPacketRepeater that will be used
to send probes for service names before advertising them, to know if
they are already in use.

Bug: 241738458
Test: atest
Change-Id: I4e5f779b891e2c665ba7f752fb5fbd4255070725

Remi NGUYEN VAN   commited 2022-12-14 11:36:55 +09:00
3568fddb36
Merge "Add areLongLivedTcpConnectionsExpensive in VpnTransportInfo"
Chiachang Wang   authored and   Gerrit Code Review   commited 2022-12-14 00:55:38 +00:00
9185577397
Add areLongLivedTcpConnectionsExpensive in VpnTransportInfo
Add VpnTransportInfo.areLongLivedTcpConnectionsExpensive() in API
surface to allow privileged apps to know whether the long-lived
TCP connections should be expensive in the VPN network.

This is expected to be used combined with getBypassable()
because connections should always go through a VPN that is not
bypassable.

Bug: 259000745
Test: atest FrameworksNetTests
Change-Id: Ic9bcdf43f252f22d12a1136902cc8bbf9cc731f5

chiachangwang   commited 2022-12-13 10:15:49 +00:00
a07cef1059
Merge "Add unit tests checking MTU of interfaces are set."
Hansen Kurli   authored and   Gerrit Code Review   commited 2022-12-13 07:01:19 +00:00
edbf34a182
Merge "Acquire a wakelock before sending KEYCODE_SLEEP" into android13-tests-dev am: 51413173f0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2300101

Change-Id: I0cde428b1a6a704039b340ccfe9de5008ecf54fa
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Shubhangi Pawar   authored and   Automerger Merge Worker   commited 2022-12-13 00:52:52 +00:00
c4b72b9583
Merge "Acquire a wakelock before sending KEYCODE_SLEEP" into android13-tests-dev
Shubhangi Pawar   authored and   Gerrit Code Review   commited 2022-12-13 00:16:21 +00:00
51413173f0
Merge changes Icd842479,I2206a846
* changes:
  Add MdnsInterfaceSocket and MdnsSocketProvider
  Put the Network info in MdnsServiceInfo

Paul Hu   authored and   Gerrit Code Review   commited 2022-12-12 08:16:23 +00:00
d78cda2ba8
Add MdnsInterfaceSocket and MdnsSocketProvider
MdnsInterfaceSocket: using for listening the multicast
socket on specific interface.

MdnsSocketProvider: using for creating and managing the
multiple multicast sockets.
- Listen NetworkCallback and TetheringEventCallback to know the
  network connected / disconnected changes. And use the callbacks
  to create / remove the sockets for mdns discovery

Bug: 254166302
Test: atest FrameworksNetTests
Change-Id: Icd8424792e89e71198fa31f9ec92e1ec8172128d

Paul Hu   commited 2022-12-12 08:15:38 +00:00
2f1de80315
Merge "Disconnect network when captive portal returns unwanted."
Hansen Kurli   authored and   Gerrit Code Review   commited 2022-12-12 06:43:01 +00:00
3597deb5e1
Put the Network info in MdnsServiceInfo
In Nsd, every request has Network info to assign the specific
network to do the mdns query. But the response MdnsServiceInfo
only has interface index which is not very useful and need to
transfer to a Network every time when using it because most
APIs for apps to use the network are based on Network object.
Thus, put the Network info into MdnsServiceInfo.

Bug: 254166302
Test: atest FrameworksNetTests
Change-Id: I2206a84636981fc7d9aa9deda0f18f60642bc7d7

Paul Hu   commited 2022-12-09 14:42:44 +08:00
9e53b630c5
Add unit tests checking MTU of interfaces are set.
Unit tests covering the different possible cases of calls to updateMtu.

Bug: 246398088
Test: atest ConnectivityServiceTest
Change-Id: Iced44c00e9dbe944c3a31bbf1da88f8077e4379a

Hansen Kurli   commited 2022-12-08 12:00:35 +00:00
8d267d8998
Merge "Add polling for WifiManager#getConnectionInfo"
Chris Ye   authored and   Gerrit Code Review   commited 2022-12-08 07:10:06 +00:00
07718da004
Merge "Verify that the underlying network info will be cleared/sent or not"
Lucas Lin   authored and   Gerrit Code Review   commited 2022-12-08 05:30:47 +00:00
dc824e95de
Merge "Correct the test design for network lost case"
Lucas Lin   authored and   Gerrit Code Review   commited 2022-12-08 03:25:05 +00:00
678113ade7
Verify that the underlying network info will be cleared/sent or not
Add some checks to verify that the underlying network info will
only be cleared when the underlying network is lost, or will only
be sent when the category is not CATEGORY_EVENT_DEACTIVATED_BY_USER
and CATEGORY_EVENT_ALWAYS_ON_STATE_CHANGED.

Bug: 237050331
Test: atest FrameworksNetTests:VpnTest
Change-Id: Ifc66658cf59481c4a9804e6933be1048f758b698

lucaslin   authored and   Lucas Lin   commited 2022-12-07 09:47:38 +00:00
d1938dffce
Correct the test design for network lost case
For network lost case, the process should be triggered by calling
onLost() instead of triggering onClosedWithException() directly.

Bug: 237050331
Test: atest FrameworksNetTests:VpnTest
Change-Id: I32781d4ac96ee8212d1fd7ba23009293f72b442e

lucaslin   commited 2022-12-07 09:42:22 +00:00
0b915e2012
Acquire a wakelock before sending KEYCODE_SLEEP
To prevent device testing via ADB over ethernet entering standby mode,
acquire a wake lock before sending KEYCODE_SLEEP to device.

We might lose connection when device entering standby mode, end up fail the test.

Test: atest com.android.cts.net.HostsideRestrictBackgroundNetworkTests#testDozeModeNonMetered_whitelisted

Bug: 233154541

Change-Id: I09e0af35d32a8001913d3414c0c41ffbb10ace3d
Merged-In: Icb28d2db6f25bd12ba00f56e5d6e56fa108bdcbd

Leon Li   commited 2022-12-07 08:08:37 +00:00
fe3cd519a3
Merge "Add onServiceNameDiscovered/onServiceNameRemoved"
Paul Hu   authored and   Gerrit Code Review   commited 2022-12-07 02:00:33 +00:00
3b1703007e
Merge "Increased the timeout from 5 to 30 seconds"
Mark Chien   authored and   Gerrit Code Review   commited 2022-12-06 14:53:44 +00:00
7e60552183
Add onServiceNameDiscovered/onServiceNameRemoved
Add onServiceNameDiscovered method which is used to listen the
discovery callbacks. It would be called once the service is found
even the response is incomplete. This is different from
onServiceFound which needs to receive a complete response.

onServiceNameRemoved is used for service removal if received
response is incomplete.

Bug: 254166302
Test: atest FramworksNetTests
Change-Id: I03313b045d74bb65f7fe6ac93673f02ce3b2c664

Paul Hu   commited 2022-12-06 10:29:26 +00:00
0ee75422c9
Add polling for WifiManager#getConnectionInfo
In Cts test after disabling Wifi, the WifiManager#getConnectionInfo will
not return network id -1 immediately. Need to poll the wifi disabled and
the network connection info cleared before asserting the connection
info.

Bug: 252869312
Test: atest ConnectivityManagerTest#testRejectPartialConnectivity_TearDownNetwork
Change-Id: If88261b0d81c1dc1731c683513878d054d2cb0dc

Chris Ye   authored and   My Name   commited 2022-12-06 00:50:26 -08:00
7efae207d2
Increased the timeout from 5 to 30 seconds
Increase the timeout to deal with the flaky test.

Bug: 260073439
Test: TH

Change-Id: I653d80cfa97256e139f8cf989a085b1133732092

Mark Chien   commited 2022-12-06 06:51:03 +00:00
82eb31b346