mirror of https://github.com/apache/jclouds.git
fixed case on RackSpace should be Rackspace
git-svn-id: http://jclouds.googlecode.com/svn/trunk@1629 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
bdd0cf3b22
commit
78573da3d0
|
@ -24,14 +24,14 @@
|
||||||
package org.jclouds.rackspace.cloudfiles.reference;
|
package org.jclouds.rackspace.cloudfiles.reference;
|
||||||
|
|
||||||
import org.jclouds.objectstore.reference.ObjectStoreConstants;
|
import org.jclouds.objectstore.reference.ObjectStoreConstants;
|
||||||
import org.jclouds.rackspace.reference.RackSpaceConstants;
|
import org.jclouds.rackspace.reference.RackspaceConstants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration properties and constants used in Cloud Files connections.
|
* Configuration properties and constants used in Cloud Files connections.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public interface CloudFilesConstants extends ObjectStoreConstants, RackSpaceConstants {
|
public interface CloudFilesConstants extends ObjectStoreConstants, RackspaceConstants {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ import org.jclouds.http.HttpException;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpRequestFilter;
|
import org.jclouds.http.HttpRequestFilter;
|
||||||
import org.jclouds.rackspace.Authentication;
|
import org.jclouds.rackspace.Authentication;
|
||||||
import org.jclouds.rackspace.reference.RackSpaceHeaders;
|
import org.jclouds.rackspace.reference.RackspaceHeaders;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
@ -89,7 +89,7 @@ public class AuthenticateRequest implements HttpRequestFilter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void filter(HttpRequest request) throws HttpException {
|
public void filter(HttpRequest request) throws HttpException {
|
||||||
request.getHeaders().replaceValues(RackSpaceHeaders.AUTH_TOKEN,
|
request.getHeaders().replaceValues(RackspaceHeaders.AUTH_TOKEN,
|
||||||
Collections.singletonList(getAuthToken()));
|
Collections.singletonList(getAuthToken()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ import javax.ws.rs.HeaderParam;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
|
|
||||||
import org.jclouds.rackspace.functions.ParseAuthenticationResponseFromHeaders;
|
import org.jclouds.rackspace.functions.ParseAuthenticationResponseFromHeaders;
|
||||||
import org.jclouds.rackspace.reference.RackSpaceHeaders;
|
import org.jclouds.rackspace.reference.RackspaceHeaders;
|
||||||
import org.jclouds.rest.ResponseParser;
|
import org.jclouds.rest.ResponseParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,7 +42,7 @@ import org.jclouds.rest.ResponseParser;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public interface RackSpaceAuthentication {
|
public interface RackspaceAuthentication {
|
||||||
|
|
||||||
public interface AuthenticationResponse {
|
public interface AuthenticationResponse {
|
||||||
@Storage
|
@Storage
|
||||||
|
@ -61,6 +61,6 @@ public interface RackSpaceAuthentication {
|
||||||
@GET
|
@GET
|
||||||
@ResponseParser(ParseAuthenticationResponseFromHeaders.class)
|
@ResponseParser(ParseAuthenticationResponseFromHeaders.class)
|
||||||
@Path("/auth")
|
@Path("/auth")
|
||||||
AuthenticationResponse authenticate(@HeaderParam(RackSpaceHeaders.AUTH_USER) String user,
|
AuthenticationResponse authenticate(@HeaderParam(RackspaceHeaders.AUTH_USER) String user,
|
||||||
@HeaderParam(RackSpaceHeaders.AUTH_KEY) String key);
|
@HeaderParam(RackspaceHeaders.AUTH_KEY) String key);
|
||||||
}
|
}
|
|
@ -34,8 +34,8 @@ import static org.jclouds.http.pool.PoolConstants.PROPERTY_POOL_MAX_CONNECTIONS;
|
||||||
import static org.jclouds.http.pool.PoolConstants.PROPERTY_POOL_MAX_CONNECTION_REUSE;
|
import static org.jclouds.http.pool.PoolConstants.PROPERTY_POOL_MAX_CONNECTION_REUSE;
|
||||||
import static org.jclouds.http.pool.PoolConstants.PROPERTY_POOL_MAX_SESSION_FAILURES;
|
import static org.jclouds.http.pool.PoolConstants.PROPERTY_POOL_MAX_SESSION_FAILURES;
|
||||||
import static org.jclouds.http.pool.PoolConstants.PROPERTY_POOL_REQUEST_INVOKER_THREADS;
|
import static org.jclouds.http.pool.PoolConstants.PROPERTY_POOL_REQUEST_INVOKER_THREADS;
|
||||||
import static org.jclouds.rackspace.reference.RackSpaceConstants.PROPERTY_RACKSPACE_KEY;
|
import static org.jclouds.rackspace.reference.RackspaceConstants.PROPERTY_RACKSPACE_KEY;
|
||||||
import static org.jclouds.rackspace.reference.RackSpaceConstants.PROPERTY_RACKSPACE_USER;
|
import static org.jclouds.rackspace.reference.RackspaceConstants.PROPERTY_RACKSPACE_USER;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.jclouds.rackspace.config;
|
package org.jclouds.rackspace.config;
|
||||||
|
|
||||||
import static org.jclouds.rackspace.reference.RackSpaceConstants.PROPERTY_RACKSPACE_KEY;
|
import static org.jclouds.rackspace.reference.RackspaceConstants.PROPERTY_RACKSPACE_KEY;
|
||||||
import static org.jclouds.rackspace.reference.RackSpaceConstants.PROPERTY_RACKSPACE_USER;
|
import static org.jclouds.rackspace.reference.RackspaceConstants.PROPERTY_RACKSPACE_USER;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
@ -10,10 +10,10 @@ import org.jclouds.http.HttpConstants;
|
||||||
import org.jclouds.http.RequiresHttp;
|
import org.jclouds.http.RequiresHttp;
|
||||||
import org.jclouds.rackspace.Authentication;
|
import org.jclouds.rackspace.Authentication;
|
||||||
import org.jclouds.rackspace.CDN;
|
import org.jclouds.rackspace.CDN;
|
||||||
import org.jclouds.rackspace.RackSpaceAuthentication;
|
import org.jclouds.rackspace.RackspaceAuthentication;
|
||||||
import org.jclouds.rackspace.Server;
|
import org.jclouds.rackspace.Server;
|
||||||
import org.jclouds.rackspace.Storage;
|
import org.jclouds.rackspace.Storage;
|
||||||
import org.jclouds.rackspace.RackSpaceAuthentication.AuthenticationResponse;
|
import org.jclouds.rackspace.RackspaceAuthentication.AuthenticationResponse;
|
||||||
import org.jclouds.rest.RestClientFactory;
|
import org.jclouds.rest.RestClientFactory;
|
||||||
import org.jclouds.rest.config.JaxrsModule;
|
import org.jclouds.rest.config.JaxrsModule;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public class RackspaceAuthenticationModule extends AbstractModule {
|
||||||
@Authentication URI authenticationUri, RestClientFactory factory,
|
@Authentication URI authenticationUri, RestClientFactory factory,
|
||||||
@Named(PROPERTY_RACKSPACE_USER) String user,
|
@Named(PROPERTY_RACKSPACE_USER) String user,
|
||||||
@Named(PROPERTY_RACKSPACE_KEY) String key) {
|
@Named(PROPERTY_RACKSPACE_KEY) String key) {
|
||||||
return factory.create(authenticationUri, RackSpaceAuthentication.class).authenticate(user,
|
return factory.create(authenticationUri, RackspaceAuthentication.class).authenticate(user,
|
||||||
key);
|
key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public class RackspaceAuthenticationModule extends AbstractModule {
|
||||||
RestClientFactory factory,
|
RestClientFactory factory,
|
||||||
@Named(PROPERTY_RACKSPACE_USER) String user,
|
@Named(PROPERTY_RACKSPACE_USER) String user,
|
||||||
@Named(PROPERTY_RACKSPACE_KEY) String key) {
|
@Named(PROPERTY_RACKSPACE_KEY) String key) {
|
||||||
return factory.create(authenticationUri, RackSpaceAuthentication.class).authenticate(user,
|
return factory.create(authenticationUri, RackspaceAuthentication.class).authenticate(user,
|
||||||
key).getAuthToken();
|
key).getAuthToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,15 +24,15 @@
|
||||||
package org.jclouds.rackspace.functions;
|
package org.jclouds.rackspace.functions;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.rackspace.reference.RackSpaceHeaders.AUTH_TOKEN;
|
import static org.jclouds.rackspace.reference.RackspaceHeaders.AUTH_TOKEN;
|
||||||
import static org.jclouds.rackspace.reference.RackSpaceHeaders.CDN_MANAGEMENT_URL;
|
import static org.jclouds.rackspace.reference.RackspaceHeaders.CDN_MANAGEMENT_URL;
|
||||||
import static org.jclouds.rackspace.reference.RackSpaceHeaders.SERVER_MANAGEMENT_URL;
|
import static org.jclouds.rackspace.reference.RackspaceHeaders.SERVER_MANAGEMENT_URL;
|
||||||
import static org.jclouds.rackspace.reference.RackSpaceHeaders.STORAGE_URL;
|
import static org.jclouds.rackspace.reference.RackspaceHeaders.STORAGE_URL;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.rackspace.RackSpaceAuthentication.AuthenticationResponse;
|
import org.jclouds.rackspace.RackspaceAuthentication.AuthenticationResponse;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
|
|
|
@ -24,11 +24,11 @@
|
||||||
package org.jclouds.rackspace.reference;
|
package org.jclouds.rackspace.reference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration properties and constants used in RackSpace connections.
|
* Configuration properties and constants used in Rackspace connections.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public interface RackSpaceConstants {
|
public interface RackspaceConstants {
|
||||||
public static final String PROPERTY_RACKSPACE_USER = "jclouds.rackspace.user";
|
public static final String PROPERTY_RACKSPACE_USER = "jclouds.rackspace.user";
|
||||||
public static final String PROPERTY_RACKSPACE_KEY = "jclouds.rackspace.key";
|
public static final String PROPERTY_RACKSPACE_KEY = "jclouds.rackspace.key";
|
||||||
}
|
}
|
|
@ -7,7 +7,7 @@ package org.jclouds.rackspace.reference;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface RackSpaceHeaders {
|
public interface RackspaceHeaders {
|
||||||
|
|
||||||
public static final String AUTH_USER = "X-Auth-User";
|
public static final String AUTH_USER = "X-Auth-User";
|
||||||
public static final String AUTH_KEY = "X-Auth-Key";
|
public static final String AUTH_KEY = "X-Auth-Key";
|
|
@ -23,8 +23,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rackspace;
|
package org.jclouds.rackspace;
|
||||||
|
|
||||||
import static org.jclouds.rackspace.reference.RackSpaceConstants.PROPERTY_RACKSPACE_KEY;
|
import static org.jclouds.rackspace.reference.RackspaceConstants.PROPERTY_RACKSPACE_KEY;
|
||||||
import static org.jclouds.rackspace.reference.RackSpaceConstants.PROPERTY_RACKSPACE_USER;
|
import static org.jclouds.rackspace.reference.RackspaceConstants.PROPERTY_RACKSPACE_USER;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
import static org.testng.Assert.fail;
|
import static org.testng.Assert.fail;
|
||||||
|
@ -36,8 +36,8 @@ import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||||
import org.jclouds.http.HttpResponseException;
|
import org.jclouds.http.HttpResponseException;
|
||||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||||
import org.jclouds.rackspace.RackSpaceAuthentication;
|
import org.jclouds.rackspace.RackspaceAuthentication;
|
||||||
import org.jclouds.rackspace.RackSpaceAuthentication.AuthenticationResponse;
|
import org.jclouds.rackspace.RackspaceAuthentication.AuthenticationResponse;
|
||||||
import org.jclouds.rest.RestClientFactory;
|
import org.jclouds.rest.RestClientFactory;
|
||||||
import org.jclouds.rest.config.JaxrsModule;
|
import org.jclouds.rest.config.JaxrsModule;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
|
@ -54,8 +54,8 @@ import com.google.inject.Singleton;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "rackspace.RackSpaceAuthenticationLiveTest")
|
@Test(groups = "live", testName = "rackspace.RackspaceAuthenticationLiveTest")
|
||||||
public class RackSpaceAuthenticationLiveTest {
|
public class RackspaceAuthenticationLiveTest {
|
||||||
|
|
||||||
protected static final String sysRackspaceUser = System.getProperty(PROPERTY_RACKSPACE_USER);
|
protected static final String sysRackspaceUser = System.getProperty(PROPERTY_RACKSPACE_USER);
|
||||||
protected static final String sysRackspaceKey = System.getProperty(PROPERTY_RACKSPACE_KEY);
|
protected static final String sysRackspaceKey = System.getProperty(PROPERTY_RACKSPACE_KEY);
|
||||||
|
@ -63,8 +63,8 @@ public class RackSpaceAuthenticationLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAuthentication() throws Exception {
|
public void testAuthentication() throws Exception {
|
||||||
RackSpaceAuthentication authentication = injector
|
RackspaceAuthentication authentication = injector
|
||||||
.getInstance(RackSpaceAuthentication.class);
|
.getInstance(RackspaceAuthentication.class);
|
||||||
AuthenticationResponse response = authentication.authenticate(sysRackspaceUser,
|
AuthenticationResponse response = authentication.authenticate(sysRackspaceUser,
|
||||||
sysRackspaceKey);
|
sysRackspaceKey);
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
|
@ -76,8 +76,8 @@ public class RackSpaceAuthenticationLiveTest {
|
||||||
|
|
||||||
@Test(expectedExceptions = HttpResponseException.class)
|
@Test(expectedExceptions = HttpResponseException.class)
|
||||||
public void testBadAuthentication() throws Exception {
|
public void testBadAuthentication() throws Exception {
|
||||||
RackSpaceAuthentication authentication = injector
|
RackspaceAuthentication authentication = injector
|
||||||
.getInstance(RackSpaceAuthentication.class);
|
.getInstance(RackspaceAuthentication.class);
|
||||||
try {
|
try {
|
||||||
authentication.authenticate("foo", "bar");
|
authentication.authenticate("foo", "bar");
|
||||||
} catch (UndeclaredThrowableException e) {
|
} catch (UndeclaredThrowableException e) {
|
||||||
|
@ -98,10 +98,10 @@ public class RackSpaceAuthenticationLiveTest {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected RackSpaceAuthentication provideCloudFilesAuthentication(
|
protected RackspaceAuthentication provideCloudFilesAuthentication(
|
||||||
RestClientFactory factory) {
|
RestClientFactory factory) {
|
||||||
return factory.create(URI.create("https://api.mosso.com"),
|
return factory.create(URI.create("https://api.mosso.com"),
|
||||||
RackSpaceAuthentication.class);
|
RackspaceAuthentication.class);
|
||||||
}
|
}
|
||||||
}, new JaxrsModule(), new ExecutorServiceModule(new WithinThreadExecutorService()),
|
}, new JaxrsModule(), new ExecutorServiceModule(new WithinThreadExecutorService()),
|
||||||
new JavaUrlHttpCommandExecutorServiceModule());
|
new JavaUrlHttpCommandExecutorServiceModule());
|
|
@ -35,7 +35,7 @@ import org.jclouds.http.HttpMethod;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||||
import org.jclouds.rackspace.functions.ParseAuthenticationResponseFromHeaders;
|
import org.jclouds.rackspace.functions.ParseAuthenticationResponseFromHeaders;
|
||||||
import org.jclouds.rackspace.reference.RackSpaceHeaders;
|
import org.jclouds.rackspace.reference.RackspaceHeaders;
|
||||||
import org.jclouds.rest.JaxrsAnnotationProcessor;
|
import org.jclouds.rest.JaxrsAnnotationProcessor;
|
||||||
import org.jclouds.rest.config.JaxrsModule;
|
import org.jclouds.rest.config.JaxrsModule;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
|
@ -49,26 +49,26 @@ import com.google.inject.Guice;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "rackspace.RackSpaceAuthentication")
|
@Test(groups = "unit", testName = "rackspace.RackspaceAuthentication")
|
||||||
public class RackSpaceAuthenticationTest {
|
public class RackspaceAuthenticationTest {
|
||||||
|
|
||||||
JaxrsAnnotationProcessor.Factory factory;
|
JaxrsAnnotationProcessor.Factory factory;
|
||||||
|
|
||||||
public void testAuthenticate() throws SecurityException, NoSuchMethodException {
|
public void testAuthenticate() throws SecurityException, NoSuchMethodException {
|
||||||
Method method = RackSpaceAuthentication.class.getMethod("authenticate", String.class,
|
Method method = RackspaceAuthentication.class.getMethod("authenticate", String.class,
|
||||||
String.class);
|
String.class);
|
||||||
URI endpoint = URI.create("http://localhost");
|
URI endpoint = URI.create("http://localhost");
|
||||||
HttpRequest httpMethod = factory.create(RackSpaceAuthentication.class).createRequest(
|
HttpRequest httpMethod = factory.create(RackspaceAuthentication.class).createRequest(
|
||||||
endpoint, method, new Object[] { "foo", "bar" });
|
endpoint, method, new Object[] { "foo", "bar" });
|
||||||
assertEquals(httpMethod.getEndpoint().getHost(), "localhost");
|
assertEquals(httpMethod.getEndpoint().getHost(), "localhost");
|
||||||
assertEquals(httpMethod.getEndpoint().getPath(), "/auth");
|
assertEquals(httpMethod.getEndpoint().getPath(), "/auth");
|
||||||
assertEquals(httpMethod.getMethod(), HttpMethod.GET);
|
assertEquals(httpMethod.getMethod(), HttpMethod.GET);
|
||||||
assertEquals(httpMethod.getHeaders().size(), 2);
|
assertEquals(httpMethod.getHeaders().size(), 2);
|
||||||
assertEquals(httpMethod.getHeaders().get(RackSpaceHeaders.AUTH_USER), Collections
|
assertEquals(httpMethod.getHeaders().get(RackspaceHeaders.AUTH_USER), Collections
|
||||||
.singletonList("foo"));
|
.singletonList("foo"));
|
||||||
assertEquals(httpMethod.getHeaders().get(RackSpaceHeaders.AUTH_KEY), Collections
|
assertEquals(httpMethod.getHeaders().get(RackspaceHeaders.AUTH_KEY), Collections
|
||||||
.singletonList("bar"));
|
.singletonList("bar"));
|
||||||
factory.create(RackSpaceAuthentication.class);
|
factory.create(RackspaceAuthentication.class);
|
||||||
assertEquals(JaxrsAnnotationProcessor.getParserOrThrowException(method),
|
assertEquals(JaxrsAnnotationProcessor.getParserOrThrowException(method),
|
||||||
ParseAuthenticationResponseFromHeaders.class);
|
ParseAuthenticationResponseFromHeaders.class);
|
||||||
|
|
Loading…
Reference in New Issue