2016-01-12 20:25:00 +00:00
|
|
|
/*
|
2021-03-29 12:04:28 +00:00
|
|
|
* Copyright 2014-2021 Andrew Gaul <andrew@gaul.org>
|
2016-01-12 20:25:00 +00:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
2019-05-20 00:30:27 +00:00
|
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
2016-01-12 20:25:00 +00:00
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.gaul.s3proxy;
|
|
|
|
|
2016-01-24 21:48:32 +00:00
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
2016-01-12 20:25:00 +00:00
|
|
|
import java.io.IOException;
|
|
|
|
import java.net.URI;
|
|
|
|
import java.net.URL;
|
|
|
|
import java.util.Properties;
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import java.util.concurrent.TimeoutException;
|
|
|
|
|
|
|
|
import com.google.common.util.concurrent.Uninterruptibles;
|
|
|
|
|
2016-01-24 21:48:32 +00:00
|
|
|
import org.assertj.core.api.Fail;
|
2016-01-12 20:25:00 +00:00
|
|
|
import org.jclouds.Constants;
|
2016-01-24 21:48:32 +00:00
|
|
|
import org.jclouds.aws.AWSResponseException;
|
2016-01-12 20:25:00 +00:00
|
|
|
import org.jclouds.blobstore.BlobStoreContext;
|
|
|
|
import org.jclouds.s3.S3ClientLiveTest;
|
2016-01-31 02:27:11 +00:00
|
|
|
import org.jclouds.s3.domain.S3Object;
|
2017-03-12 23:55:49 +00:00
|
|
|
import org.jclouds.s3.reference.S3Constants;
|
2016-01-12 20:25:00 +00:00
|
|
|
import org.testng.SkipException;
|
2024-02-25 08:39:15 +00:00
|
|
|
import org.testng.annotations.AfterSuite;
|
2016-01-12 20:25:00 +00:00
|
|
|
import org.testng.annotations.Test;
|
|
|
|
|
|
|
|
@Test(testName = "JcloudsS3ClientLiveTest")
|
|
|
|
public final class JcloudsS3ClientLiveTest extends S3ClientLiveTest {
|
|
|
|
protected static final int AWAIT_CONSISTENCY_TIMEOUT_SECONDS =
|
|
|
|
Integer.parseInt(
|
|
|
|
System.getProperty(
|
|
|
|
"test.blobstore.await-consistency-timeout-seconds",
|
|
|
|
"0"));
|
|
|
|
private S3Proxy s3Proxy;
|
|
|
|
private BlobStoreContext context;
|
2016-01-31 02:45:45 +00:00
|
|
|
private String blobStoreType;
|
2016-01-12 20:25:00 +00:00
|
|
|
|
2024-02-25 08:39:15 +00:00
|
|
|
@AfterSuite
|
|
|
|
@Override
|
|
|
|
public void destroyResources() throws Exception {
|
2023-09-19 11:56:18 +00:00
|
|
|
context.close();
|
2024-02-25 08:39:15 +00:00
|
|
|
s3Proxy.stop();
|
2016-01-12 20:25:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void awaitConsistency() {
|
|
|
|
Uninterruptibles.sleepUninterruptibly(
|
|
|
|
AWAIT_CONSISTENCY_TIMEOUT_SECONDS, TimeUnit.SECONDS);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Properties setupProperties() {
|
|
|
|
TestUtils.S3ProxyLaunchInfo info;
|
|
|
|
try {
|
2018-01-09 06:33:46 +00:00
|
|
|
info = TestUtils.startS3Proxy("s3proxy.conf");
|
2016-01-12 20:25:00 +00:00
|
|
|
s3Proxy = info.getS3Proxy();
|
|
|
|
context = info.getBlobStore().getContext();
|
2016-01-31 02:45:45 +00:00
|
|
|
blobStoreType = context.unwrap().getProviderMetadata().getId();
|
2016-01-12 20:25:00 +00:00
|
|
|
} catch (Exception e) {
|
2017-01-20 06:37:22 +00:00
|
|
|
throw new RuntimeException(e);
|
2016-01-12 20:25:00 +00:00
|
|
|
}
|
|
|
|
Properties props = super.setupProperties();
|
|
|
|
props.setProperty(Constants.PROPERTY_IDENTITY, info.getS3Identity());
|
|
|
|
props.setProperty(Constants.PROPERTY_CREDENTIAL,
|
|
|
|
info.getS3Credential());
|
|
|
|
props.setProperty(Constants.PROPERTY_ENDPOINT,
|
2017-03-12 23:55:49 +00:00
|
|
|
info.getEndpoint().toString() + info.getServicePath());
|
2016-01-12 20:25:00 +00:00
|
|
|
props.setProperty(Constants.PROPERTY_STRIP_EXPECT_HEADER, "true");
|
2017-03-12 23:55:49 +00:00
|
|
|
props.setProperty(S3Constants.PROPERTY_S3_SERVICE_PATH,
|
|
|
|
info.getServicePath());
|
|
|
|
endpoint = info.getEndpoint().toString() + info.getServicePath();
|
2016-01-12 20:25:00 +00:00
|
|
|
return props;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Test
|
|
|
|
public void testPublicWriteOnObject() throws InterruptedException,
|
2016-11-14 08:58:02 +00:00
|
|
|
ExecutionException, TimeoutException, IOException {
|
2016-01-24 21:48:32 +00:00
|
|
|
try {
|
|
|
|
super.testPublicWriteOnObject();
|
|
|
|
Fail.failBecauseExceptionWasNotThrown(AWSResponseException.class);
|
|
|
|
} catch (AWSResponseException are) {
|
|
|
|
assertThat(are.getError().getCode()).isEqualTo("NotImplemented");
|
|
|
|
throw new SkipException("public-read-write-acl not supported", are);
|
|
|
|
}
|
2016-01-12 20:25:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Test
|
|
|
|
public void testUpdateObjectACL() throws InterruptedException,
|
2016-11-14 08:58:02 +00:00
|
|
|
ExecutionException, TimeoutException, IOException {
|
2016-01-24 21:48:32 +00:00
|
|
|
try {
|
|
|
|
super.testUpdateObjectACL();
|
|
|
|
Fail.failBecauseExceptionWasNotThrown(AWSResponseException.class);
|
|
|
|
} catch (AWSResponseException are) {
|
|
|
|
assertThat(are.getError().getCode()).isEqualTo("NotImplemented");
|
|
|
|
throw new SkipException("XML ACLs not supported", are);
|
|
|
|
}
|
2016-01-12 20:25:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// work around bucket-in-host and port 80 assumptions
|
|
|
|
@Override
|
|
|
|
protected URL getObjectURL(String containerName, String key)
|
|
|
|
throws Exception {
|
|
|
|
return new URL(String.format("%s/%s/%s", URI.create(endpoint),
|
|
|
|
containerName, key));
|
|
|
|
}
|
2016-01-31 02:45:45 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void testPutCannedAccessPolicyPublic() throws Exception {
|
|
|
|
if (Quirks.NO_BLOB_ACCESS_CONTROL.contains(blobStoreType)) {
|
|
|
|
throw new SkipException("blob access control not supported");
|
|
|
|
}
|
|
|
|
super.testPutCannedAccessPolicyPublic();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void testCopyCannedAccessPolicyPublic() throws Exception {
|
|
|
|
if (Quirks.NO_BLOB_ACCESS_CONTROL.contains(blobStoreType)) {
|
|
|
|
throw new SkipException("blob access control not supported");
|
|
|
|
}
|
|
|
|
super.testCopyCannedAccessPolicyPublic();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void testPublicReadOnObject()
|
|
|
|
throws InterruptedException, ExecutionException, TimeoutException,
|
|
|
|
IOException {
|
|
|
|
if (Quirks.NO_BLOB_ACCESS_CONTROL.contains(blobStoreType)) {
|
|
|
|
throw new SkipException("blob access control not supported");
|
|
|
|
}
|
|
|
|
super.testPublicReadOnObject();
|
|
|
|
}
|
|
|
|
|
2016-01-31 02:27:11 +00:00
|
|
|
@Override
|
|
|
|
public void testCopyIfNoneMatch()
|
|
|
|
throws IOException, InterruptedException, ExecutionException,
|
|
|
|
TimeoutException {
|
|
|
|
if (Quirks.NO_COPY_IF_NONE_MATCH.contains(blobStoreType)) {
|
|
|
|
throw new SkipException("copy If-None-Match not supported");
|
|
|
|
}
|
|
|
|
super.testCopyIfNoneMatch();
|
|
|
|
}
|
|
|
|
|
2016-01-31 02:45:45 +00:00
|
|
|
@Override
|
|
|
|
public void testUpdateObjectCannedACL() throws Exception {
|
|
|
|
if (Quirks.NO_BLOB_ACCESS_CONTROL.contains(blobStoreType)) {
|
|
|
|
throw new SkipException("blob access control not supported");
|
|
|
|
}
|
|
|
|
super.testUpdateObjectCannedACL();
|
|
|
|
}
|
2016-01-31 02:27:11 +00:00
|
|
|
|
2016-06-14 21:25:42 +00:00
|
|
|
@Override
|
|
|
|
public void testListMultipartUploads() throws Exception {
|
|
|
|
if (Quirks.NO_LIST_MULTIPART_UPLOADS.contains(blobStoreType)) {
|
|
|
|
throw new SkipException("list multipart uploads not supported");
|
|
|
|
}
|
|
|
|
super.testListMultipartUploads();
|
|
|
|
}
|
|
|
|
|
2016-01-31 02:27:11 +00:00
|
|
|
@Override
|
|
|
|
protected void assertCacheControl(S3Object newObject, String string) {
|
|
|
|
if (Quirks.NO_CACHE_CONTROL_SUPPORT.contains(blobStoreType)) {
|
|
|
|
throw new SkipException("cache control not supported");
|
|
|
|
}
|
|
|
|
super.assertCacheControl(newObject, string);
|
|
|
|
}
|
2016-01-12 20:25:00 +00:00
|
|
|
}
|