roded commented on a change in pull request #43: JCLOUDS-1511: allow configuration of S3 to use V4 signatures URL: https://github.com/apache/jclouds/pull/43#discussion_r319734878
########## File path: apis/s3/src/test/java/org/jclouds/s3/config/S3HttpApiModuleTest.java ########## @@ -0,0 +1,63 @@ +package org.jclouds.s3.config; + +import com.google.common.collect.ImmutableList; +import com.google.common.io.ByteSource; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.Module; +import com.google.inject.name.Names; +import org.jclouds.location.config.LocationModule; +import org.jclouds.logging.config.NullLoggingModule; +import org.jclouds.providers.JcloudsTestBlobStoreProviderMetadata; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.config.CredentialStoreModule; +import org.jclouds.rest.internal.BaseRestApiTest; +import org.jclouds.s3.blobstore.config.S3BlobStoreContextModule; +import org.jclouds.s3.filters.RequestAuthorizeSignature; +import org.jclouds.s3.filters.RequestAuthorizeSignatureV2; +import org.jclouds.s3.filters.RequestAuthorizeSignatureV4; +import org.testng.annotations.Test; + +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; + +import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; +import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_V4_REQUEST_SIGNATURES; +import static org.testng.Assert.assertTrue; + +/** + * @author roded + */ +public class S3HttpApiModuleTest { + + @Test + public void testRequestAuthorizeSignatureV2() { + RequestAuthorizeSignature requestAuthorizeSignature = getRequestAuthorizeSignature("false"); + assertTrue(requestAuthorizeSignature instanceof RequestAuthorizeSignatureV2); + } + + @Test + public void testRequestAuthorizeSignatureV4() { + RequestAuthorizeSignature requestAuthorizeSignature = getRequestAuthorizeSignature("true"); + assertTrue(requestAuthorizeSignature instanceof RequestAuthorizeSignatureV4); + } + + private RequestAuthorizeSignature getRequestAuthorizeSignature(final String s3V4Value) { + AbstractModule abstractModule = new AbstractModule() { + @Override + protected void configure() { + bindConstant().annotatedWith(Names.named(PROPERTY_S3_V4_REQUEST_SIGNATURES)).to(s3V4Value); + bind(String.class).annotatedWith(Names.named(PROPERTY_SESSION_INTERVAL)).toInstance("60"); + bind(ProviderMetadata.class).to(JcloudsTestBlobStoreProviderMetadata.class); + } + }; + List<Module> modules = ImmutableList.<Module>of(new BaseRestApiTest.MockModule(), + new CredentialStoreModule(new ConcurrentHashMap<String, ByteSource>()), + new S3BlobStoreContextModule(), + new NullLoggingModule(), + new S3HttpApiModule<>(), + new LocationModule(), + abstractModule); + return Guice.createInjector(modules).getInstance(RequestAuthorizeSignature.class); + } +} Review comment: This does not yet work. Other dependencies are missing: ``` com.google.inject.CreationException: Guice creation errors: 1) No implementation for com.google.common.base.Supplier<org.jclouds.domain.Credentials> annotated with @org.jclouds.location.Provider() was bound. while locating com.google.common.base.Supplier<org.jclouds.domain.Credentials> annotated with @org.jclouds.location.Provider() for parameter 1 at org.jclouds.rest.internal.RestAnnotationProcessor.<init>(RestAnnotationProcessor.java:137) while locating org.jclouds.rest.internal.RestAnnotationProcessor for parameter 0 at org.jclouds.s3.blobstore.S3BlobRequestSigner.<init>(S3BlobRequestSigner.java:61) at org.jclouds.s3.blobstore.config.S3BlobStoreContextModule.bindRequestSigner(S3BlobStoreContextModule.java:55) ... ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services