Skip to content

Commit 161037c

Browse files
committed
Add encrypted file upload to test03AddVault.
1 parent 1cdaeff commit 161037c

File tree

2 files changed

+50
-14
lines changed

2 files changed

+50
-14
lines changed

hub/src/test/java/ch/iterate/hub/core/AbstractHubSynchronizeTest.java

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,37 @@
44

55
package ch.iterate.hub.core;
66

7-
import ch.cyberduck.core.AbstractPath;
8-
import ch.cyberduck.core.AttributedList;
9-
import ch.cyberduck.core.DisabledCancelCallback;
10-
import ch.cyberduck.core.DisabledHostKeyCallback;
11-
import ch.cyberduck.core.DisabledListProgressListener;
12-
import ch.cyberduck.core.DisabledLoginCallback;
13-
import ch.cyberduck.core.DisabledPasswordCallback;
14-
import ch.cyberduck.core.Host;
15-
import ch.cyberduck.core.ListService;
16-
import ch.cyberduck.core.Path;
17-
import ch.cyberduck.core.Protocol;
18-
import ch.cyberduck.core.ProtocolFactory;
19-
import ch.cyberduck.core.Session;
20-
import ch.cyberduck.core.SimplePathPredicate;
7+
import ch.cyberduck.core.*;
8+
import ch.cyberduck.core.features.Bulk;
219
import ch.cyberduck.core.features.Home;
10+
import ch.cyberduck.core.features.Touch;
2211
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;
2316
import ch.cyberduck.core.preferences.PreferencesFactory;
2417
import ch.cyberduck.core.proxy.DisabledProxyFinder;
2518
import ch.cyberduck.core.ssl.DefaultX509KeyManager;
2619
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;
2723
import ch.cyberduck.core.vault.DefaultVaultRegistry;
2824

25+
import org.apache.commons.io.IOUtils;
26+
import org.apache.commons.lang3.RandomUtils;
2927
import org.apache.commons.lang3.StringUtils;
3028
import org.apache.logging.log4j.LogManager;
3129
import org.apache.logging.log4j.Logger;
3230
import org.junit.jupiter.api.Assertions;
31+
import org.junit.jupiter.api.Disabled;
32+
import org.junit.jupiter.api.Test;
3333
import org.junit.jupiter.params.ParameterizedTest;
3434
import org.openapitools.jackson.nullable.JsonNullableModule;
3535

36+
import java.io.ByteArrayInputStream;
37+
import java.util.Collections;
3638
import java.util.EnumSet;
3739
import java.util.List;
3840
import java.util.UUID;
@@ -58,12 +60,24 @@
5860
import com.fasterxml.jackson.annotation.JsonInclude;
5961
import com.fasterxml.jackson.databind.ObjectMapper;
6062

63+
import org.testcontainers.shaded.org.apache.commons.io.input.NullInputStream;
64+
6165
import static ch.iterate.hub.testsetup.HubTestUtilities.getAdminApiClient;
6266
import static org.junit.jupiter.api.Assertions.*;
6367

6468
public abstract class AbstractHubSynchronizeTest extends AbstractHubTest {
6569
private static final Logger log = LogManager.getLogger(AbstractHubSynchronizeTest.class.getName());
6670

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+
6781
/**
6882
* Verify storage profiles are synced from hub bookmark.
6983
*/
@@ -249,6 +263,19 @@ public void test03AddVault(final HubTestConfig config) throws Exception {
249263
final AttributedList<Path> list = session.getFeature(ListService.class).list(bucket, new DisabledListProgressListener());
250264
assertTrue(list.isEmpty());
251265
}
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+
}
252279

253280
// raw listing encrypted file names
254281
vaultRegistry.close(bucket);

hub/src/test/java/ch/iterate/hub/core/HubSynchronizeTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ private Stream<Arguments> arguments() {
3131
}
3232
}
3333

34+
@Nested
35+
@TestInstance(PER_CLASS)
36+
@Disabled("run standalone against already running hub started by runForever test.")
37+
public class PUnattendedMinio extends AbstractHubSynchronizeTest {
38+
private Stream<Arguments> arguments() {
39+
return Stream.of(minioStaticUnattendedLocalOnly, minioSTSUnattendedLocalOnly);
40+
}
41+
}
42+
3443
@Nested
3544
@ExtendWith({HubTestSetupDockerExtension.UnattendedLocalKeycloakDev.class})
3645
@TestInstance(PER_CLASS)

0 commit comments

Comments
 (0)