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