Search in sources :

Example 1 with S3MetadataFeature

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();
}
Also used : Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) S3FindFeature(ch.cyberduck.core.s3.S3FindFeature) SessionPool(ch.cyberduck.core.pool.SessionPool) S3TouchFeature(ch.cyberduck.core.s3.S3TouchFeature) Acl(ch.cyberduck.core.Acl) S3MetadataFeature(ch.cyberduck.core.s3.S3MetadataFeature) S3AccessControlListFeature(ch.cyberduck.core.s3.S3AccessControlListFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) AbstractS3Test(ch.cyberduck.core.s3.AbstractS3Test) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 2 with S3MetadataFeature

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();
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) Scheme(ch.cyberduck.core.Scheme) Host(ch.cyberduck.core.Host) S3MetadataFeature(ch.cyberduck.core.s3.S3MetadataFeature) DisabledCancelCallback(ch.cyberduck.core.DisabledCancelCallback) DisabledHostKeyCallback(ch.cyberduck.core.DisabledHostKeyCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) Credentials(ch.cyberduck.core.Credentials) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Aggregations

DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)2 Path (ch.cyberduck.core.Path)2 S3MetadataFeature (ch.cyberduck.core.s3.S3MetadataFeature)2 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)2 IntegrationTest (ch.cyberduck.test.IntegrationTest)2 Test (org.junit.Test)2 Acl (ch.cyberduck.core.Acl)1 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)1 Credentials (ch.cyberduck.core.Credentials)1 DisabledCancelCallback (ch.cyberduck.core.DisabledCancelCallback)1 DisabledHostKeyCallback (ch.cyberduck.core.DisabledHostKeyCallback)1 DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)1 Host (ch.cyberduck.core.Host)1 Scheme (ch.cyberduck.core.Scheme)1 Delete (ch.cyberduck.core.features.Delete)1 SessionPool (ch.cyberduck.core.pool.SessionPool)1 AbstractS3Test (ch.cyberduck.core.s3.AbstractS3Test)1 S3AccessControlListFeature (ch.cyberduck.core.s3.S3AccessControlListFeature)1 S3FindFeature (ch.cyberduck.core.s3.S3FindFeature)1 S3TouchFeature (ch.cyberduck.core.s3.S3TouchFeature)1