summaryrefslogtreecommitdiff
path: root/tests/net/java/com/android/server/IpSecServiceTest.java
AgeCommit message (Collapse)Author
2021-05-13Move net unit tests to packages/ConnectivityRemi NGUYEN VAN
Move the tests together with packages/Connectivity code, so both can be moved to packages/modules/Connectivity together. Also reorganize unit tests in a unit/ directory, as other tests (integration/, common/ etc.) have been added in tests/net since they were created. This makes the directory structure consistent. Test: atest FrameworksNetTests Bug: 187814163 Ignore-AOSP-First: needs per-branch move for merge conflicts Change-Id: I254ffd1c08ec058d594b4ea55cbae5505f8497cc
2021-03-12Add a new API to get the network ID range of IPSec tunnel interfacelucaslin
- Add a new API to get the network ID range of IPSec tunnel interface. - Use the new API in IpSecServiceTest to make sure the result is the same. Follow-up commit will change the logic in IpSecService#reserveNetId(), the modified test can ensure the correctness of the new change. Bug: 172183305 Test: atest FrameworksNetTests:IpSecServiceTest Change-Id: Ic605e48941fc9d6482cdcd01a8adcdc9b6d586a6
2021-02-08Remove unused INetworkManagementService from IpSecServicelucaslin
IpSecService is no longer using any methods of INetworkManagementService, so remove it from IpSecService and related files. Bug: 170598012 Test: atest FrameworksNetTests Change-Id: I852e3a534e0ffd26b4b22420754f3ec8a6f153ad
2020-03-10Automatically set IPsec tunnel interface as upBenedict Wong
This change makes IPsec tunnel interfaces automatically get brought up once they are created. Originally this was considered to be an additional safety check, as they would not be start routing traffic until explicitly brought up. However, in the intervening time, the NetworkManagementController now requires the NETWORK_STACK permission to set an interface as up. Additionally, that call is a hidden API, and thus not usable for use cases such as IWLAN. Bug: 149348618 Test: FrameworksNetTests, CtsNetTestCases passing. Change-Id: I55b63a748463a388e1e2991d2d5d6b3023545e60
2019-05-10Revert "Add NATT keepalive resources and methods into IpSecService"Junyu Lai
This reverts commit 2445227fa803e66ad39693057625aae72db454ed. Reason for revert: Adds dependency between IpSecService and ConnectivityService may lead to future deadlock problems. Uses a simpler approach instead, hence the solution is not needed. See aosp/954040. Change-Id: Ibff278a6eee666cd85dba81c2bed94d568679b02
2019-04-19Add NATT keepalive resources and methods into IpSecServiceBenedict Wong
This change adds a new NATTKeepalive resource type, along with the associated allocation/deallocation. Additionally, this change allows ReferenceCountedResource(s) to not be binder-linked, to allow the ConnectivityService to verify ownership and allocate a NattKeepalive without double-registering for binder-death notifications. Bug: 125517194 Test: IpSecService frameworks tests ran Change-Id: I8293f79940ad57dabb6f2b9de5e334d06b869443
2019-04-03Fix flaky UdpEncapsulationSocket testBenedict Wong
This commit reduces the flakiness of the testOpenAndCloseUdpEncapsulationSocket by retrying up to three times. Unfortunately, testing port-selected socket creation is racy against other applications. This helps to handle the same race condition as done in IpSecService#bindToRandomPort Bug: 128024100 Test: 200x runs of testOpenAndCloseUdpEncapsulationSocket Change-Id: I7e036ce821019dbac6c50899bd0894e89d2fe82a
2019-03-05Migrate frameworks/base/tests/net/ to androidx.testBrett Chabot
Test: atest FrameworksNetTests Change-Id: Iaa59d606f5e1678cc5aaca9ed37e184fad894e5d
2019-01-18Merge "Avoid calling ParcelFileDescriptor.fromSocket on new Sockets."Josh Gao
2018-11-28Use ParcelFileDescriptor instead of FileDescriptor in INetd.aidlLuke Huang
Stable aidl won't support FileDescriptor but ParcelFileDescriptor. In order to migrate to stable aidl, replace all FileDescriptor in INdetd.aidl. Test: runtest frameworks-net passes Change-Id: Icdf37aed0e0cce0352070a437066e77c0f2fd85a
2018-11-09Avoid calling ParcelFileDescriptor.fromSocket on new Sockets.Josh Gao
Previously, we were calling ParcelFileDescriptor.fromSocket on a newly initialized Socket, which doesn't actually create a file descriptor until the Socket is bound or connected. Bind the Socket to a random port to force the file descriptor to be allocated. Test: treehugger Change-Id: Id92a3e1316881d1c5382485aa2d6a41fc37e9651
2018-01-24Add TunnelInterface API and KernelResourceRecordsBenedict Wong
This change adds one KernelResourceRecord type (TunnelInterfaceRecord), and adds methods for the creation of TunnelInterfaces, as well as the application of Transforms to the given TunnelInterfaces As part of the generation of ikeys/okeys, a ReserveKeyTracker manages a java bitset to avoid collisions and reserve/release keys. Bug: 63588681 Test: Compiles, CTS, unit tests all pass on AOSP_marlin Change-Id: I9e9b6455e27073acd4491eae666aa966b3b10e0f
2018-01-22Merge "Address comments and final cleanup from refcounting integration"Benedict Wong
2018-01-19Rename create/delete transform methodsBenedict Wong
CreateTransportModeTransform and DeleteTransportModeTransform are both agnostic as far as which mode of transform it creates/deletes. As such, to facilitate the implementation of tunnel mode, this patch renames them to CreateTransform and DeleteTransform, along with all test names. Bug: 63588681 Test: frameworks/base unit tests and CTS tests run, passed Change-Id: I1f015eb7ad0e85fca966658a9402485ca2b44091
2018-01-17Address comments and final cleanup from refcounting integrationBenedict Wong
Added some extra comments on reference counting and moved a few methods around. No significant logical changes made in this CL Bug: 63409385 Test: CTS, Unit tests (both frameworks-base and netd) and binder tests all pass Change-Id: I89f1f4a021db48ae406fefefa6aca7406045736c
2018-01-17IpSec - API Tweak for removeTransportModeTransformNathan Harold
Because IpSecTransforms are now unidirectional, and because the only mechanism for removing Transforms removes it from both directions, the API can no longer use the Transform parameter to meaningfully validate that the caller had applied a transform. Since that functionality was as-yet unimplemented and is now infeasible, the transform parameter is removed. Bug: 72079356 Test: cts - IpSecManagerTest; runtest frameworks-net Change-Id: If19b0d34bdc6daf31a40d6d62bff326dcbca08c0
2018-01-16Update IpSecService UnitTestsNathan Harold
The IpSecService Unit tests relied on the directionality of the IpSecConfig and previously did not specify a source address. Unit tests updated without functional change other than to address these two requirements. Bug: 71717213 Test: runtest frameworks-net Change-Id: Iedbed735bc50fd4fdfe985f9e173956062a7b0d1
2018-01-16Make Transforms UnidirectionalNathan Harold
Convert the IpSecTransform from being a bi-directional pair of SAs to a unidirectional single SA. This CL also removes the concept of "direction from SAs meaning that a IpSecTransform may now be applied to a socket in either direction. -Make transforms unidirectional -Add Convert allocateSpi() to use destination rather than direction and remote address -Remove directionality from builders for IpSecTransform -Change applyTransportModeTransform() to take a direction in which to apply the transform object. -Additional minor naming updates -Restrict IpSecConfig to only print keys on eng builds -Move DIRECTION constants to IpSecManager -Add sourceAddress parameter to IpSecTransform to provide additional guarantees about the source address of data; (explicit failure rather than implicit failure). -Move SPI to the build() method of IpSecTransform Bug: 71717213 Test: runtest frameworks-net, CTS - IpSecManagerTest Change-Id: I0824b37f443f4b8c62536d9801238c63ed8f2a1c
2018-01-04Add validation to IpSecConfig algorithm settersBenedict Wong
Adds checks to ensure that users can only set the correct types of algorithms for the Authentication, Encryption and Authenticated Encryption algorithms. Bug: 65223935 Test: Added tests in IpSecConfigTest, and passed on aosp_marlin-eng Change-Id: I462c77d9eb5710b8d03a48866453649d3b6fc6bf
2017-12-18[ipsec-doze] Add fchown to IpSecService to support dozeBenedict Wong
Encap sockets are currently created as the system server, and should be fchown'd to the user for whom it was created on behalf of. Bug: 62994731 Test: New tests added and run to IpSecService Change-Id: Icc49e709ae588981e69765fdb77537d7ffbac5fe
2017-12-18[ipsec-qtaguid] Tag sockets upon creation of encap socketsBenedict Wong
Added calls to tag encap sockets to that of the UID for which the encap socket is being created on behalf of. This ensures that all data accounting generated for the UDP-encap-ESP socket is correctly billed to the right UID. Bug: 62994731 Test: New tests added to IpSecServiceTest.java, passing Change-Id: I15365ea9c982fd7b4e3cdeff314ddfba2289c86e
2017-12-14Merge "Use consistent naming for allocating SPI."nharold
2017-12-13Convert IpSecService resources to use refcountingBenedict Wong
This is part 2 of 2 of the refcounting refactor for IpSecService resources. Switched ManagedResources to use RefcountedResource structure for managing reference counts and eventual cleanup. Further, resource arrays and quota management have been aggregated into a UserRecord for better isolation. UID access checking has been similarly moved into the UserRecordTracker, and resourceId checking has been rolled into RefcountedResourceArray's accessor methods. Bug: 63409385 Test: CTS, all unit tests run on aosp_marlin-eng, new tests added Change-Id: Iee52dd1c9d2583bb6bfaf65be87569e9d50a5b63
2017-12-12Use consistent naming for allocating SPI.Jonathan Basseri
Throughout the IPsec code (API, system server, netd) we use "reserve" SPI and "allocate" SPI interchangeably. This renames to use "allocate" everywhere for self-consistency and consistency with the kernel (ALLOCSPI). In javadoc, I am leaving the word "reserve" in several places because it is still an accurate description of how the method behaves. Bug: 69128142 Test: TreeHugger should be enough Change-Id: I8ea603b4612303b0393beef04032671fa53d2106
2017-11-28Cleanup of resource limit testsludi
Test: runtest frameworks-net Bug: 65688605 Change-Id: Ice3ff2624b83c833a99559485c1e782d36c54ae3
2017-11-13Add test case for user quota management in IpSecServiceludi
Test: runtest frameworks-net Bug: 65688605 Change-Id: I3210c4920d0ac1d09fecb56c25e392e2bcba641f
2017-10-18Return a port from bindToPort() in IpSecServiceBenedict Wong
When binding to a random port, the port number was not being returned, so the user is incorrectly receiving a port of zero. Return the port number that was ultimately bound. Bug: 67662580 Test: Ran CTS test on aosp_angler-eng Change-Id: I22f4e5cdc83d43dc453788889990feb34e451bd3
2017-10-12Migrate most of core networking tests to junit4Hugo Benichi
This patch is a batch of mechanical changes to test classes to migrate away from AndroidTestCase and TestCase. Bug: 62918393 Test: runtest frameworks-net Change-Id: I74134609e511f22c4d9ecd65780e981f9ba7ae3f
2017-10-03Split IpSecServiceTest to add IPv6 TestsNathan Harold
-Split IpSecServiceTest into parameterized and single tests. -Add IPv6 parameters Bug: 66954381 Test: this Change-Id: Ib98c112560014f73bccc3d2842c31d297c7a07ef
2017-10-03Input Validation for IpSecServiceNathan Harold
All of the input to IpSecService over the Binder interface needs to be validated both for sanity and for safety. -Sanity check all the parameters coming from binder. -Added setters for IpSecConfig to decouple the test from the IpSecManager. This was needed because the input validation caused the tests to fail due to a null parameter that was previously un-tested. -Added the mode flag to the IpSecConfig bundle this oversight was found during testing. -Expose the getResourceId() methods for testing in UdpEncapsulationSocket, SecurityParameterIndex, and IpSecTransform classes. -Remove the unneeded getIpSecConfig() from IpSecTransform: unneeded now that we can synthesize configs. Bug: 38397094 Test: runtest frameworks-net Change-Id: I5241fc7fbfa9816d54219acd8d81a9f7eef10dd4
2017-07-20Add unit test for IpSecServiceludi
Test: runtest frameworks-net Bug:38259578 Change-Id: I4a049d5fdec79e36692e3b12306bd0758c19ad75