mirror of https://github.com/apache/jclouds.git
Revert "Parse Swift authentication headers case-insensitively"
Missing JIRA issue number.
This reverts commit e532e6f260
.
This commit is contained in:
parent
e532e6f260
commit
5d3b293b69
|
@ -20,6 +20,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import static org.jclouds.http.HttpUtils.releasePayload;
|
||||
import static org.jclouds.http.Uris.uriBuilder;
|
||||
import static org.jclouds.openstack.reference.AuthHeaders.AUTH_TOKEN;
|
||||
import static org.jclouds.openstack.reference.AuthHeaders.URL_SUFFIX;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map.Entry;
|
||||
|
@ -30,7 +31,6 @@ import org.jclouds.http.HttpRequest;
|
|||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.openstack.domain.AuthenticationResponse;
|
||||
import org.jclouds.openstack.reference.AuthHeaders;
|
||||
import org.jclouds.rest.InvocationContext;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
@ -58,14 +58,8 @@ public class ParseAuthenticationResponseFromHeaders implements Function<HttpResp
|
|||
// HTTP headers are case insensitive (RFC 2616) so we must allow for that when looking an header names for the URL keyword
|
||||
Builder<String, URI> builder = ImmutableMap.builder();
|
||||
for (Entry<String, String> entry : from.getHeaders().entries()) {
|
||||
String header = entry.getKey();
|
||||
if (header.equalsIgnoreCase(AuthHeaders.STORAGE_URL)) {
|
||||
builder.put(AuthHeaders.STORAGE_URL, getURI(entry.getValue()));
|
||||
} else if (header.equalsIgnoreCase(AuthHeaders.SERVER_MANAGEMENT_URL)) {
|
||||
builder.put(AuthHeaders.SERVER_MANAGEMENT_URL, getURI(entry.getValue()));
|
||||
} else if (header.equalsIgnoreCase(AuthHeaders.CDN_MANAGEMENT_URL)) {
|
||||
builder.put(AuthHeaders.CDN_MANAGEMENT_URL, getURI(entry.getValue()));
|
||||
}
|
||||
if (entry.getKey().toLowerCase().endsWith(URL_SUFFIX.toLowerCase()))
|
||||
builder.put(entry.getKey(), getURI(entry.getValue()));
|
||||
}
|
||||
AuthenticationResponse response = new AuthenticationResponse(checkNotNull(from.getFirstHeaderOrNull(AUTH_TOKEN),
|
||||
AUTH_TOKEN), builder.build());
|
||||
|
|
|
@ -23,9 +23,9 @@ import java.net.URI;
|
|||
import org.jclouds.Constants;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.openstack.domain.AuthenticationResponse;
|
||||
import org.jclouds.openstack.reference.AuthHeaders;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
@ -53,16 +53,11 @@ public class ParseAuthenticationResponseFromHeadersTest {
|
|||
HttpResponse response = HttpResponse.builder().statusCode(204).message("No Content")
|
||||
.addHeader("X-Auth-Token", "token")
|
||||
.addHeader("X-Storage-Token", "token")
|
||||
.addHeader("X-Storage-Url", "http://127.0.0.1:8080/v1/token")
|
||||
.addHeader("X-CDN-Management-Url", "http://127.0.0.1:8080/cdn-mgmt")
|
||||
.addHeader("X-Server-Management-Url", "http://127.0.0.1:8080/srv-mgmt")
|
||||
.build();
|
||||
.addHeader("X-Storage-Url", "http://127.0.0.1:8080/v1/token").build();
|
||||
|
||||
AuthenticationResponse md = parser.apply(response);
|
||||
assertEquals(md.getAuthToken(), "token");
|
||||
assertEquals(md.getServices().get(AuthHeaders.STORAGE_URL), URI.create("http://fooman:8080/v1/token"));
|
||||
assertEquals(md.getServices().get(AuthHeaders.CDN_MANAGEMENT_URL), URI.create("http://fooman:8080/cdn-mgmt"));
|
||||
assertEquals(md.getServices().get(AuthHeaders.SERVER_MANAGEMENT_URL), URI.create("http://fooman:8080/srv-mgmt"));
|
||||
assertEquals(md, new AuthenticationResponse("token", ImmutableMap.<String, URI> of("X-Storage-Url",
|
||||
URI.create("http://fooman:8080/v1/token"))));
|
||||
}
|
||||
|
||||
public void testHandleHeadersCaseInsensitively() {
|
||||
|
@ -72,14 +67,9 @@ public class ParseAuthenticationResponseFromHeadersTest {
|
|||
HttpResponse response = HttpResponse.builder().statusCode(204).message("No Content")
|
||||
.addHeader("x-auth-token", "token")
|
||||
.addHeader("x-storage-token", "token")
|
||||
.addHeader("x-storage-url", "http://127.0.0.1:8080/v1/token")
|
||||
.addHeader("x-cdn-management-url", "http://127.0.0.1:8080/cdn-mgmt")
|
||||
.addHeader("x-server-management-url", "http://127.0.0.1:8080/srv-mgmt")
|
||||
.build();
|
||||
.addHeader("x-storage-url", "http://127.0.0.1:8080/v1/token").build();
|
||||
AuthenticationResponse md = parser.apply(response);
|
||||
assertEquals(md.getAuthToken(), "token");
|
||||
assertEquals(md.getServices().get(AuthHeaders.STORAGE_URL), URI.create("http://fooman:8080/v1/token"));
|
||||
assertEquals(md.getServices().get(AuthHeaders.CDN_MANAGEMENT_URL), URI.create("http://fooman:8080/cdn-mgmt"));
|
||||
assertEquals(md.getServices().get(AuthHeaders.SERVER_MANAGEMENT_URL), URI.create("http://fooman:8080/srv-mgmt"));
|
||||
assertEquals(md, new AuthenticationResponse("token", ImmutableMap.<String, URI> of("x-storage-url",
|
||||
URI.create("http://fooman:8080/v1/token"))));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue