use of org.cryptomator.cryptolib.api.FileHeaderCryptor in project cryptofs by cryptomator.
the class OpenCryptoFileTest method testForceThrowsExceptionDuringWriteIfWritable.
@Test
public void testForceThrowsExceptionDuringWriteIfWritable() throws IOException {
when(options.writable()).thenReturn(true);
IOException expected = new IOException();
doThrow(expected).when(exceptionsDuringWrite).throwIfPresent();
FileHeaderCryptor fileHeaderCryptor = Mockito.mock(FileHeaderCryptor.class);
when(cryptor.fileHeaderCryptor()).thenReturn(fileHeaderCryptor);
thrown.expect(is(expected));
inTest.force(false, options);
}
use of org.cryptomator.cryptolib.api.FileHeaderCryptor in project cryptofs by cryptomator.
the class CryptoBasicFileAttributesTest method setup.
@Before
public void setup() throws IOException {
cryptor = Mockito.mock(Cryptor.class);
FileHeaderCryptor headerCryptor = Mockito.mock(FileHeaderCryptor.class);
FileContentCryptor contentCryptor = Mockito.mock(FileContentCryptor.class);
Mockito.when(cryptor.fileHeaderCryptor()).thenReturn(headerCryptor);
Mockito.when(headerCryptor.headerSize()).thenReturn(88);
Mockito.when(cryptor.fileContentCryptor()).thenReturn(contentCryptor);
Mockito.when(contentCryptor.cleartextChunkSize()).thenReturn(32 * 1024);
Mockito.when(contentCryptor.ciphertextChunkSize()).thenReturn(16 + 32 * 1024 + 32);
ciphertextFilePath = Mockito.mock(Path.class);
FileSystem fs = Mockito.mock(FileSystem.class);
Mockito.when(ciphertextFilePath.getFileSystem()).thenReturn(fs);
FileSystemProvider fsProvider = Mockito.mock(FileSystemProvider.class);
Mockito.when(fs.provider()).thenReturn(fsProvider);
delegateAttr = Mockito.mock(BasicFileAttributes.class);
}
use of org.cryptomator.cryptolib.api.FileHeaderCryptor in project cryptofs by cryptomator.
the class OpenCryptoFileTest method testCloseThrowsExceptionDuringWriteIfWritable.
@Test
public void testCloseThrowsExceptionDuringWriteIfWritable() throws IOException {
when(options.writable()).thenReturn(true);
IOException expected = new IOException();
doThrow(expected).when(exceptionsDuringWrite).throwIfPresent();
FileHeaderCryptor fileHeaderCryptor = Mockito.mock(FileHeaderCryptor.class);
when(cryptor.fileHeaderCryptor()).thenReturn(fileHeaderCryptor);
thrown.expect(is(expected));
inTest.close(options);
}
Aggregations