|
| 1 | +/** |
| 2 | + * TLS-Attacker - A Modular Penetration Testing Framework for TLS |
| 3 | + * |
| 4 | + * Copyright 2014-2017 Ruhr University Bochum / Hackmanit GmbH |
| 5 | + * |
| 6 | + * Licensed under Apache License 2.0 |
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + */ |
| 9 | +package de.rub.nds.tlsattacker.core.protocol.parser.suppData; |
| 10 | + |
| 11 | +import de.rub.nds.modifiablevariable.util.ArrayConverter; |
| 12 | +import de.rub.nds.tlsattacker.core.protocol.message.suppData.SupplementalDataEntry; |
| 13 | +import java.util.Arrays; |
| 14 | +import java.util.Collection; |
| 15 | +import static org.junit.Assert.assertArrayEquals; |
| 16 | +import static org.junit.Assert.assertTrue; |
| 17 | +import org.junit.Test; |
| 18 | +import org.junit.runner.RunWith; |
| 19 | +import org.junit.runners.Parameterized; |
| 20 | + |
| 21 | +@RunWith(Parameterized.class) |
| 22 | +public class SupplementalDataEntryParserTest { |
| 23 | + |
| 24 | + @Parameterized.Parameters |
| 25 | + public static Collection<Object[]> generateData() { |
| 26 | + return Arrays.asList(new Object[][] { |
| 27 | + { |
| 28 | + ArrayConverter.hexStringToByteArray("4002000a0008010005aaaaaaaaaa"), |
| 29 | + 16386, |
| 30 | + 10, |
| 31 | + ArrayConverter.hexStringToByteArray("0008010005aaaaaaaaaa"), |
| 32 | + } |
| 33 | + }); |
| 34 | + } |
| 35 | + |
| 36 | + private int supplementalDataEntryType; |
| 37 | + private int supplementalDataEntryLength; |
| 38 | + private byte[] supplementalDataEntry; |
| 39 | + private byte[] supplementalDataTestEntry; |
| 40 | + |
| 41 | + public SupplementalDataEntryParserTest(byte[] supplementalDataTestEntry, int supplementalDataEntryType, |
| 42 | + int supplementalDataEntryLength, byte[] supplementalDataEntry) { |
| 43 | + this.supplementalDataEntryType = supplementalDataEntryType; |
| 44 | + this.supplementalDataEntryLength = supplementalDataEntryLength; |
| 45 | + this.supplementalDataEntry = supplementalDataEntry; |
| 46 | + this.supplementalDataTestEntry = supplementalDataTestEntry; |
| 47 | + } |
| 48 | + |
| 49 | + @Test |
| 50 | + public void testParse() { |
| 51 | + SupplementalDataEntryParser parser = new SupplementalDataEntryParser(0, supplementalDataTestEntry); |
| 52 | + SupplementalDataEntry entry = parser.parse(); |
| 53 | + assertTrue(supplementalDataEntryType == entry.getSupplementalDataEntryType().getValue()); |
| 54 | + assertTrue(supplementalDataEntryLength == entry.getSupplementalDataEntryLength().getValue()); |
| 55 | + assertArrayEquals(supplementalDataEntry, entry.getSupplementalDataEntry().getValue()); |
| 56 | + } |
| 57 | + |
| 58 | +} |
0 commit comments