summaryrefslogtreecommitdiff
path: root/tests/net/java/com/android/server/IpSecServiceTest.java
Commit message (Collapse)AuthorAgeFilesLines
* Move net unit tests to packages/ConnectivityRemi NGUYEN VAN2021-05-131-670/+0
| | | | | | | | | | | | | | 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
* Add a new API to get the network ID range of IPSec tunnel interfacelucaslin2021-03-121-4/+6
| | | | | | | | | | | | | - 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
* Remove unused INetworkManagementService from IpSecServicelucaslin2021-02-081-6/+3
| | | | | | | | | | 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
* Automatically set IPsec tunnel interface as upBenedict Wong2020-03-101-4/+7
| | | | | | | | | | | | | | 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
* Revert "Add NATT keepalive resources and methods into IpSecService"Junyu Lai2019-05-101-96/+0
| | | | | | | | | | | | 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
* Add NATT keepalive resources and methods into IpSecServiceBenedict Wong2019-04-191-0/+96
| | | | | | | | | | | | 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
* Fix flaky UdpEncapsulationSocket testBenedict Wong2019-04-031-14/+20
| | | | | | | | | | | | 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
* Migrate frameworks/base/tests/net/ to androidx.testBrett Chabot2019-03-051-8/+9
| | | | | Test: atest FrameworksNetTests Change-Id: Iaa59d606f5e1678cc5aaca9ed37e184fad894e5d
* Merge "Avoid calling ParcelFileDescriptor.fromSocket on new Sockets."Josh Gao2019-01-181-1/+3
|\
| * Avoid calling ParcelFileDescriptor.fromSocket on new Sockets.Josh Gao2018-11-091-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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
* | Use ParcelFileDescriptor instead of FileDescriptor in INetd.aidlLuke Huang2018-11-281-3/+3
|/ | | | | | | | | 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
* Add TunnelInterface API and KernelResourceRecordsBenedict Wong2018-01-241-0/+21
| | | | | | | | | | | | | 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
* Merge "Address comments and final cleanup from refcounting integration"Benedict Wong2018-01-221-3/+3
|\
| * Address comments and final cleanup from refcounting integrationBenedict Wong2018-01-171-3/+3
| | | | | | | | | | | | | | | | | | | | | | 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
* | Rename create/delete transform methodsBenedict Wong2018-01-191-2/+2
|/ | | | | | | | | | | 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
* IpSec - API Tweak for removeTransportModeTransformNathan Harold2018-01-171-1/+1
| | | | | | | | | | | | | | 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
* Update IpSecService UnitTestsNathan Harold2018-01-161-66/+55
| | | | | | | | | | | | 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
* Make Transforms UnidirectionalNathan Harold2018-01-161-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add validation to IpSecConfig algorithm settersBenedict Wong2018-01-041-0/+153
| | | | | | | | | | 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
* [ipsec-doze] Add fchown to IpSecService to support dozeBenedict Wong2017-12-181-0/+22
| | | | | | | | | 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
* [ipsec-qtaguid] Tag sockets upon creation of encap socketsBenedict Wong2017-12-181-0/+64
| | | | | | | | | | | 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
* Merge "Use consistent naming for allocating SPI."nharold2017-12-141-4/+4
|\
| * Use consistent naming for allocating SPI.Jonathan Basseri2017-12-121-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Convert IpSecService resources to use refcountingBenedict Wong2017-12-131-1/+33
|/ | | | | | | | | | | | | | | | 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
* Cleanup of resource limit testsludi2017-11-281-9/+9
| | | | | | Test: runtest frameworks-net Bug: 65688605 Change-Id: Ice3ff2624b83c833a99559485c1e782d36c54ae3
* Add test case for user quota management in IpSecServiceludi2017-11-131-0/+119
| | | | | | Test: runtest frameworks-net Bug: 65688605 Change-Id: I3210c4920d0ac1d09fecb56c25e392e2bcba641f
* Return a port from bindToPort() in IpSecServiceBenedict Wong2017-10-181-0/+2
| | | | | | | | | | 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
* Migrate most of core networking tests to junit4Hugo Benichi2017-10-121-2/+2
| | | | | | | | | 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
* Split IpSecServiceTest to add IPv6 TestsNathan Harold2017-10-031-195/+2
| | | | | | | | | | -Split IpSecServiceTest into parameterized and single tests. -Add IPv6 parameters Bug: 66954381 Test: this Change-Id: Ib98c112560014f73bccc3d2842c31d297c7a07ef
* Input Validation for IpSecServiceNathan Harold2017-10-031-16/+35
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Add unit test for IpSecServiceludi2017-07-201-0/+435
Test: runtest frameworks-net Bug:38259578 Change-Id: I4a049d5fdec79e36692e3b12306bd0758c19ad75