Commit Graph

132 Commits

Author SHA1 Message Date
chiachangwang
91bac1953c Move VpnTransportInfoTest to common test
Move VpnTransportInfoTest to common test to add the cts
coverage.

Annotate @ConnectivityModuleTest so that the test will
not fail with module that is not up-to-date, and use
assertParcelingIsLossless to prevent similar order module
in device case.

Bug: 256775913
Test: atest CtsNetTestCases:android.net.VpnTransportInfoTest
Change-Id: I1c40a4fc42468748d71c3df5c18b2ceb5b3769e1
2022-11-18 02:17:33 +00:00
Maciej Żenczykowski
44089f5080 trivialize apf property accessor dead code
(these are never called, but must exist for API reasons)

Bug: 257393783
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2f1cb29c5176539abe25bf767997ab4ed5eca6de
2022-11-04 11:43:22 +00:00
Chalard Jean
86317d8bb4 Add logs for changes in capabilities and score
This will be useful for diagnosing default network changes.

Logs may look like, for example :
Update capabilities for net 100 : -NET_CAPABILITY_OEM_PAID+NET_CAPABILITY_TRUSTED
Or :
Update score for net 100 : -POLICY_EVER_EVALUATED+POLICY_IS_VPN+POLICY_IS_DESTROYED

Test: FrameworksNetTests
      manual
Change-Id: Ic4788c599573aae9daeca995b8853800aaaba0b8
2022-10-14 14:32:38 +09:00
Chalard Jean
1d420b3b76 Move bit utilities to BitUtils.
Test: BitUtilsTest
Change-Id: I3e100c6087f61c2a13aa8558ee8f9a9ad480c681
2022-10-12 16:39:37 +09:00
Paul Hu
0655d1b89a Fix test flake on IpConnectivityLogTest
The test does not wait for sending all log events done, just
check the total received event number after 200ms. If one of
thread is running slowly, the test would be flaky. Thus, use
the Thread#join() to ensure the log events sending out
completely.

Bug: 245005401
Test: atest CtsNetTestCases
Change-Id: I90ad6960453c4639b6429a2e36e35d2d53148131
2022-09-16 18:27:53 +08:00
Lorenzo Colitti
9f74712d49 Merge "Simplify per-target-SDK LinkProperties tests." 2022-07-26 05:53:05 +00:00
Lorenzo Colitti
ccd3020a91 Simplify per-target-SDK LinkProperties tests.
Currently these tests run as hostside tests and require a lot of
boilerplate, including their own CtsHostsideNetworkTestsApp3
build target.

Move the coverage to LinkPropertiesTest using the new-ish
@CtsNetTestCasesMaxTargetSdk31 annotation, and remove the
hostside tests.

The only test that is not being moved is one that checks the
behaviour of disabling the compat change on T. This test is not
very useful because it can only run on userdebug builds and not
on production builds, because CtsHostsideNetworkTestsApp3 targets
SDK 33. We do have test coverage for disabling the compat change
on an app targeting SDK 31, where it is allowed.

Fix: 236087258
Test: atest CtsNetTestCasesMaxTargetSdk31
Test: atest CtsNetTestCasesLatestSdk:android.net.LinkPropertiesTest
Change-Id: I6d4b1ba40f6cb63b30a600c227e9628858c03d73
2022-07-22 17:53:55 +09:00
Remi NGUYEN VAN
be077c1498 Remove usage of isDevSdkInRange
SdkLevel utilities should be used instead.

Test: atest
Change-Id: I81bf2807be30e3e4d2d7102cf03f267b28c65a08
2022-07-22 11:14:31 +09:00
Remi NGUYEN VAN
48380e4132 Revert EXCLUDED_ROUTES to only keep RTN_UNICAST
Revert the previous change to filter out all non-RTN_THROW routes when
EXCLUDED_ROUTES is disabled, as that behavior is CTS tested for T, and
has been used by T for a while. The previous change already ensured that
there is no behavior change on S, so this is the safest approach.

This fixes HostsideLinkPropertiesGatingTests.

