Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Nov 28, 2024
1 parent ccef8c6 commit 71cfff6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import ch.cyberduck.core.TestProtocol;
import ch.cyberduck.core.http.HttpConnectionPoolBuilder;
import ch.cyberduck.core.proxy.DisabledProxyFinder;
import ch.cyberduck.core.proxy.Proxy;
import ch.cyberduck.core.ssl.DefaultX509KeyManager;
import ch.cyberduck.core.ssl.DisabledX509TrustManager;
import ch.cyberduck.core.ssl.ThreadLocalHostnameDelegatingTrustManager;
Expand Down Expand Up @@ -76,7 +75,7 @@ public void testSetupConnectionVirtualHost() throws Exception {
final String key = new AlphanumericRandomStringService().random();
{
final HttpUriRequest request = service.setupConnection("GET", "", key, Collections.emptyMap());
assertEquals(String.format("https://test-eu-west-3-cyberduck.s3.amazonaws.com:443/%s", key), request.getURI().toString());
assertEquals(String.format("https://test-eu-central-1-cyberduck.s3.amazonaws.com:443/%s", key), request.getURI().toString());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ public void testVirtualHostStyle() throws Exception {

@Test(expected = NotfoundException.class)
public void testDetermineRegionVirtualHostStyle() throws Exception {
assertEquals("eu-west-3", virtualhost.getClient().getRegionEndpointCache().getRegionForBucketName(""));
assertEquals("eu-west-3", virtualhost.getClient().getRegionEndpointCache().getRegionForBucketName("test-eu-west-3-cyberduck"));
assertEquals("eu-central-1", virtualhost.getClient().getRegionEndpointCache().getRegionForBucketName(""));
assertEquals("eu-central-1", virtualhost.getClient().getRegionEndpointCache().getRegionForBucketName("test-eu-central-1-cyberduck"));
final S3AttributesFinderFeature f = new S3AttributesFinderFeature(virtualhost, new S3AccessControlListFeature(virtualhost));
final Path file = new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
// No region is cached and must be determined although HEAD request will not allow S3 to return correct region to use in AWS4 signature
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import ch.cyberduck.core.features.Location;
import ch.cyberduck.core.preferences.PreferencesFactory;
import ch.cyberduck.core.proxy.DisabledProxyFinder;
import ch.cyberduck.core.proxy.Proxy;
import ch.cyberduck.core.serializer.impl.dd.ProfilePlistReader;
import ch.cyberduck.test.IntegrationTest;

Expand Down Expand Up @@ -141,10 +140,10 @@ public String getProperty(final String key) {
@Test
public void testAccessBucketNameInHostname() throws Exception {
final RegionEndpointCache cache = virtualhost.getClient().getRegionEndpointCache();
assertEquals(new S3LocationFeature.S3Region("eu-west-3"), new S3LocationFeature(virtualhost, cache).getLocation(
assertEquals(new S3LocationFeature.S3Region("eu-central-1"), new S3LocationFeature(virtualhost, cache).getLocation(
new Path("/", EnumSet.of(Path.Type.directory))
));
assertEquals("eu-west-3", cache.getRegionForBucketName(""));
assertEquals("eu-central-1", cache.getRegionForBucketName(""));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ public void testCreateVirtualHost() throws Exception {
final Calendar expiry = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
expiry.add(Calendar.MILLISECOND, (int) TimeUnit.DAYS.toMillis(7));
final String url = new S3PresignedUrlProvider(virtualhost).create(System.getProperties().getProperty("s3.secret"),
"test-eu-west-3-cyberduck", "eu-west-3", "f", "GET", expiry.getTimeInMillis());
"test-eu-central-1-cyberduck", "eu-central-1", "f", "GET", expiry.getTimeInMillis());
assertNotNull(url);
assertEquals("test-eu-west-3-cyberduck.s3.amazonaws.com", URI.create(url).getHost());
assertTrue(url, url.startsWith("https://test-eu-west-3-cyberduck.s3.amazonaws.com/f"));
assertEquals("test-eu-central-1-cyberduck.s3.amazonaws.com", URI.create(url).getHost());
assertTrue(url, url.startsWith("https://test-eu-central-1-cyberduck.s3.amazonaws.com/f"));
}

@Test
Expand Down
4 changes: 1 addition & 3 deletions s3/src/test/java/ch/cyberduck/core/s3/S3UrlProviderTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ch.cyberduck.core.s3;

import ch.cyberduck.core.AbstractPath;
import ch.cyberduck.core.Credentials;
import ch.cyberduck.core.DescriptiveUrl;
import ch.cyberduck.core.DescriptiveUrlBag;
Expand All @@ -12,7 +11,6 @@
import ch.cyberduck.core.Path;
import ch.cyberduck.core.exception.BackgroundException;
import ch.cyberduck.core.proxy.DisabledProxyFinder;
import ch.cyberduck.core.proxy.Proxy;
import ch.cyberduck.test.IntegrationTest;

import org.junit.Test;
Expand Down Expand Up @@ -181,7 +179,7 @@ public String findLoginPassword(final Host bookmark) {
});
final String url = provider.toSignedUrl(new Path("/t", EnumSet.of(Path.Type.file)), 30).getUrl();
assertTrue(url, url.startsWith(
"https://test-eu-west-3-cyberduck.s3.amazonaws.com/t?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential="));
"https://test-eu-central-1-cyberduck.s3.amazonaws.com/t?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential="));
}

@Test
Expand Down

0 comments on commit 71cfff6

Please sign in to comment.