Use auth endpoint from named location instead of hardcoding Remove keystone references, sample location uses swift instead of swift-keystone provider.
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/431f0c47 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/431f0c47 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/431f0c47 Branch: refs/heads/master Commit: 431f0c4722c23f4b5bfdb2a776dade5d820a1bfc Parents: 0141dc9 Author: Svetoslav Neykov <[email protected]> Authored: Thu Feb 5 16:28:40 2015 +0200 Committer: Svetoslav Neykov <[email protected]> Committed: Tue Mar 17 22:02:49 2015 +0200 ---------------------------------------------------------------------- .../brooklyn/location/jclouds/JcloudsUtil.java | 2 +- .../persister/jclouds/BlobStoreExpiryTest.java | 22 +++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/431f0c47/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsUtil.java ---------------------------------------------------------------------- diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsUtil.java b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsUtil.java index eb0e605..b910e9f 100644 --- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsUtil.java +++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsUtil.java @@ -262,7 +262,7 @@ public class JcloudsUtil implements JcloudsLocationConfig { * <p> * (Marked Beta as that argument will likely be removed.) * - * @since 1.7.0 */ + * @since 0.7.0 */ @Beta public static BlobStoreContext newBlobstoreContext(String provider, @Nullable String endpoint, String identity, String credential) { Properties overrides = new Properties(); http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/431f0c47/locations/jclouds/src/test/java/brooklyn/entity/rebind/persister/jclouds/BlobStoreExpiryTest.java ---------------------------------------------------------------------- diff --git a/locations/jclouds/src/test/java/brooklyn/entity/rebind/persister/jclouds/BlobStoreExpiryTest.java b/locations/jclouds/src/test/java/brooklyn/entity/rebind/persister/jclouds/BlobStoreExpiryTest.java index 76618a5..3d98d20 100644 --- a/locations/jclouds/src/test/java/brooklyn/entity/rebind/persister/jclouds/BlobStoreExpiryTest.java +++ b/locations/jclouds/src/test/java/brooklyn/entity/rebind/persister/jclouds/BlobStoreExpiryTest.java @@ -21,8 +21,9 @@ package brooklyn.entity.rebind.persister.jclouds; import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.openstack.reference.AuthHeaders.URL_SUFFIX; -import java.io.IOException; import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; import java.util.List; import java.util.Map.Entry; @@ -59,7 +60,6 @@ import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; import com.google.inject.Inject; -import com.google.inject.Module; @Test(groups={"Live", "Live-sanity"}) public class BlobStoreExpiryTest { @@ -122,14 +122,14 @@ public class BlobStoreExpiryTest { context = null; } - public void testRenewAuthSucceedsWithOurOverride() throws IOException { + public void testRenewAuthSucceeds() throws Exception { doTestRenewAuth(); } - protected void doTestRenewAuth() throws IOException { + protected void doTestRenewAuth() throws Exception { getBlobStoreContext(); - injectShortLivedTokenForKeystoneV1_1(); + injectShortLivedTokenForSwiftAuth(); context.getBlobStore().createContainerInLocation(null, testContainerName); @@ -149,8 +149,10 @@ public class BlobStoreExpiryTest { BlobStoreTest.assertHasItemNamed(ps, testContainerName); } - private void injectShortLivedTokenForKeystoneV1_1() { - HttpToolResponse tokenHttpResponse1 = requestTokenWithExplicitLifetime("https://keystone-endpoint/v1.1", "CHANGE_ME", + private void injectShortLivedTokenForSwiftAuth() throws Exception { + URL endpointUrl = new URL(endpoint); + + HttpToolResponse tokenHttpResponse1 = requestTokenWithExplicitLifetime(endpointUrl, identity, credential, Duration.FIVE_SECONDS); Builder<String, URI> servicesMapBuilder = ImmutableMap.builder(); @@ -178,12 +180,12 @@ public class BlobStoreExpiryTest { } } - public static HttpToolResponse requestTokenWithExplicitLifetime(String url, String host, String user, String key, Duration expiration) { + public static HttpToolResponse requestTokenWithExplicitLifetime(URL url, String user, String key, Duration expiration) throws URISyntaxException { HttpClient client = HttpTool.httpClientBuilder().build(); - HttpToolResponse response = HttpTool.httpGet(client, URI.create(url), MutableMap.<String,String>of() + HttpToolResponse response = HttpTool.httpGet(client, url.toURI(), MutableMap.<String,String>of() .add(AuthHeaders.AUTH_USER, user) .add(AuthHeaders.AUTH_KEY, key) - .add("Host", host) + .add("Host", url.getHost()) .add("X-Auth-New-Token", "" + true) .add("X-Auth-Token-Lifetime", "" + expiration.toSeconds()) );
