|
1 | 1 | /* |
2 | | - * Copyright © 2015 IBM Corp. All rights reserved. |
| 2 | + * Copyright © 2015, 2018 IBM Corp. All rights reserved. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file |
5 | 5 | * except in compliance with the License. You may obtain a copy of the License at |
|
15 | 15 | package com.cloudant.sync.datastore.encryption; |
16 | 16 |
|
17 | 17 | import com.cloudant.sync.internal.documentstore.encryption.EncryptedAttachmentInputStream; |
18 | | -import com.cloudant.sync.matcher.CauseMatcher; |
19 | 18 | import com.cloudant.sync.util.TestUtils; |
20 | 19 |
|
21 | 20 | import org.apache.commons.io.IOUtils; |
| 21 | +import org.junit.Assert; |
22 | 22 | import org.junit.Rule; |
23 | 23 | import org.junit.Test; |
24 | | -import org.junit.Assert; |
25 | 24 | import org.junit.rules.ExpectedException; |
26 | 25 |
|
27 | 26 | import java.io.File; |
|
30 | 29 | import java.io.InputStream; |
31 | 30 | import java.security.InvalidKeyException; |
32 | 31 |
|
33 | | -import javax.crypto.IllegalBlockSizeException; |
34 | | - |
35 | 32 | /** |
36 | 33 | * Test encrypting an attachment to check correct on disk format is read. |
37 | 34 | */ |
@@ -86,25 +83,6 @@ public void testReadingTruncatedIVFile() throws IOException, InvalidKeyException |
86 | 83 | new FileInputStream(encryptedAttachmentBlob), EncryptionTestConstants.key16Byte); |
87 | 84 | } |
88 | 85 |
|
89 | | - /** |
90 | | - * Test when we read file shorter than block multiple that an IOException escapes. |
91 | | - */ |
92 | | - @Test |
93 | | - public void testReadingTruncatedDataFile() throws IOException, InvalidKeyException { |
94 | | - exception.expect(IOException.class); |
95 | | - exception.expectCause(new CauseMatcher(IllegalBlockSizeException.class)); |
96 | | - |
97 | | - File encryptedAttachmentBlob = TestUtils.loadFixture( |
98 | | - "fixture/EncryptedAttachmentTest_truncatedData"); |
99 | | - InputStream encryptedInputStream = new EncryptedAttachmentInputStream( |
100 | | - new FileInputStream(encryptedAttachmentBlob), EncryptionTestConstants.key16Byte); |
101 | | - |
102 | | - //noinspection StatementWithEmptyBody |
103 | | - while (encryptedInputStream.read(new byte[1024]) != -1) { |
104 | | - // just read the data |
105 | | - } |
106 | | - } |
107 | | - |
108 | 86 | @Test(expected=InvalidKeyException.class) |
109 | 87 | public void Test31ByteKey() throws IOException, InvalidKeyException { |
110 | 88 | new EncryptedAttachmentInputStream(null, EncryptionTestConstants.keyLength31); |
|
0 commit comments