|
5 | 5 | package ch.iterate.hub.core; |
6 | 6 |
|
7 | 7 | import ch.cyberduck.core.*; |
| 8 | +import ch.cyberduck.core.features.Bulk; |
8 | 9 | import ch.cyberduck.core.features.Home; |
| 10 | +import ch.cyberduck.core.features.Touch; |
9 | 11 | import ch.cyberduck.core.features.Vault; |
| 12 | +import ch.cyberduck.core.features.Write; |
| 13 | +import ch.cyberduck.core.io.ChecksumComputeFactory; |
| 14 | +import ch.cyberduck.core.io.HashAlgorithm; |
| 15 | +import ch.cyberduck.core.io.StatusOutputStream; |
10 | 16 | import ch.cyberduck.core.preferences.PreferencesFactory; |
11 | 17 | import ch.cyberduck.core.proxy.DisabledProxyFinder; |
12 | 18 | import ch.cyberduck.core.ssl.DefaultX509KeyManager; |
13 | 19 | import ch.cyberduck.core.ssl.DisabledX509TrustManager; |
| 20 | +import ch.cyberduck.core.transfer.Transfer; |
| 21 | +import ch.cyberduck.core.transfer.TransferItem; |
| 22 | +import ch.cyberduck.core.transfer.TransferStatus; |
14 | 23 | import ch.cyberduck.core.vault.DefaultVaultRegistry; |
15 | 24 |
|
16 | | -import ch.iterate.hub.client.api.DeviceResourceApi; |
17 | | -import ch.iterate.hub.client.api.UsersResourceApi; |
18 | | -import ch.iterate.hub.client.api.VaultResourceApi; |
19 | | - |
20 | | -import ch.iterate.hub.crypto.UserKeys; |
21 | | -import ch.iterate.hub.crypto.uvf.UvfMetadataPayload; |
22 | | -import ch.iterate.hub.workflows.UserKeysService; |
23 | | -import ch.iterate.hub.workflows.UserKeysServiceImpl; |
24 | | -import ch.iterate.hub.workflows.VaultServiceImpl; |
25 | | - |
| 25 | +import org.apache.commons.io.IOUtils; |
| 26 | +import org.apache.commons.lang3.RandomUtils; |
26 | 27 | import org.apache.commons.lang3.StringUtils; |
27 | 28 | import org.apache.logging.log4j.LogManager; |
28 | 29 | import org.apache.logging.log4j.Logger; |
29 | 30 | import org.junit.jupiter.api.Assertions; |
| 31 | +import org.junit.jupiter.api.Disabled; |
| 32 | +import org.junit.jupiter.api.Test; |
30 | 33 | import org.junit.jupiter.params.ParameterizedTest; |
31 | 34 | import org.openapitools.jackson.nullable.JsonNullableModule; |
32 | 35 |
|
| 36 | +import java.io.ByteArrayInputStream; |
| 37 | +import java.util.Collections; |
33 | 38 | import java.util.EnumSet; |
34 | 39 | import java.util.List; |
35 | 40 | import java.util.UUID; |
|
55 | 60 | import com.fasterxml.jackson.annotation.JsonInclude; |
56 | 61 | import com.fasterxml.jackson.databind.ObjectMapper; |
57 | 62 |
|
| 63 | +import org.testcontainers.shaded.org.apache.commons.io.input.NullInputStream; |
| 64 | + |
58 | 65 | import static ch.iterate.hub.testsetup.HubTestUtilities.getAdminApiClient; |
59 | 66 | import static org.junit.jupiter.api.Assertions.*; |
60 | 67 |
|
61 | 68 | public abstract class AbstractHubSynchronizeTest extends AbstractHubTest { |
62 | 69 | private static final Logger log = LogManager.getLogger(AbstractHubSynchronizeTest.class.getName()); |
63 | 70 |
|
| 71 | + /** |
| 72 | + * Use to start unattended setup and then run |
| 73 | + * @throws InterruptedException |
| 74 | + */ |
| 75 | + @Test |
| 76 | + @Disabled |
| 77 | + public void runForever() throws InterruptedException { |
| 78 | + Thread.sleep(924982347); |
| 79 | + } |
| 80 | + |
64 | 81 | /** |
65 | 82 | * Verify storage profiles are synced from hub bookmark. |
66 | 83 | */ |
@@ -240,13 +257,25 @@ public void test03AddVault(final HubTestConfig config) throws Exception { |
240 | 257 | assertFalse(vaultRegistry.isEmpty()); |
241 | 258 | assertEquals(1, vaultRegistry.size()); |
242 | 259 |
|
243 | | - // TODO WiP trying to guide AbstractVault.encrypt() -> CryptoDirectoryV7Provider.toEncrypted(final Session<?> session, final String directoryId, final Path directory) -> do we need to write own CryptoDirectory? |
244 | 260 | final Path bucket = new Path(vaultBookmark.getDefaultPath(), EnumSet.of(Path.Type.directory, Path.Type.volume, Path.Type.vault)); |
245 | 261 | assertNotSame(Vault.DISABLED, vaultRegistry.find(session, bucket)); |
246 | 262 | { |
247 | 263 | final AttributedList<Path> list = session.getFeature(ListService.class).list(bucket, new DisabledListProgressListener()); |
248 | 264 | assertTrue(list.isEmpty()); |
249 | 265 | } |
| 266 | + { |
| 267 | + final Path home = vaultRegistry.find(session, bucket).getHome(); |
| 268 | + Path file = new Path(home, "gugus.txt", EnumSet.of(AbstractPath.Type.file)); |
| 269 | + byte[] content = RandomUtils.nextBytes(234); |
| 270 | + TransferStatus transferStatus = new TransferStatus().withLength(content.length); |
| 271 | + transferStatus.setChecksum(session.getFeature(Write.class).checksum(file, transferStatus).compute(new ByteArrayInputStream(content), transferStatus)); |
| 272 | + session.getFeature(Bulk.class).pre(Transfer.Type.upload, Collections.singletonMap(new TransferItem(file), transferStatus), new DisabledConnectionCallback()); |
| 273 | + StatusOutputStream<?> out = session.getFeature(Write.class).write(file, transferStatus, new DisabledConnectionCallback()); |
| 274 | + IOUtils.copyLarge(new ByteArrayInputStream(content), out); |
| 275 | + out.close(); |
| 276 | + final AttributedList<Path> list = session.getFeature(ListService.class).list(bucket, new DisabledListProgressListener()); |
| 277 | + assertFalse(list.isEmpty()); |
| 278 | + } |
250 | 279 |
|
251 | 280 | // raw listing encrypted file names |
252 | 281 | vaultRegistry.close(bucket); |
|
0 commit comments