diff options
author | Cody Kesting <ckesting@google.com> | 2019-10-07 16:13:14 -0700 |
---|---|---|
committer | Cody Kesting <ckesting@google.com> | 2019-10-08 10:44:02 -0700 |
commit | 7b612c47fc8ca6e6c66b6b9b3f811b6f4b271dec (patch) | |
tree | 4bde79baada667aa67706b0b5586c41d27f720c3 /tests/iketests | |
parent | d5756ba69b5fb990e3b059b83c311a06e8019f4e (diff) | |
download | ike-7b612c47fc8ca6e6c66b6b9b3f811b6f4b271dec.tar.gz |
Test EAP-AKA type data with skippable attrs.
EAP-AKA type data decoding testing is supplemented with a
test using unknown, skippable attributes.
Bug: 142279431
Test: added test case to EapAkaTypeDataTest.
Test: atest FrameworksIkeTests
Change-Id: I39f40e20de5e363961d0e03d1ad5e1cc76afa42c
Diffstat (limited to 'tests/iketests')
-rw-r--r-- | tests/iketests/src/java/com/android/ike/eap/message/simaka/EapAkaTypeDataTest.java | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/iketests/src/java/com/android/ike/eap/message/simaka/EapAkaTypeDataTest.java b/tests/iketests/src/java/com/android/ike/eap/message/simaka/EapAkaTypeDataTest.java index 65f0df1d..e5c6f9e8 100644 --- a/tests/iketests/src/java/com/android/ike/eap/message/simaka/EapAkaTypeDataTest.java +++ b/tests/iketests/src/java/com/android/ike/eap/message/simaka/EapAkaTypeDataTest.java @@ -16,6 +16,7 @@ package com.android.ike.eap.message.simaka; +import static com.android.ike.TestUtils.hexStringToByteArray; import static com.android.ike.eap.message.EapTestMessageDefinitions.EAP_AKA_CHALLENGE_RESPONSE_MAC_BYTES; import static com.android.ike.eap.message.EapTestMessageDefinitions.EAP_AKA_CHALLENGE_RESPONSE_TYPE_DATA; import static com.android.ike.eap.message.EapTestMessageDefinitions.EAP_AKA_IDENTITY_REQUEST; @@ -23,7 +24,10 @@ import static com.android.ike.eap.message.EapTestMessageDefinitions.INVALID_SUBT import static com.android.ike.eap.message.simaka.EapAkaTypeData.EAP_AKA_CHALLENGE; import static com.android.ike.eap.message.simaka.EapAkaTypeData.EAP_AKA_IDENTITY; import static com.android.ike.eap.message.simaka.EapSimAkaAttribute.EAP_AT_ANY_ID_REQ; +import static com.android.ike.eap.message.simaka.EapSimAkaAttribute.EAP_AT_AUTN; +import static com.android.ike.eap.message.simaka.EapSimAkaAttribute.EAP_AT_CHECKCODE; import static com.android.ike.eap.message.simaka.EapSimAkaAttribute.EAP_AT_MAC; +import static com.android.ike.eap.message.simaka.EapSimAkaAttribute.EAP_AT_RAND; import static com.android.ike.eap.message.simaka.EapSimAkaAttribute.EAP_AT_RES; import static com.android.ike.eap.message.simaka.attributes.EapTestAttributeDefinitions.RES_BYTES; @@ -36,8 +40,11 @@ import static org.junit.Assert.assertTrue; import com.android.ike.eap.message.simaka.EapAkaTypeData.EapAkaTypeDataDecoder; import com.android.ike.eap.message.simaka.EapSimAkaAttribute.AtAnyIdReq; +import com.android.ike.eap.message.simaka.EapSimAkaAttribute.AtAutn; import com.android.ike.eap.message.simaka.EapSimAkaAttribute.AtMac; +import com.android.ike.eap.message.simaka.EapSimAkaAttribute.AtRandAka; import com.android.ike.eap.message.simaka.EapSimAkaAttribute.AtRes; +import com.android.ike.eap.message.simaka.EapSimAkaAttribute.EapSimAkaUnsupportedAttribute; import com.android.ike.eap.message.simaka.EapSimAkaTypeData.DecodeResult; import org.junit.Before; @@ -52,6 +59,22 @@ public class EapAkaTypeDataTest { private static final int UNABLE_TO_PROCESS_CODE = 0; private static final int INVALID_SUBTYPE_INT = -1; + private static final int EAP_AT_TRUST_IND = 139; + private static final String RAND = "7A1FCDC0034BA1227E7B9FCEAFD47D53"; + private static final byte[] RAND_BYTES = hexStringToByteArray(RAND); + private static final String AUTN = "000102030405060708090A0B0C0D0E0F"; + private static final byte[] AUTN_BYTES = hexStringToByteArray(AUTN); + private static final String MAC = "95FEB9E70427F34B4FAC8F2C7A65A302"; + private static final byte[] MAC_BYTES = hexStringToByteArray(MAC); + private static final byte[] EAP_AKA_REQUEST = + hexStringToByteArray( + "010000" // Challenge | 2B padding + + "01050000" + RAND // AT_RAND attribute + + "02050000" + AUTN // AT_AUTN attribute + + "8B010002" // AT_RESULT_IND attribute (TS 124 302#8.2.3.1) + + "0B050000" + MAC // AT_MAC attribute + + "86010000"); // AT_CHECKCODE attribute + private EapAkaTypeDataDecoder mEapAkaTypeDataDecoder; @Before @@ -83,6 +106,40 @@ public class EapAkaTypeDataTest { } @Test + public void testDecodeWithOptionalAttributes() { + DecodeResult<EapAkaTypeData> result = mEapAkaTypeDataDecoder.decode(EAP_AKA_REQUEST); + + assertTrue(result.isSuccessfulDecode()); + EapAkaTypeData eapAkaTypeData = result.eapTypeData; + assertEquals(EAP_AKA_CHALLENGE, eapAkaTypeData.eapSubtype); + + // also check Map entries (needs to match input order) + Iterator<Entry<Integer, EapSimAkaAttribute>> itr = + eapAkaTypeData.attributeMap.entrySet().iterator(); + Entry<Integer, EapSimAkaAttribute> entry = itr.next(); + assertEquals(EAP_AT_RAND, (int) entry.getKey()); + assertArrayEquals(RAND_BYTES, ((AtRandAka) entry.getValue()).rand); + + entry = itr.next(); + assertEquals(EAP_AT_AUTN, (int) entry.getKey()); + assertArrayEquals(AUTN_BYTES, ((AtAutn) entry.getValue()).autn); + + entry = itr.next(); + assertEquals(EAP_AT_TRUST_IND, (int) entry.getKey()); + assertTrue(entry.getValue() instanceof EapSimAkaUnsupportedAttribute); + + entry = itr.next(); + assertEquals(EAP_AT_MAC, (int) entry.getKey()); + assertArrayEquals(MAC_BYTES, ((AtMac) entry.getValue()).mac); + + entry = itr.next(); + assertEquals(EAP_AT_CHECKCODE, (int) entry.getKey()); + assertTrue(entry.getValue() instanceof EapSimAkaUnsupportedAttribute); + + assertFalse(itr.hasNext()); + } + + @Test public void testDecodeInvalidSubtype() { DecodeResult<EapAkaTypeData> result = mEapAkaTypeDataDecoder.decode(INVALID_SUBTYPE); assertFalse(result.isSuccessfulDecode()); |