1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.commons.compress.archivers.sevenz;
20
21 import static org.junit.jupiter.api.Assertions.assertEquals;
22 import static org.junit.jupiter.api.Assertions.assertThrows;
23
24 import java.io.BufferedInputStream;
25 import java.io.IOException;
26 import java.io.InputStream;
27 import java.io.ObjectInputStream;
28
29 import org.junit.jupiter.api.Test;
30
31
32
33
34
35
36 public class AES256SHA256DecoderTest {
37
38 @Test
39 public void testDecodeWithNonEmptyString() throws IOException {
40
41 final AES256SHA256Decoder aES256SHA256Decoder = new AES256SHA256Decoder();
42 try (BufferedInputStream bufferedInputStream = new BufferedInputStream(null, 3138)) {
43 final byte[] byteArray = new byte[8];
44 byteArray[1] = (byte) -72;
45 final Coder coder = new Coder(null, 0, 0, byteArray);
46 try (InputStream inputStream = aES256SHA256Decoder.decode("x", bufferedInputStream, 3138, coder, coder.properties, Integer.MAX_VALUE)) {
47 final IOException e = assertThrows(IOException.class, () -> new ObjectInputStream(inputStream), "Expecting exception: IOException");
48 assertEquals("Salt size + IV size too long in x", e.getMessage());
49 assertEquals("org.apache.commons.compress.archivers.sevenz.AES256SHA256Decoder$AES256SHA256DecoderInputStream",
50 e.getStackTrace()[0].getClassName());
51 }
52 }
53 }
54
55 }