summaryrefslogtreecommitdiff
path: root/tests/net/java/com/android/server/IpSecServiceParameterizedTest.java
diff options
context:
space:
mode:
authorBenedict Wong <benedictwong@google.com>2017-12-13 18:26:40 -0800
committerBenedict Wong <benedictwong@google.com>2018-01-22 21:09:47 -0800
commite6b42773e8c079d0d41814d3455803d627dd1e3a (patch)
tree2e969e7a5078d86e435de4ae31007737c8de3486 /tests/net/java/com/android/server/IpSecServiceParameterizedTest.java
parent222529d95ca6f0ea89bff5532dd9440909258540 (diff)
Add checks to ensure SPIs are not reused
This change adds an additional check in CheckIpsecConfig to prevent users from using the same SPI twice. This allows for a more granular error message. Bug: 70642141 Test: Tests added in IpSecServiceParameterizedTest Change-Id: I9621fb05c6b162bd8ae8db4ac1e64feaa9d0ac73
Diffstat (limited to 'tests/net/java/com/android/server/IpSecServiceParameterizedTest.java')
-rw-r--r--tests/net/java/com/android/server/IpSecServiceParameterizedTest.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/net/java/com/android/server/IpSecServiceParameterizedTest.java b/tests/net/java/com/android/server/IpSecServiceParameterizedTest.java
index d9d4eeba900f..1618e07a79c0 100644
--- a/tests/net/java/com/android/server/IpSecServiceParameterizedTest.java
+++ b/tests/net/java/com/android/server/IpSecServiceParameterizedTest.java
@@ -268,6 +268,31 @@ public class IpSecServiceParameterizedTest {
anyInt());
}
+ public void testCreateTwoTransformsWithSameSpis() throws Exception {
+ IpSecConfig ipSecConfig = new IpSecConfig();
+ addDefaultSpisAndRemoteAddrToIpSecConfig(ipSecConfig);
+ addAuthAndCryptToIpSecConfig(ipSecConfig);
+
+ IpSecTransformResponse createTransformResp =
+ mIpSecService.createTransform(ipSecConfig, new Binder());
+ assertEquals(IpSecManager.Status.OK, createTransformResp.status);
+
+ // Attempting to create transform a second time with the same SPIs should throw an error...
+ try {
+ mIpSecService.createTransform(ipSecConfig, new Binder());
+ fail("IpSecService should have thrown an error for reuse of SPI");
+ } catch (IllegalStateException expected) {
+ }
+
+ // ... even if the transform is deleted
+ mIpSecService.deleteTransform(createTransformResp.resourceId);
+ try {
+ mIpSecService.createTransform(ipSecConfig, new Binder());
+ fail("IpSecService should have thrown an error for reuse of SPI");
+ } catch (IllegalStateException expected) {
+ }
+ }
+
@Test
public void testDeleteTransform() throws Exception {
IpSecConfig ipSecConfig = new IpSecConfig();