Bug: 239046959
Test: atest LinkPropertiesTest CtsHostsideNetworkTests
Change-Id: I55e078cdc06341f4957fe7bc743c0022b2c7d3da
2022-07-15 16:46:14 +09:00
Remi NGUYEN VAN
66c27c18a2 Let LinkProperties#getRoutes() keeps returning all routes before T
Starting from T, VpnService supports exclude routes, which will
make the caller to get both of include routes and exclude routes
from LinkProperties#getRoutes(), and it's not expected to get the
exclude routes before T in production code even though the code
returns all routes.

But there is a CTS - LinkPropertiesTest#testRouteAddWithSameKey()
will try to add an exclude route and check if the result of
LinkProperties#getRoutes() contains that exclude route or not.
And the test is failed now since LinkProperties#getRoutes() will
only return include route if compat feature - EXCLUDED_ROUTES is
disabled. (EXCLUDED_ROUTES is enabled starting from target SDK T)

To fix this test failure, let LinkProperties#getRoutes() keeps
returning all routes if SDK is before T. This avoids changing
behavior on S, and even though there is still a behavior change
when upgrading to T, apps are unlikely to be relying on such
behavior, especially outside of tests.

Bug: 238061814
Test: Run "atest CtsNetTestCases:LinkPropertiesTest" on S build
      with mainline module which contains this patch.
Change-Id: Iac4362c4fe347ee3f06d5b21b0325fa69a7f27b6
2022-07-14 18:54:05 +09:00
Lorenzo Colitti
b64aeade58 Merge "Fix LinkProperties exclude routes tests on user builds." 2022-06-13 02:01:43 +00:00
Lorenzo Colitti
1bb94a3490 Fix LinkProperties exclude routes tests on user builds.
The tests fail on user builds because they target T and attempt
to override the compat change, which is not allowed on user
builds because the change defaults to on for apps targeting T+.
Fix this by marking the tests max target SDK 31.

Also improve the tests a bit:

- Use a RuleChain to make it explicit that
  CtsNetTestCasesMaxTargetSdk31 should be evaluated before
  EnableCompatChanges (otherwise the compat change rule would
  crash on user builds even if the max target SDK rule was going
  to skip the test anyway).

- Fix the IgnoreUpTo for all exclude route tests to say S+.
  Currently:
  - One says R+, which is incorrect because the updated
    LinkProperties code is in the connectivity module, which only
    goes back to S, not R.
  - The others say T+, which is incorrect because the update code
    is present on S.

Fix: 233553525
Test: LinkProperties test in CtsNetTestCasesLatestSdk passes on T user build
Test: LinkProperties test in CtsNetTestCasesMaxTargetSdk31 passes on T user build
Change-Id: Ie0e2f6761b90a65813ed3610c7b5e930a9fdc982
2022-06-13 02:01:35 +00:00
Junyu Lai
bfdd4407eb Return sorted NetworkStatsHistory
NetworkStatsHistory internally assumes that bucketStart is
sorted at all times. However, in the fields, we've found there
are some buckets of NetworkStatsHistory do not preserve the
order of timestamp, which is caught by the IAE when addEntry
is called.

In order to provide backward compatibility, return sorted items
instead of throwing IAE when adding entry into
NetworkStatsHistory instance.

Test: atest android.net.netstats.NetworkStatsHistoryTest#testBuilder
Bug: 233825704
Change-Id: If3187384bd1e90770ca5873b8ec73e852fff543d
Merged-In: If3187384bd1e90770ca5873b8ec73e852fff543d
  (pure cherry-picked from ag/18581718)
2022-06-07 10:51:52 +08:00
Natasha Lee
bcdb3c12ee Merge changes from topic "stats-migration"
* changes:
  Skip PersistentIntTest on S- device
  Don't clobber existing history entries.
  Ensure NetworkStats migrated snapshot is identical
  [MS82.1] Support network stats data migration process
  Add a PersistentInt class.
2022-06-01 03:03:02 +00:00
Lorenzo Colitti
1c7a20c6c6 Run testExcludedRoutesDisabled only in APKs with target SDK < T.
This test crashes if run from an APK that has target SDK 33 or
above because it tries to disable a compat change that on those
SDK versions is enabled by default.

Run it only in CtsNetTestCasesMaxTargetSdk31 and skip it in our
regular CTS modules.

