diff --git a/pom.xml b/pom.xml index bbbb506c..6b6610da 100644 --- a/pom.xml +++ b/pom.xml @@ -26,8 +26,8 @@ 2.0.9 - 5.9.1 - 4.9.0 + 5.10.1 + 5.2.0 2.2 1.3.0 diff --git a/src/test/java/org/cryptomator/cryptofs/CryptoFileSystemImplTest.java b/src/test/java/org/cryptomator/cryptofs/CryptoFileSystemImplTest.java index 12cc3ef2..e694130f 100644 --- a/src/test/java/org/cryptomator/cryptofs/CryptoFileSystemImplTest.java +++ b/src/test/java/org/cryptomator/cryptofs/CryptoFileSystemImplTest.java @@ -49,6 +49,7 @@ import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.DosFileAttributeView; import java.nio.file.attribute.DosFileAttributes; +import java.nio.file.attribute.FileAttribute; import java.nio.file.attribute.FileOwnerAttributeView; import java.nio.file.attribute.FileTime; import java.nio.file.attribute.GroupPrincipal; @@ -71,6 +72,7 @@ import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doThrow; @@ -454,7 +456,7 @@ public void setup() throws IOException { when(ciphertextPath.getFilePath()).thenReturn(ciphertextFilePath); when(openCryptoFiles.getOrCreate(ciphertextFilePath)).thenReturn(openCryptoFile); when(ciphertextFilePath.getName(3)).thenReturn(mock(CryptoPath.class, "path.c9r")); - when(openCryptoFile.newFileChannel(any(), any())).thenReturn(fileChannel); + when(openCryptoFile.newFileChannel(any(), any(FileAttribute[].class))).thenReturn(fileChannel); } @Nested @@ -861,7 +863,7 @@ public class Copy { private final CryptoPath cleartextTargetParent = mock(CryptoPath.class, "cleartextTargetParent"); private final Path ciphertextTargetParent = mock(Path.class, "ciphertextTargetParent"); private final Path ciphertextTargetDirParent = mock(Path.class, "ciphertextTargetDirParent"); - private final FileChannel ciphertextTargetDirFileChannel = mock(FileChannel.class); + private final FileChannel ciphertextTargetDirDirFileFileChannel = mock(FileChannel.class); @BeforeEach public void setup() throws IOException, ReflectiveOperationException { @@ -872,7 +874,7 @@ public void setup() throws IOException, ReflectiveOperationException { when(cryptoPathMapper.getCiphertextDir(cleartextTargetParent)).thenReturn(new CiphertextDirectory("41", ciphertextTargetParent)); when(cryptoPathMapper.getCiphertextDir(cleartextDestination)).thenReturn(new CiphertextDirectory("42", ciphertextDestinationDir)); - when(physicalFsProv.newFileChannel(Mockito.same(ciphertextDestinationDirFile), Mockito.anySet(), Mockito.any())).thenReturn(ciphertextTargetDirFileChannel); + when(physicalFsProv.newFileChannel(Mockito.same(ciphertextDestinationDirFile), Mockito.anySet(), Mockito.any())).thenReturn(ciphertextTargetDirDirFileFileChannel); } @Test @@ -954,6 +956,7 @@ public void copyFile() throws IOException { @Test public void copyDirectory() throws IOException { + when(physicalFsProv.newFileChannel(Mockito.eq(ciphertextDestinationDirFile), Mockito.any(), any(FileAttribute[].class))).thenReturn(ciphertextTargetDirDirFileFileChannel); when(cryptoPathMapper.getCiphertextFileType(cleartextSource)).thenReturn(CiphertextFileType.DIRECTORY); when(cryptoPathMapper.getCiphertextFileType(cleartextDestination)).thenThrow(NoSuchFileException.class); Mockito.doThrow(new NoSuchFileException("ciphertextDestinationDirFile")).when(physicalFsProv).checkAccess(ciphertextDestinationFile); @@ -961,7 +964,7 @@ public void copyDirectory() throws IOException { inTest.copy(cleartextSource, cleartextDestination); verify(readonlyFlag, atLeast(1)).assertWritable(); - verify(ciphertextTargetDirFileChannel).write(any(ByteBuffer.class)); + verify(ciphertextTargetDirDirFileFileChannel).write(any(ByteBuffer.class)); verify(physicalFsProv).createDirectory(ciphertextDestinationDir); verify(dirIdProvider, Mockito.never()).delete(Mockito.any()); verify(cryptoPathMapper, Mockito.never()).invalidatePathMapping(Mockito.any()); @@ -981,7 +984,7 @@ public void copyDirectoryReplaceExisting() throws IOException { inTest.copy(cleartextSource, cleartextDestination, StandardCopyOption.REPLACE_EXISTING); verify(readonlyFlag).assertWritable(); - verify(ciphertextTargetDirFileChannel, Mockito.never()).write(any(ByteBuffer.class)); + verify(ciphertextTargetDirDirFileFileChannel, Mockito.never()).write(any(ByteBuffer.class)); verify(physicalFsProv, Mockito.never()).createDirectory(Mockito.any()); verify(dirIdProvider, Mockito.never()).delete(Mockito.any()); verify(cryptoPathMapper, Mockito.never()).invalidatePathMapping(Mockito.any()); @@ -1001,8 +1004,9 @@ public void moveDirectoryCopyBasicAttributes() throws IOException { when(srcAttrs.lastModifiedTime()).thenReturn(lastModifiedTime); when(srcAttrs.lastAccessTime()).thenReturn(lastAccessTime); when(srcAttrs.creationTime()).thenReturn(createTime); - when(physicalFsProv.readAttributes(Mockito.same(ciphertextSourceDir), Mockito.same(BasicFileAttributes.class), Mockito.any())).thenReturn(srcAttrs); - when(physicalFsProv.getFileAttributeView(Mockito.same(ciphertextDestinationDir), Mockito.same(BasicFileAttributeView.class), Mockito.any())).thenReturn(dstAttrView); + when(physicalFsProv.readAttributes(Mockito.same(ciphertextSourceDir), Mockito.same(BasicFileAttributes.class), any(LinkOption[].class))).thenReturn(srcAttrs); + when(physicalFsProv.getFileAttributeView(Mockito.same(ciphertextDestinationDir), Mockito.same(BasicFileAttributeView.class), any(LinkOption[].class))).thenReturn(dstAttrView); + when(physicalFsProv.newFileChannel(Mockito.same(ciphertextDestinationDirFile), Mockito.anySet(), any(FileAttribute[].class))).thenReturn(ciphertextTargetDirDirFileFileChannel); inTest.copy(cleartextSource, cleartextDestination, StandardCopyOption.COPY_ATTRIBUTES); @@ -1020,8 +1024,9 @@ public void moveDirectoryCopyFileOwnerAttributes() throws IOException { FileOwnerAttributeView srcAttrsView = mock(FileOwnerAttributeView.class); FileOwnerAttributeView dstAttrView = mock(FileOwnerAttributeView.class); when(srcAttrsView.getOwner()).thenReturn(owner); - when(physicalFsProv.getFileAttributeView(Mockito.same(ciphertextSourceDir), Mockito.same(FileOwnerAttributeView.class), Mockito.any())).thenReturn(srcAttrsView); - when(physicalFsProv.getFileAttributeView(Mockito.same(ciphertextDestinationDir), Mockito.same(FileOwnerAttributeView.class), Mockito.any())).thenReturn(dstAttrView); + when(physicalFsProv.getFileAttributeView(Mockito.same(ciphertextSourceDir), Mockito.same(FileOwnerAttributeView.class), any(LinkOption[].class))).thenReturn(srcAttrsView); + when(physicalFsProv.getFileAttributeView(Mockito.same(ciphertextDestinationDir), Mockito.same(FileOwnerAttributeView.class), any(LinkOption[].class))).thenReturn(dstAttrView); + when(physicalFsProv.newFileChannel(Mockito.same(ciphertextDestinationDirFile), Mockito.anySet(), any(FileAttribute[].class))).thenReturn(ciphertextTargetDirDirFileFileChannel); inTest.copy(cleartextSource, cleartextDestination, StandardCopyOption.COPY_ATTRIBUTES); @@ -1042,8 +1047,9 @@ public void moveDirectoryCopyPosixAttributes() throws IOException { PosixFileAttributeView dstAttrView = mock(PosixFileAttributeView.class); when(srcAttrs.group()).thenReturn(group); when(srcAttrs.permissions()).thenReturn(permissions); - when(physicalFsProv.readAttributes(Mockito.same(ciphertextSourceDir), Mockito.same(PosixFileAttributes.class), Mockito.any())).thenReturn(srcAttrs); - when(physicalFsProv.getFileAttributeView(Mockito.same(ciphertextDestinationDir), Mockito.same(PosixFileAttributeView.class), Mockito.any())).thenReturn(dstAttrView); + when(physicalFsProv.readAttributes(Mockito.same(ciphertextSourceDir), Mockito.same(PosixFileAttributes.class), any(LinkOption[].class))).thenReturn(srcAttrs); + when(physicalFsProv.getFileAttributeView(Mockito.same(ciphertextDestinationDir), Mockito.same(PosixFileAttributeView.class), any(LinkOption[].class))).thenReturn(dstAttrView); + when(physicalFsProv.newFileChannel(Mockito.same(ciphertextDestinationDirFile), Mockito.anySet(), any(FileAttribute[].class))).thenReturn(ciphertextTargetDirDirFileFileChannel); inTest.copy(cleartextSource, cleartextDestination, StandardCopyOption.COPY_ATTRIBUTES); @@ -1064,8 +1070,9 @@ public void moveDirectoryCopyDosAttributes() throws IOException { when(srcAttrs.isHidden()).thenReturn(true); when(srcAttrs.isReadOnly()).thenReturn(true); when(srcAttrs.isSystem()).thenReturn(true); - when(physicalFsProv.readAttributes(Mockito.same(ciphertextSourceDir), Mockito.same(DosFileAttributes.class), Mockito.any())).thenReturn(srcAttrs); - when(physicalFsProv.getFileAttributeView(Mockito.same(ciphertextDestinationDir), Mockito.same(DosFileAttributeView.class), Mockito.any())).thenReturn(dstAttrView); + when(physicalFsProv.readAttributes(Mockito.same(ciphertextSourceDir), Mockito.same(DosFileAttributes.class), any(LinkOption[].class))).thenReturn(srcAttrs); + when(physicalFsProv.getFileAttributeView(Mockito.same(ciphertextDestinationDir), Mockito.same(DosFileAttributeView.class), any(LinkOption[].class))).thenReturn(dstAttrView); + when(physicalFsProv.newFileChannel(Mockito.same(ciphertextDestinationDirFile), Mockito.anySet(), any(FileAttribute[].class))).thenReturn(ciphertextTargetDirDirFileFileChannel); inTest.copy(cleartextSource, cleartextDestination, StandardCopyOption.COPY_ATTRIBUTES); @@ -1091,7 +1098,7 @@ public void moveDirectoryReplaceExistingNonEmpty() throws IOException { inTest.copy(cleartextSource, cleartextDestination, StandardCopyOption.REPLACE_EXISTING); }); verify(readonlyFlag).assertWritable(); - verify(ciphertextTargetDirFileChannel, Mockito.never()).write(any(ByteBuffer.class)); + verify(ciphertextTargetDirDirFileFileChannel, Mockito.never()).write(any(ByteBuffer.class)); verify(physicalFsProv, Mockito.never()).createDirectory(Mockito.any()); verify(dirIdProvider, Mockito.never()).delete(Mockito.any()); verify(cryptoPathMapper, Mockito.never()).invalidatePathMapping(Mockito.any()); diff --git a/src/test/java/org/cryptomator/cryptofs/CryptoPathMapperTest.java b/src/test/java/org/cryptomator/cryptofs/CryptoPathMapperTest.java index 263f7ca9..e2da36a8 100644 --- a/src/test/java/org/cryptomator/cryptofs/CryptoPathMapperTest.java +++ b/src/test/java/org/cryptomator/cryptofs/CryptoPathMapperTest.java @@ -50,7 +50,7 @@ public void setup() { Mockito.when(cryptor.fileNameCryptor()).thenReturn(fileNameCryptor); Mockito.when(pathToVault.resolve("d")).thenReturn(dataRoot); Mockito.when(vaultConfig.getShorteningThreshold()).thenReturn(220); - Mockito.when(fileSystem.getPath(ArgumentMatchers.anyString(), ArgumentMatchers.any())).thenAnswer(invocation -> { + Mockito.when(fileSystem.getPath(ArgumentMatchers.anyString(), ArgumentMatchers.any(String[].class))).thenAnswer(invocation -> { String first = invocation.getArgument(0); if (invocation.getArguments().length == 1) { return cryptoPathFactory.getPath(fileSystem, first); diff --git a/src/test/java/org/cryptomator/cryptofs/SymlinksTest.java b/src/test/java/org/cryptomator/cryptofs/SymlinksTest.java index 0fa01436..5169dc64 100644 --- a/src/test/java/org/cryptomator/cryptofs/SymlinksTest.java +++ b/src/test/java/org/cryptomator/cryptofs/SymlinksTest.java @@ -17,6 +17,7 @@ import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.attribute.FileAttribute; import java.nio.file.spi.FileSystemProvider; public class SymlinksTest { @@ -69,7 +70,7 @@ public void testCreateSymbolicLink() throws IOException { inTest.createSymbolicLink(cleartextPath, target); ArgumentCaptor bytesWritten = ArgumentCaptor.forClass(ByteBuffer.class); - Mockito.verify(underlyingFsProvider).createDirectory(Mockito.eq(ciphertextPath), Mockito.any()); + Mockito.verify(underlyingFsProvider).createDirectory(Mockito.eq(ciphertextPath), Mockito.any(FileAttribute[].class)); Mockito.verify(openCryptoFiles).writeCiphertextFile(Mockito.eq(symlinkFilePath), Mockito.any(), bytesWritten.capture()); Assertions.assertEquals("/symlink/target/path", StandardCharsets.UTF_8.decode(bytesWritten.getValue()).toString()); } diff --git a/src/test/java/org/cryptomator/cryptofs/attr/AttributeProviderTest.java b/src/test/java/org/cryptomator/cryptofs/attr/AttributeProviderTest.java index 85dd5916..d123f3df 100644 --- a/src/test/java/org/cryptomator/cryptofs/attr/AttributeProviderTest.java +++ b/src/test/java/org/cryptomator/cryptofs/attr/AttributeProviderTest.java @@ -62,9 +62,9 @@ public void setup() throws IOException { ciphertextBasicAttr = Mockito.mock(BasicFileAttributes.class); ciphertextPosixAttr = Mockito.mock(PosixFileAttributes.class); ciphertextDosAttr = Mockito.mock(DosFileAttributes.class); - Mockito.when(provider.readAttributes(Mockito.same(ciphertextRawPath), Mockito.same(BasicFileAttributes.class), any())).thenReturn(ciphertextBasicAttr); - Mockito.when(provider.readAttributes(Mockito.same(ciphertextRawPath), Mockito.same(PosixFileAttributes.class), any())).thenReturn(ciphertextPosixAttr); - Mockito.when(provider.readAttributes(Mockito.same(ciphertextRawPath), Mockito.same(DosFileAttributes.class), any())).thenReturn(ciphertextDosAttr); + Mockito.when(provider.readAttributes(Mockito.same(ciphertextRawPath), Mockito.same(BasicFileAttributes.class), any(LinkOption[].class))).thenReturn(ciphertextBasicAttr); + Mockito.when(provider.readAttributes(Mockito.same(ciphertextRawPath), Mockito.same(PosixFileAttributes.class), any(LinkOption[].class))).thenReturn(ciphertextPosixAttr); + Mockito.when(provider.readAttributes(Mockito.same(ciphertextRawPath), Mockito.same(DosFileAttributes.class), any(LinkOption[].class))).thenReturn(ciphertextDosAttr); Mockito.when(pathMapper.getCiphertextFileType(cleartextPath)).thenReturn(CiphertextFileType.FILE); Mockito.when(pathMapper.getCiphertextFilePath(cleartextPath)).thenReturn(ciphertextPath);