Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1756 in ITERATE/cyberduck from bugfix/TRAC-10750 …
…to master * commit 'effd4386e29e87ba58856b92d2ad93ae6eb0990c': Hash code collision with same path length and common prefix. Test with actual string comparision. Fix #10750. Add test. Review. Add failing test
- Loading branch information
Showing
3 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
onedrive/src/test/java/ch/cyberduck/core/onedrive/GraphFileIdProviderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package ch.cyberduck.core.onedrive; | ||
|
||
import ch.cyberduck.core.DisabledListProgressListener; | ||
import ch.cyberduck.core.Path; | ||
import ch.cyberduck.core.features.Directory; | ||
import ch.cyberduck.core.features.IdProvider; | ||
import ch.cyberduck.core.onedrive.features.GraphDirectoryFeature; | ||
import ch.cyberduck.core.onedrive.features.GraphFileIdProvider; | ||
import ch.cyberduck.core.transfer.TransferStatus; | ||
import ch.cyberduck.test.IntegrationTest; | ||
|
||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
|
||
import java.util.EnumSet; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
@Category(IntegrationTest.class) | ||
public class GraphFileIdProviderTest extends AbstractOneDriveTest { | ||
|
||
@Test | ||
public void testFileIdCollision() throws Exception { | ||
final Path path2R = new Path("/2R", EnumSet.of(Path.Type.directory)); | ||
final Path path33 = new Path("/33", EnumSet.of(Path.Type.directory)); | ||
|
||
final Directory directoryFeature = new GraphDirectoryFeature(session); | ||
final Path path2RWithId = directoryFeature.mkdir(path2R, null, new TransferStatus()); | ||
assertNotNull(path2RWithId.attributes().getVersionId()); | ||
final Path path33WithId = directoryFeature.mkdir(path33, null, new TransferStatus()); | ||
assertNotNull(path33WithId.attributes().getVersionId()); | ||
assertNotEquals(path2RWithId.attributes().getVersionId(), path33WithId.attributes().getVersionId()); | ||
|
||
final IdProvider idProvider = new GraphFileIdProvider(session); | ||
final String fileId = idProvider.getFileid(path33, new DisabledListProgressListener()); | ||
|
||
assertEquals(fileId, path33WithId.attributes().getVersionId()); | ||
assertNotEquals(fileId, path2RWithId.attributes().getVersionId()); | ||
} | ||
} |