Bug: 233553525
Test: test-only change
Change-Id: Iaf9c46591c13505c9d2a2a09994b9ee22a22390c
2022-05-30 23:36:23 +09:00
Lorenzo Colitti
ec2fbb7159 Don't clobber existing history entries.
Currently, adding a history to a NetworkStatsCollection.Builder
will overwrite any history that was previously passed in with the
same key. This breaks the importer (which is the primary/only
caller of this code), because the importer re-uses the same
NetworkStatsCollection object to import multiple files.

Instead, simply add any passed-in entries after the ones that
were already there. Require the caller to pass in entries in
order, because NetworkStatsHistory internally assumes that
entris are always sorted.

Bug: 230289468
Test: manually verified this unbreaks the importer
Change-Id: Ic8647ff28fca78d579d5f759f96a864877f8158b
Merged-In: Ic8647ff28fca78d579d5f759f96a864877f8158b
  (pure cherry-picked from ag/18453213)
2022-05-24 11:37:42 +08:00
preranap
ee4bfe7d3a Follow-up changes to Update VPN isolation code for excluded routes
Making changes in the hasExcludeRoute() with more realistic values as
suggested in CL 18173562(https://googleplex-android-review.git.corp.google.com/c/platform/packages/modules/Connectivity/+/18173562) by Lorenzo

Bug: 230058738
Test: atest LinkPropertiesTest
Change-Id: Ic0ea1e83fbe5bfec98b0060ba1a9635d5ba710e1
(cherry picked from commit 6c36b00662df8ccffb2ce49daa04b358c38f1b3e)
2022-05-13 00:26:27 +00:00
Treehugger Robot
65b3529be5 Merge "Remove NetworkIdentitySet usage in CTS" 2022-05-09 04:13:27 +00:00
James Mattis
105c5f0b1a Merge changes I8b48655d,I8ff4e371
* changes:
  Rename of InternalNetworkManagementException
  InternalNetworkManagementExceptionTest unit tests
2022-05-05 20:05:35 +00:00
James Mattis
371b229216 Rename of InternalNetworkManagementException
Test update for renaming InternalNetworkManagementException to
EthernetNetworkManagementException.

Bug: 210485380
Test: atest FrameworksNetTests
Change-Id: I8b48655dc090eecda1dfd0542092308036fe6da7
2022-05-03 13:22:21 -07:00
James Mattis
d9d03808f1 InternalNetworkManagementExceptionTest unit tests
Bug: 210485380
Test: atest FrameworksNetTests
:android.net.InternalNetworkManagementExceptionTest

Change-Id: I8ff4e371be961a4ffce5e6281c86ab4c2968f971
Merged-In: I8ff4e371be961a4ffce5e6281c86ab4c2968f971
2022-05-03 13:22:15 -07:00
Prerana Patil
a1c6dbbd53 Merge "Update VPN isolation code for excluded routes" 2022-05-03 17:40:12 +00:00
Aaron Huang
c7975ff3bf Merge "Add test for NetworkTemplate.Builder#setRoaming(int)" 2022-05-03 07:02:11 +00:00
Aaron Huang
132df4ed06 Merge "Add NetworkTemplateTest to common test for cts coverage" 2022-05-03 07:01:55 +00:00
Remi NGUYEN VAN
7b0c61d0bd Remove NetworkIdentitySet usage in CTS
NetworkIdentitySet is hidden API and may change on subsequent module
updates.
Use the module_lib NetworkStatsCollection.Key constructor that uses a
set of NetworkIdentity instead.

Bug: 217129444
Test: atest NetworkStatsCollectionTest
Change-Id: Icd1160ae920059306c3319f7298707f1e14cbb48
2022-05-02 14:59:51 +09:00
Treehugger Robot
6a957c70c0 Merge "[MS83] Add Cts for NetworkStatsCollection/History builders" 2022-05-02 02:26:55 +00:00
Prerana
2b97bbebf4 Update VPN isolation code for excluded routes
Bug: 230058738
Test: atest LinkPropertiesTest

Result: https://paste.googleplex.com/4706859672928256

Change-Id: I970fca6b0e2cd358e9bd77152563d13367867c74
2022-04-29 22:23:02 +00:00
Remi NGUYEN VAN
d651629b14 Merge "Fix CtsNetTestCases on Q" 2022-04-18 03:12:42 +00:00
Remi NGUYEN VAN
c559512cd2 Fix CtsNetTestCases on Q
- Skip NetworkCapabilitiesTest on Q. The test covers code that is very
   localized in NetworkCapabilities.java, and is only updatable on S+,
   so does not need to be in MTS before that.
 - Fix ConnectivityManagerTest to remove external references to
   CaptivePortalData instances in the lambdas, as this is compiled into
   a method taking CaptivePortalData as argument, and because the class
   does not exist on Q, the test runner would crash enumerating method
   arguments.
 - Remove call to getSystemService(ETHERNET_SERVICE) on Q from the test
   thread, as it will crash when called from a thread that does not have
   a Looper.

Test: atest CtsNetTestCases
Bug: 227253613
Change-Id: I97c64b24c767e874dfba00aa1f46be2c4972f917
2022-04-15 16:40:08 +09:00
Taras Antoshchuk
30d41e59bc Filter out excluded routes in LinkProperties
Gate presence of excluded routes in LinkProperties on target sdk T.

Bug: 186082280
Test: atest LinkPropertiesTest
Change-Id: If8fdb468a0a4968c5f2a878b7aacfeb4f7d9a9e5
2022-04-13 01:17:56 +02:00
Chalard Jean
de665266cd Rename setAccessUids to setAllowedUids
Bug: 217725769
Test: ConnectivityServiceTest CtsNetTestCases
Change-Id: Ic8a3f91553d1462b7f54259c467fb90a950bdd59
Merged-In: I8860fbb353eedf5d01e9dc248e4d765046bd562c
2022-03-16 17:58:20 +00:00
Aaron Huang
6d70c20ff5 Add test for NetworkTemplate.Builder#setRoaming(int)
Bug: 215435701
Test: CtsNetTestCases
Change-Id: Ie000244a954585241304adef95b4156e64d33f41
Merged-In: Ie000244a954585241304adef95b4156e64d33f41
2022-03-10 15:00:49 +00:00
Aaron Huang
22999fd87a Add NetworkTemplateTest to common test for cts coverage
Test for NetworkTemplate.Builder

Bug: 215435701
Test: CtsNetTestCases
Change-Id: I3a55bc74388fa34a142abec308b67b185641c460
Merged-In: I3a55bc74388fa34a142abec308b67b185641c460
2022-03-10 14:57:46 +00:00
junyulai
08e0130dcb [MS83] Add Cts for NetworkStatsCollection/History builders
Test: 1. atest CtsNetTestCases:android.net.netstats.NetworkStatsHistoryTest
 2. atest CtsNetTestCases:android.net.netstats.NetworkStatsCollectionTest
 3. atest FrameworksNetTests
Bug: 218441356
  (cherry-picked from ag/16811190)
Change-Id: If3d45325623cad987aab35f89c55f84042271adf
Merged-In: If3d45325623cad987aab35f89c55f84042271adf
2022-03-09 14:14:01 +08:00
Chiachang Wang
978370cb9c Merge "Rename getVpnRequiresValidation to isVpnValidationRequired" 2022-03-03 00:10:54 +00:00
Chiachang Wang
7ec6ae74c8 Rename getVpnRequiresValidation to isVpnValidationRequired
Update API name from getVpnRequiresValidation to
isVpnValidationRequired according to API review feedback.

Test: atest FrameworksNetTests
Bug: 220129160
Change-Id: I1025f4c35b320c14e872eaffd7ed82658a5f3d0c
2022-03-02 01:02:45 +00:00
Remi NGUYEN VAN
3b81323e4a Fix testing with/without connectivity module
Add missing @ConnectivityModuleTest annotations to tests that cover
functionalities that were introduced in a newer connectivity module
update.

Also add CtsNetTestCasesLatestSdk to postsubmit with only APK modules
installed, and with only the connectivity/tethering module installed.
This can then be moved to presubmit to catch such issues before they are
merged.

While doing this cleanup the TEST_MAPPING file in tests/ and merge its
contents into the root TEST_MAPPING file. This does not change anything
for "postsubmit" tests as they are run independently of changes. It only
causes FrameworksNetIntegrationTests to run in presubmit on any change
in modules/Connectivity/ instead of only on modules/Connectivity/tests/
changes, which is how it should be.

Bug: 218611855
Test: TH needs to test TEST_MAPPING
Change-Id: I26629a35d8c2df3db33180ecc22d49d538ad3b8b
2022-02-16 15:22:30 +09:00
Remi NGUYEN VAN
106569b856 Merge "Allow test+other networks to have specifiers" 2022-02-14 05:31:20 +00:00
Chiachang Wang
84ad04f768 Merge "Change naming of excludeLocalRoutes" 2022-02-10 00:50:30 +00:00
Patrick Rohr
6b5b7b40d8 Merge changes from topic "bandwidth-limiting"
* changes:
  Add bandwidth limiting to CS
  Add setting that controls network rate limit
2022-02-09 18:00:04 +00:00
Patrick Rohr
a20843638f Add setting that controls network rate limit
The INGRESS_RATE_LIMIT_BYTES_PER_SECOND setting controls the rate limit
for internet networks. If set to -1, no rate limit applies.  There is
one global rate limit that will be applied to all networks with
NET_CAPABILITY_INTERNET.

Test: atest ConnectivitySettingsManagerTest
Bug: 157552970
Change-Id: Ia82aa867686d484ce46734f76d4a48bf864eff84
2022-02-09 14:46:26 +01:00
Chiachang Wang
f890874970 Change naming of excludeLocalRoutes
Address API review feedback to change naming of
setExcludedLocalRoutesVpn and getter.

Bug: 217742354
Test: atest FrameworksNetTests
Change-Id: I57bbf55c7aba1c86ec8687d2431a50b37e63c6d0
2022-02-09 15:50:06 +08:00
Jean Chalard
4b66d4e244 Merge "Add and implement API for VpnManagers to request validation" 2022-02-09 06:03:45 +00:00
Chiachang Wang
865511a8c4 Add and implement API for VpnManagers to request validation
This adds a new API that lets VPN apps using VpnManager request
that the platform run its basic validation check on the resulting
network.

Bug: 184750836
Test: atest FrameworksNetTests
Change-Id: I00092eee857d3e33529b19461cfd5dd060a0fe20
2022-02-08 22:47:26 +09:00
Etan Cohen
1e86b3af26 Expose public APIs for IP & static IP configuration
Create public API for IP and static IP configuration.

Bug: 209840828
Test: atest android.net.cts.IpConfigurationTest
Test: atest android.net.cts.StaticIpConfigurationTest
Test: atest android.net.dhcp.DhcpResultsParcelableUtilTest
Change-Id: I720f168d1023806970919ca5dd44239a276826b6
2022-02-07 19:57:07 +00:00
Chalard Jean
9a30acf744 Add accessUids to NetworkCapabilities.
For now, all entry points reject this. Followup changes
will allow the supported use cases.

Test: new unit tests and CTS for this in this patch
Change-Id: I7262811a2e46336d3bb63c80886fc0578a36da94
2022-01-31 17:04:58 +09:00
Sooraj Sasindran
f8eb713874 Add low latency and high bandwidth network capabilities
Bug: 194332512
Test: build
Change-Id: I415ca1ba90ea54c4106f806fe855bcb84d3e38ba
2022-01-25 09:35:30 -08:00
Sooraj Sasindran
f4a58dcd45 Add support for Multiple enterprise slice
Bug: 194332512
Test: unit test
CTS-Coverage-Bug: 211133973
Change-Id: Ie8be08a7cfa9155168d1da146d02fd1643248bdc
2022-01-22 14:39:40 -08:00
Chiachang Wang
b04664d7a6 Merge "Update the SDK for the tests with intended target in T+" 2022-01-21 06:34:29 +00:00
Chiachang Wang
7212fbee14 Update the SDK for the tests with intended target in T+
Correct the SDK for those tests are expected running in T+
device. Check @IgnoreUpTo(S) may be incorrect after receiving
patches before T release.

Refer to temporary constant definition in DevSdkIgnoreRule until
the SDK constant being pushed into AOSP and synced with branch
used for mainline.

BUg: 215294242
Test: atest CtsNetTestCases CtsNetTestCasesLatestSdk
Change-Id: Ide6a241f7944dd1e75bc33b21aa29471a5df94c6
2022-01-20 10:30:19 +08:00