From d29fbba78357e314263d40fdb0f7984e3ee69ff7 Mon Sep 17 00:00:00 2001 From: Adrian Cole <adrian@jclouds.org> Date: Fri, 15 Jun 2012 16:41:21 -0400 Subject: [PATCH] Issue 980: timestamp on ec2 requests are in the future --- .../org/jclouds/cloudwatch/CloudWatchAsyncClientTest.java | 6 +----- .../cloudwatch/internal/BaseCloudWatchExpectTest.java | 6 +----- .../ec2/compute/BaseEC2ComputeServiceExpectTest.java | 3 +-- .../org/jclouds/ec2/services/BaseEC2AsyncClientTest.java | 2 +- .../nova/ec2/internal/BaseNovaEC2RestClientExpectTest.java | 5 +---- .../jclouds/aws/config/FormSigningRestClientModule.java | 7 ++----- .../src/test/java/org/jclouds/elb/ELBAsyncClientTest.java | 6 +----- .../aws/ec2/services/BaseAWSEC2AsyncClientTest.java | 2 +- 8 files changed, 9 insertions(+), 28 deletions(-) diff --git a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchAsyncClientTest.java b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchAsyncClientTest.java index d313ccd9b7..8f730d6674 100644 --- a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchAsyncClientTest.java +++ b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchAsyncClientTest.java @@ -27,9 +27,6 @@ import java.net.URI; import java.util.Date; import java.util.Map; -import javax.inject.Named; - -import org.jclouds.Constants; import org.jclouds.apis.ApiMetadata; import org.jclouds.aws.domain.Region; import org.jclouds.aws.filters.FormSigner; @@ -111,8 +108,7 @@ public class CloudWatchAsyncClientTest extends BaseAsyncClientTest<CloudWatchAsy } @Override - protected String provideTimeStamp(final DateService dateService, - @Named(Constants.PROPERTY_SESSION_INTERVAL) int expiration) { + protected String provideTimeStamp(final DateService dateService) { return "2009-11-08T15:54:08.897Z"; } } diff --git a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/internal/BaseCloudWatchExpectTest.java b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/internal/BaseCloudWatchExpectTest.java index d4576ac55a..765f4237ec 100644 --- a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/internal/BaseCloudWatchExpectTest.java +++ b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/internal/BaseCloudWatchExpectTest.java @@ -23,9 +23,6 @@ import static com.google.common.collect.Maps.transformValues; import java.net.URI; import java.util.Map; -import javax.inject.Named; - -import org.jclouds.Constants; import org.jclouds.aws.domain.Region; import org.jclouds.cloudwatch.config.CloudWatchRestClientModule; import org.jclouds.date.DateService; @@ -69,8 +66,7 @@ public class BaseCloudWatchExpectTest<T> extends BaseRestClientExpectTest<T> { } @Override - protected String provideTimeStamp(final DateService dateService, - @Named(Constants.PROPERTY_SESSION_INTERVAL) int expiration) { + protected String provideTimeStamp(final DateService dateService) { return "2009-11-08T15:54:08.897Z"; } } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/BaseEC2ComputeServiceExpectTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/BaseEC2ComputeServiceExpectTest.java index f663fde11b..37867fb038 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/BaseEC2ComputeServiceExpectTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/BaseEC2ComputeServiceExpectTest.java @@ -59,8 +59,7 @@ public abstract class BaseEC2ComputeServiceExpectTest<T> extends BaseRestClientE private static final class TestEC2RestClientModule extends EC2RestClientModule<EC2Client, EC2AsyncClient> { @Override @Provides - protected String provideTimeStamp(final DateService dateService, - @Named(Constants.PROPERTY_SESSION_INTERVAL) final int expiration) { + protected String provideTimeStamp(DateService dateService) { return CONSTANT_DATE; } } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/BaseEC2AsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/BaseEC2AsyncClientTest.java index 2890eae3fc..39e689dae9 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/BaseEC2AsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/BaseEC2AsyncClientTest.java @@ -79,7 +79,7 @@ public abstract class BaseEC2AsyncClientTest<T> extends BaseAsyncClientTest<T> { } @Override - protected String provideTimeStamp(DateService dateService, int expiration) { + protected String provideTimeStamp(DateService dateService) { return "2009-11-08T15:54:08.897Z"; } diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/internal/BaseNovaEC2RestClientExpectTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/internal/BaseNovaEC2RestClientExpectTest.java index 69b7eed4b2..d1730d904d 100644 --- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/internal/BaseNovaEC2RestClientExpectTest.java +++ b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/internal/BaseNovaEC2RestClientExpectTest.java @@ -2,10 +2,8 @@ package org.jclouds.openstack.nova.ec2.internal; import java.net.URI; -import javax.inject.Named; import javax.ws.rs.core.MediaType; -import org.jclouds.Constants; import org.jclouds.date.DateService; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.http.HttpRequest; @@ -45,8 +43,7 @@ public abstract class BaseNovaEC2RestClientExpectTest extends BaseRestClientExpe private static final class TestNovaEC2RestClientModule extends NovaEC2RestClientModule { @Override @Provides - protected String provideTimeStamp(final DateService dateService, - @Named(Constants.PROPERTY_SESSION_INTERVAL) final int expiration) { + protected String provideTimeStamp(DateService dateService) { return CONSTANT_DATE; } } diff --git a/common/aws/src/main/java/org/jclouds/aws/config/FormSigningRestClientModule.java b/common/aws/src/main/java/org/jclouds/aws/config/FormSigningRestClientModule.java index 12b90f30da..761a292a8c 100644 --- a/common/aws/src/main/java/org/jclouds/aws/config/FormSigningRestClientModule.java +++ b/common/aws/src/main/java/org/jclouds/aws/config/FormSigningRestClientModule.java @@ -21,10 +21,8 @@ package org.jclouds.aws.config; import java.util.Date; import java.util.Map; -import javax.inject.Named; import javax.inject.Singleton; -import org.jclouds.Constants; import org.jclouds.aws.filters.FormSigner; import org.jclouds.date.DateService; import org.jclouds.date.TimeStamp; @@ -59,9 +57,8 @@ public abstract class FormSigningRestClientModule<S, A> extends AWSRestClientMod @Provides @TimeStamp - protected String provideTimeStamp(final DateService dateService, - @Named(Constants.PROPERTY_SESSION_INTERVAL) final int expiration) { - return dateService.iso8601DateFormat(new Date(System.currentTimeMillis() + (expiration * 1000))); + protected String provideTimeStamp(DateService dateService) { + return dateService.iso8601DateFormat(new Date(System.currentTimeMillis())); } @Provides diff --git a/labs/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java b/labs/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java index bd9a10a5e8..85486c1c32 100644 --- a/labs/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java +++ b/labs/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java @@ -23,9 +23,6 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.lang.reflect.Method; -import javax.inject.Named; - -import org.jclouds.Constants; import org.jclouds.apis.ApiMetadata; import org.jclouds.aws.filters.FormSigner; import org.jclouds.date.DateService; @@ -162,8 +159,7 @@ public class ELBAsyncClientTest extends BaseAsyncClientTest<ELBAsyncClient> { } @Override - protected String provideTimeStamp(final DateService dateService, - @Named(Constants.PROPERTY_SESSION_INTERVAL) int expiration) { + protected String provideTimeStamp(final DateService dateService) { return "2009-11-08T15:54:08.897Z"; } } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/BaseAWSEC2AsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/BaseAWSEC2AsyncClientTest.java index add38e4eca..b555713cca 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/BaseAWSEC2AsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/BaseAWSEC2AsyncClientTest.java @@ -64,7 +64,7 @@ public abstract class BaseAWSEC2AsyncClientTest<T> extends BaseAsyncClientTest<T protected static class StubAWSEC2RestClientModule extends AWSEC2RestClientModule { @Override - protected String provideTimeStamp(DateService dateService, int expiration) { + protected String provideTimeStamp(DateService dateService) { return "2009-11-08T15:54:08.897Z"; }