Skip to content

Commit

Permalink
Delete tests for content type in metadata no longer available with 51…
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Mar 8, 2024
1 parent 94f6f40 commit f8b4b03
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 94 deletions.
5 changes: 2 additions & 3 deletions s3/src/test/java/ch/cyberduck/core/s3/S3CopyFeatureTest.java
Expand Up @@ -42,15 +42,14 @@ public void testCopyFileZeroLength() throws Exception {
final Path container = new Path("test-eu-central-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
final Path test = new Path(container, new AsciiRandomStringService().random(), EnumSet.of(Path.Type.file));
test.attributes().setSize(0L);
new S3TouchFeature(session, new S3AccessControlListFeature(session)).touch(test, new TransferStatus().withMime("application/cyberduck"));
new S3TouchFeature(session, new S3AccessControlListFeature(session)).touch(test, new TransferStatus());
final Path copy = new Path(container, new AsciiRandomStringService().random(), EnumSet.of(Path.Type.file));
new S3CopyFeature(session, new S3AccessControlListFeature(session)).copy(test, copy, new TransferStatus(), new DisabledConnectionCallback(), new DisabledStreamListener());
assertTrue(new S3FindFeature(session, new S3AccessControlListFeature(session)).find(test));
assertNull(copy.attributes().getVersionId());
new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
assertTrue(new S3FindFeature(session, new S3AccessControlListFeature(session)).find(copy));
assertEquals("application/cyberduck",
new S3MetadataFeature(session, new S3AccessControlListFeature(session)).getMetadata(copy).get("Content-Type"));
;
new S3DefaultDeleteFeature(session).delete(Collections.singletonList(copy), new DisabledLoginCallback(), new Delete.DisabledCallback());
}

Expand Down
20 changes: 3 additions & 17 deletions s3/src/test/java/ch/cyberduck/core/s3/S3MetadataFeatureTest.java
Expand Up @@ -50,12 +50,12 @@ public void testGetMetadataBucket() throws Exception {
public void testGetMetadataFile() throws Exception {
final Path container = new Path("versioning-test-eu-central-1-cyberduck", EnumSet.of(Path.Type.volume, Path.Type.directory));
final Path test = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
new S3TouchFeature(session, new S3AccessControlListFeature(session)).touch(test, new TransferStatus().withMime("text/plain"));
new S3TouchFeature(session, new S3AccessControlListFeature(session)).touch(test, new TransferStatus().withMetadata(Collections.singletonMap("app", "cyberduck")));
final Map<String, String> metadata = new S3MetadataFeature(session, new S3AccessControlListFeature(session)).getMetadata(test);
new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
assertFalse(metadata.isEmpty());
assertTrue(metadata.containsKey("Content-Type"));
assertEquals("text/plain", metadata.get("Content-Type"));
assertTrue(metadata.containsKey("app"));
assertEquals("cyberduck", metadata.get("app"));
assertFalse(metadata.containsKey(Constants.KEY_FOR_USER_METADATA));
assertFalse(metadata.containsKey(Constants.KEY_FOR_SERVICE_METADATA));
assertFalse(metadata.containsKey(Constants.KEY_FOR_COMPLETE_METADATA));
Expand Down Expand Up @@ -87,18 +87,4 @@ public void testSetMetadataFileLeaveOtherFeatures() throws Exception {

new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
}

@Test
public void testSetDuplicateHeaderDifferentCapitalization() throws Exception {
final Path container = new Path("versioning-test-eu-central-1-cyberduck", EnumSet.of(Path.Type.volume, Path.Type.directory));
final Path test = new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
new S3TouchFeature(session, new S3AccessControlListFeature(session)).touch(test, new TransferStatus());
final S3MetadataFeature feature = new S3MetadataFeature(session, new S3AccessControlListFeature(session));
assertTrue(feature.getMetadata(test).containsKey("Content-Type"));
feature.setMetadata(test, Collections.singletonMap("Content-type", "text/plain"));
final Map<String, String> metadata = feature.getMetadata(test);
assertTrue(metadata.containsKey("Content-Type"));
assertEquals("text/plain", metadata.get("Content-Type"));
new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
}
13 changes: 3 additions & 10 deletions s3/src/test/java/ch/cyberduck/core/s3/S3MoveFeatureTest.java
Expand Up @@ -41,7 +41,6 @@
import java.io.ByteArrayInputStream;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Map;

import static org.junit.Assert.*;

Expand All @@ -52,7 +51,7 @@ public class S3MoveFeatureTest extends AbstractS3Test {
public void testMove() throws Exception {
final Path container = new Path("test-eu-central-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
final S3AccessControlListFeature acl = new S3AccessControlListFeature(session);
final Path test = new S3TouchFeature(session, acl).touch(new Path(container, new AsciiRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus().withMime("text/plain"));
final Path test = new S3TouchFeature(session, acl).touch(new Path(container, new AsciiRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
assertNull(test.attributes().getVersionId());
assertTrue(new S3FindFeature(session, acl).find(test));
final Path renamed = new Path(container, new AsciiRandomStringService().random(), EnumSet.of(Path.Type.file));
Expand All @@ -62,9 +61,6 @@ public void testMove() throws Exception {
final PathAttributes targetAttr = new S3AttributesFinderFeature(session, acl).find(renamed);
assertEquals(Comparison.equal, session.getHost().getProtocol().getFeature(ComparisonService.class).compare(Path.Type.file, test.attributes(), targetAttr));
assertEquals(Comparison.equal, session.getHost().getProtocol().getFeature(ComparisonService.class).compare(Path.Type.file, renamed.attributes(), targetAttr));
final Map<String, String> metadata = new S3MetadataFeature(session, acl).getMetadata(renamed);
assertFalse(metadata.isEmpty());
assertEquals("text/plain", metadata.get("Content-Type"));
new S3DefaultDeleteFeature(session).delete(Collections.singletonList(renamed), new DisabledLoginCallback(), new Delete.DisabledCallback());
}

Expand Down Expand Up @@ -97,12 +93,12 @@ public void testMoveVersioned() throws Exception {
final Path container = new Path("versioning-test-eu-central-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
Path test = new Path(container, new AsciiRandomStringService().random(), EnumSet.of(Path.Type.file));
final S3AccessControlListFeature acl = new S3AccessControlListFeature(session);
assertNotNull(new S3TouchFeature(session, acl).touch(test, new TransferStatus().withMime("text/plain")).attributes().getVersionId());
assertNotNull(new S3TouchFeature(session, acl).touch(test, new TransferStatus()).attributes().getVersionId());
assertTrue(new S3FindFeature(session, acl).find(test));
// Write some data to add a new version
final S3WriteFeature feature = new S3WriteFeature(session, acl);
final byte[] content = RandomUtils.nextBytes(10);
final TransferStatus status = new TransferStatus().withMime("text/plain");
final TransferStatus status = new TransferStatus();
status.setLength(content.length);
status.setChecksum(new SHA256ChecksumCompute().compute(new ByteArrayInputStream(content), status));
final HttpResponseOutputStream<StorageObject> out = feature.write(test, status, new DisabledConnectionCallback());
Expand All @@ -129,9 +125,6 @@ public void testMoveVersioned() throws Exception {
break;
}
}
final Map<String, String> metadata = new S3MetadataFeature(session, acl).getMetadata(renamed);
assertFalse(metadata.isEmpty());
assertEquals("text/plain", metadata.get("Content-Type"));
new S3DefaultDeleteFeature(session).delete(Collections.singletonList(renamed), new DisabledLoginCallback(), new Delete.DisabledCallback());
}

Expand Down
Expand Up @@ -30,7 +30,6 @@
import java.io.InputStream;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;

Expand All @@ -51,7 +50,6 @@ public void testUploadSinglePart() throws Exception {
IOUtils.write(random, local.getOutputStream(false));
final TransferStatus status = new TransferStatus();
status.setLength(random.length);
status.setMime("text/plain");
status.setStorageClass(S3Object.STORAGE_CLASS_REDUCED_REDUNDANCY);
final BytecountStreamListener count = new BytecountStreamListener();
service.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED),
Expand All @@ -71,9 +69,6 @@ public void testUploadSinglePart() throws Exception {
// d2b77e21aa68ebdcbfb589124b9f9192-1
assertEquals(Checksum.NONE, Checksum.parse(attr.getETag()));
assertEquals(S3Object.STORAGE_CLASS_REDUCED_REDUNDANCY, new S3StorageClassFeature(session, acl).getClass(test));
final Map<String, String> metadata = new S3MetadataFeature(session, acl).getMetadata(test);
assertFalse(metadata.isEmpty());
assertEquals("text/plain", metadata.get("Content-Type"));
new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
local.delete();
}
Expand All @@ -90,7 +85,6 @@ public void testUploadBucketInHostname() throws Exception {
IOUtils.write(random, local.getOutputStream(false));
final TransferStatus status = new TransferStatus();
status.setLength(random.length);
status.setMime("text/plain");
status.setStorageClass(S3Object.STORAGE_CLASS_REDUCED_REDUNDANCY);
final BytecountStreamListener count = new BytecountStreamListener();
service.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED),
Expand All @@ -110,9 +104,6 @@ public void testUploadBucketInHostname() throws Exception {
// d2b77e21aa68ebdcbfb589124b9f9192-1
assertEquals(Checksum.NONE, Checksum.parse(attr.getETag()));
assertEquals(S3Object.STORAGE_CLASS_REDUCED_REDUNDANCY, new S3StorageClassFeature(virtualhost, acl).getClass(test));
final Map<String, String> metadata = new S3MetadataFeature(virtualhost, acl).getMetadata(test);
assertFalse(metadata.isEmpty());
assertEquals("text/plain", metadata.get("Content-Type"));
new S3DefaultDeleteFeature(virtualhost).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
local.delete();
}
Expand All @@ -130,7 +121,6 @@ public void testUploadSinglePartEncrypted() throws Exception {
final TransferStatus status = new TransferStatus();
status.setEncryption(KMSEncryptionFeature.SSE_KMS_DEFAULT);
status.setLength(random.length);
status.setMime("text/plain");
status.setModified(System.currentTimeMillis());
status.setStorageClass(S3Object.STORAGE_CLASS_REDUCED_REDUNDANCY);
final BytecountStreamListener count = new BytecountStreamListener();
Expand All @@ -147,11 +137,6 @@ public void testUploadSinglePartEncrypted() throws Exception {
assertEquals(status.getResponse().getChecksum(), attr.getChecksum());
assertEquals(random.length, attr.getSize());
assertEquals(S3Object.STORAGE_CLASS_REDUCED_REDUNDANCY, new S3StorageClassFeature(session, acl).getClass(test));
final Map<String, String> metadata = new S3MetadataFeature(session, acl).getMetadata(test);
assertFalse(metadata.isEmpty());
assertEquals("text/plain", metadata.get("Content-Type"));
assertEquals("aws:kms", metadata.get("server-side-encryption"));
assertNotNull(metadata.get("server-side-encryption-aws-kms-key-id"));
new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
local.delete();
}
Expand Down
Expand Up @@ -106,7 +106,6 @@ public void testReadGzipContentEncoding() throws Exception {
status.setChecksum(new SHA256ChecksumCompute().compute(new ByteArrayInputStream(compressedContent), status));
final OutputStream out = new S3WriteFeature(session, new S3AccessControlListFeature(session)).write(file, status, new DisabledConnectionCallback());
new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(compressedContent), out);
assertEquals("gzip", new S3AttributesFinderFeature(session, new S3AccessControlListFeature(session)).find(file).getMetadata().get(HttpHeaders.CONTENT_ENCODING));
final InputStream in = new S3ReadFeature(session).read(file, status, new DisabledConnectionCallback());
assertNotNull(in);
assertEquals(TransferStatus.UNKNOWN_LENGTH, status.getLength());
Expand Down
Expand Up @@ -38,7 +38,6 @@
import java.io.OutputStream;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Map;
import java.util.UUID;

import static org.junit.Assert.*;
Expand Down Expand Up @@ -75,9 +74,6 @@ public void testUpload() throws Exception {
assertEquals(status.getResponse().getChecksum(), attr.getChecksum());
assertEquals(status.getResponse().getETag(), attr.getETag());
assertEquals(random.length, attr.getSize());
final Map<String, String> metadata = new S3MetadataFeature(session, new S3AccessControlListFeature(session)).getMetadata(test);
assertFalse(metadata.isEmpty());
assertEquals("text/plain", metadata.get("Content-Type"));
new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
local.delete();
}
Expand All @@ -95,18 +91,12 @@ public void testUploadSSE() throws Exception {
out.close();
final TransferStatus status = new TransferStatus();
status.setLength(random.length);
status.setMime("text/plain");
status.setEncryption(KMSEncryptionFeature.SSE_KMS_DEFAULT);
service.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED),
new DisabledStreamListener(), status, new DisabledLoginCallback());
assertTrue(new S3FindFeature(session, new S3AccessControlListFeature(session)).find(test));
final PathAttributes attributes = new S3AttributesFinderFeature(session, new S3AccessControlListFeature(session)).find(test);
assertEquals(random.length, attributes.getSize());
final Map<String, String> metadata = new S3MetadataFeature(session, new S3AccessControlListFeature(session)).getMetadata(test);
assertFalse(metadata.isEmpty());
assertEquals("text/plain", metadata.get("Content-Type"));
assertEquals("aws:kms", metadata.get("server-side-encryption"));
assertNotNull(metadata.get("server-side-encryption-aws-kms-key-id"));
new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
local.delete();
}
Expand All @@ -124,15 +114,11 @@ public void testUploadWithSHA256Checksum() throws Exception {
out.close();
final TransferStatus status = new TransferStatus();
status.setLength(random.length);
status.setMime("text/plain");
service.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED),
new DisabledStreamListener(), status, new DisabledLoginCallback());
assertTrue(new S3FindFeature(session, new S3AccessControlListFeature(session)).find(test));
final PathAttributes attributes = new S3AttributesFinderFeature(session, new S3AccessControlListFeature(session)).find(test);
assertEquals(random.length, attributes.getSize());
final Map<String, String> metadata = new S3MetadataFeature(session, new S3AccessControlListFeature(session)).getMetadata(test);
assertFalse(metadata.isEmpty());
assertEquals("text/plain", metadata.get("Content-Type"));
new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
local.delete();
}
Expand Down
Expand Up @@ -40,7 +40,8 @@
import java.util.Map;
import java.util.UUID;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

@Category(IntegrationTest.class)
public class S3ThresholdUploadServiceTest extends AbstractS3Test {
Expand All @@ -66,7 +67,6 @@ public void testUploadSinglePartEuCentral() throws Exception {
IOUtils.write(random, local.getOutputStream(false));
final TransferStatus status = new TransferStatus();
status.setLength(random.length);
status.setMime("text/plain");
status.setStorageClass(S3Object.STORAGE_CLASS_REDUCED_REDUNDANCY);
final BytecountStreamListener count = new BytecountStreamListener();
service.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED),
Expand All @@ -77,9 +77,6 @@ public void testUploadSinglePartEuCentral() throws Exception {
final PathAttributes attributes = new S3AttributesFinderFeature(session, new S3AccessControlListFeature(session)).find(test);
assertEquals(random.length, attributes.getSize(), 0L);
assertEquals(S3Object.STORAGE_CLASS_REDUCED_REDUNDANCY, new S3StorageClassFeature(session, new S3AccessControlListFeature(session)).getClass(test));
final Map<String, String> metadata = new S3MetadataFeature(session, new S3AccessControlListFeature(session)).getMetadata(test);
assertFalse(metadata.isEmpty());
assertEquals("text/plain", metadata.get("Content-Type"));
new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
local.delete();
}
Expand All @@ -95,7 +92,6 @@ public void testUploadSinglePartUsEast() throws Exception {
IOUtils.write(random, local.getOutputStream(false));
final TransferStatus status = new TransferStatus();
status.setLength(random.length);
status.setMime("text/plain");
status.setStorageClass(S3Object.STORAGE_CLASS_REDUCED_REDUNDANCY);
final BytecountStreamListener count = new BytecountStreamListener();
service.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED),
Expand All @@ -107,8 +103,6 @@ public void testUploadSinglePartUsEast() throws Exception {
assertEquals(random.length, attributes.getSize());
assertEquals(S3Object.STORAGE_CLASS_REDUCED_REDUNDANCY, new S3StorageClassFeature(session, new S3AccessControlListFeature(session)).getClass(test));
final Map<String, String> metadata = new S3MetadataFeature(session, new S3AccessControlListFeature(session)).getMetadata(test);
assertFalse(metadata.isEmpty());
assertEquals("text/plain", metadata.get("Content-Type"));
new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
local.delete();
}
Expand Down

0 comments on commit f8b4b03

Please sign in to comment.