Search in sources :

Example 1 with FileHeaderCryptor

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);
}
Also used : FileHeaderCryptor(org.cryptomator.cryptolib.api.FileHeaderCryptor) IOException(java.io.IOException) Test(org.junit.Test)

Example 2 with FileHeaderCryptor

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);
}
Also used : Path(java.nio.file.Path) FileHeaderCryptor(org.cryptomator.cryptolib.api.FileHeaderCryptor) FileHeaderCryptor(org.cryptomator.cryptolib.api.FileHeaderCryptor) FileContentCryptor(org.cryptomator.cryptolib.api.FileContentCryptor) Cryptor(org.cryptomator.cryptolib.api.Cryptor) FileSystemProvider(java.nio.file.spi.FileSystemProvider) FileSystem(java.nio.file.FileSystem) FileContentCryptor(org.cryptomator.cryptolib.api.FileContentCryptor) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes) Before(org.junit.Before)

Example 3 with FileHeaderCryptor

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);
}
Also used : FileHeaderCryptor(org.cryptomator.cryptolib.api.FileHeaderCryptor) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

FileHeaderCryptor (org.cryptomator.cryptolib.api.FileHeaderCryptor)3 IOException (java.io.IOException)2 Test (org.junit.Test)2 FileSystem (java.nio.file.FileSystem)1 Path (java.nio.file.Path)1 BasicFileAttributes (java.nio.file.attribute.BasicFileAttributes)1 FileSystemProvider (java.nio.file.spi.FileSystemProvider)1 Cryptor (org.cryptomator.cryptolib.api.Cryptor)1 FileContentCryptor (org.cryptomator.cryptolib.api.FileContentCryptor)1 Before (org.junit.Before)1