use of ch.cyberduck.core.s3.S3MetadataFeature in project cyberduck by iterate-ch.
the class MoveWorkerTest method testMoveFile.
@Test
public void testMoveFile() throws Exception {
final Path home = new Path("test-eu-central-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
final Path source = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
final Path target = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
new S3TouchFeature(session).touch(source, new TransferStatus().withMime("application/cyberduck"));
new S3AccessControlListFeature(session).setPermission(source, new Acl(new Acl.UserAndRole(new Acl.Owner("80b9982b7b08045ee86680cc47f43c84bf439494a89ece22b5330f8a49477cf6"), new Acl.Role(Acl.Role.FULL)), new Acl.UserAndRole(new Acl.GroupUser("http://acs.amazonaws.com/groups/global/AllUsers"), new Acl.Role(Acl.Role.READ))));
assertTrue(new S3FindFeature(session).find(source));
final MoveWorker worker = new MoveWorker(Collections.singletonMap(source, target), new SessionPool.SingleSessionPool(session), PathCache.empty(), new DisabledProgressListener(), new DisabledLoginCallback());
worker.run(session);
assertFalse(new S3FindFeature(session).find(source));
assertTrue(new S3FindFeature(session).find(target));
assertEquals("application/cyberduck", new S3MetadataFeature(session, new S3AccessControlListFeature(session)).getMetadata(target).get("Content-Type"));
assertTrue(new S3AccessControlListFeature(session).getPermission(target).asList().contains(new Acl.UserAndRole(new Acl.Owner("80b9982b7b08045ee86680cc47f43c84bf439494a89ece22b5330f8a49477cf6"), new Acl.Role(Acl.Role.FULL))));
assertTrue(new S3AccessControlListFeature(session).getPermission(target).asList().contains(new Acl.UserAndRole(new Acl.GroupUser(Acl.GroupUser.EVERYONE), new Acl.Role(Acl.Role.READ))));
new DeleteWorker(new DisabledLoginCallback(), Collections.singletonList(target), PathCache.empty(), new DisabledProgressListener()).run(session);
session.close();
}
use of ch.cyberduck.core.s3.S3MetadataFeature in project cyberduck by iterate-ch.
the class SpectraTouchFeatureTest method testTouch.
@Test
public void testTouch() throws Exception {
final Host host = new Host(new SpectraProtocol() {
@Override
public Scheme getScheme() {
return Scheme.http;
}
}, System.getProperties().getProperty("spectra.hostname"), Integer.valueOf(System.getProperties().getProperty("spectra.port")), new Credentials(System.getProperties().getProperty("spectra.user"), System.getProperties().getProperty("spectra.key")));
final SpectraSession session = new SpectraSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback(), new DisabledCancelCallback());
session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback());
final Path container = new Path("cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
final Path test = new Path(container, UUID.randomUUID().toString() + ".txt", EnumSet.of(Path.Type.file));
new SpectraTouchFeature(session).touch(test, new TransferStatus());
assertTrue(new SpectraFindFeature(session).find(test));
final Map<String, String> metadata = new S3MetadataFeature(session, null).getMetadata(test);
assertFalse(metadata.isEmpty());
new SpectraDeleteFeature(session).delete(Collections.<Path>singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
assertFalse(new SpectraFindFeature(session).find(test));
session.close();
}
Aggregations