diff options
author | Yan Yan <evitayan@google.com> | 2019-02-19 17:56:02 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-02-19 17:56:02 +0000 |
commit | 97cbb71ea0057a3be4fe354549de2d61cc31eeb2 (patch) | |
tree | 60cf633a69e8eaf7497c15a714638319d289711c /tests/iketests/src/java/com | |
parent | 4b255a59d01857ebc4a508106a8917e6b3710745 (diff) | |
parent | 1015c6f66c50e661f8357041c33b5110b45546a9 (diff) | |
download | ike-97cbb71ea0057a3be4fe354549de2d61cc31eeb2.tar.gz |
Merge "Create Builder for SaProposal"
Diffstat (limited to 'tests/iketests/src/java/com')
-rw-r--r-- | tests/iketests/src/java/com/android/ike/ikev2/SaProposalTest.java | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/iketests/src/java/com/android/ike/ikev2/SaProposalTest.java b/tests/iketests/src/java/com/android/ike/ikev2/SaProposalTest.java new file mode 100644 index 00000000..522d44bc --- /dev/null +++ b/tests/iketests/src/java/com/android/ike/ikev2/SaProposalTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.ike.ikev2; + +import static org.junit.Assert.fail; + +import com.android.ike.ikev2.SaProposal.Builder; + +import org.junit.Test; + +public final class SaProposalTest { + @Test + public void testBuildEncryptAlgosWithNoAlgorithm() throws Exception { + Builder builder = Builder.newIkeSaProposalBuilder(); + try { + builder.buildOrThrow(); + fail("Encryption algorithm is not provided."); + } catch (IllegalArgumentException expected) { + + } + } + + @Test + public void testBuildEncryptAlgosWithUnrecognizedAlgorithm() throws Exception { + Builder builder = Builder.newIkeSaProposalBuilder(); + try { + builder.addEncryptionAlgorithm(-1); + fail("Encryption algorithm is not recognized."); + } catch (IllegalArgumentException expected) { + + } + } + + @Test + public void testBuildEncryptAlgosWithTwoModes() throws Exception { + Builder builder = Builder.newIkeSaProposalBuilder(); + try { + builder.addEncryptionAlgorithm(SaProposal.ENCRYPTION_ALGORITHM_3DES) + .addEncryptionAlgorithm(SaProposal.ENCRYPTION_ALGORITHM_AES_GCM_12); + fail("Expect failure when normal and combined-mode ciphers are proposed together."); + } catch (IllegalArgumentException expected) { + + } + } +} |