You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by an...@apache.org on 2017/12/19 14:07:14 UTC

[1/3] jclouds git commit: wip

Repository: jclouds
Updated Branches:
  refs/heads/keystonev3 17c11ec9d -> 05b9195b7


wip


Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/278ecf57
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/278ecf57
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/278ecf57

Branch: refs/heads/keystonev3
Commit: 278ecf57de69832142ca3977a125830c97b22614
Parents: 17c11ec
Author: Andrea Turli <an...@gmail.com>
Authored: Tue Dec 12 09:39:20 2017 +0100
Committer: Andrea Turli <an...@gmail.com>
Committed: Tue Dec 12 09:39:20 2017 +0100

----------------------------------------------------------------------
 .../keystone/v3/KeystoneApiMetadata.java        |   6 +-
 .../keystone/v3/auth/V3AuthenticationApi.java   |   4 +-
 .../v3/config/KeystoneHttpApiModule.java        |  49 ++
 .../v3/config/KeystoneParserModule.java         |  31 ++
 .../keystone/v3/features/TokenApi.java          |  10 +-
 .../v3/internal/BaseV3KeystoneApiLiveTest.java  |  39 ++
 .../v3/internal/BaseV3KeystoneApiMockTest.java  | 141 +++++
 .../src/test/resources/logback-test.xml         |  42 ++
 .../src/test/resources/logback.xml              |  64 ---
 .../src/test/resources/v3/token.json            | 510 +++++++++++++++++++
 .../digitalocean2/src/test/resources/token.json |   0
 11 files changed, 821 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/278ecf57/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/KeystoneApiMetadata.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/KeystoneApiMetadata.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/KeystoneApiMetadata.java
index d649563..52c400c 100644
--- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/KeystoneApiMetadata.java
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/KeystoneApiMetadata.java
@@ -27,8 +27,8 @@ import org.jclouds.apis.ApiMetadata;
 import org.jclouds.openstack.keystone.auth.config.AuthenticationModule;
 import org.jclouds.openstack.keystone.catalog.config.KeystoneAdminURLModule;
 import org.jclouds.openstack.keystone.catalog.config.ServiceCatalogModule;
-import org.jclouds.openstack.keystone.v2_0.config.KeystoneHttpApiModule;
-import org.jclouds.openstack.keystone.v2_0.config.KeystoneParserModule;
+import org.jclouds.openstack.keystone.v3.config.KeystoneHttpApiModule;
+import org.jclouds.openstack.keystone.v3.config.KeystoneParserModule;
 import org.jclouds.openstack.v2_0.ServiceType;
 import org.jclouds.rest.internal.BaseHttpApiMetadata;
 
@@ -59,7 +59,7 @@ public class KeystoneApiMetadata extends BaseHttpApiMetadata<KeystoneApi> {
       Properties properties = BaseHttpApiMetadata.defaultProperties();
       properties.setProperty(CREDENTIAL_TYPE, org.jclouds.openstack.keystone.auth.config.CredentialTypes.PASSWORD_CREDENTIALS);
       properties.setProperty(SERVICE_TYPE, ServiceType.IDENTITY);
-      properties.setProperty(KEYSTONE_VERSION, "2");
+      properties.setProperty(KEYSTONE_VERSION, "3");
       return properties;
    }
 

http://git-wip-us.apache.org/repos/asf/jclouds/blob/278ecf57/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/auth/V3AuthenticationApi.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/auth/V3AuthenticationApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/auth/V3AuthenticationApi.java
index 0553c15..0d99b66 100644
--- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/auth/V3AuthenticationApi.java
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/auth/V3AuthenticationApi.java
@@ -45,14 +45,14 @@ public interface V3AuthenticationApi extends AuthenticationApi, Closeable {
 
    @Named("token:create")
    @POST
-   @ResponseParser(ParseTokenFromHttpResponse.class) //ParseToken.class)
+   @ResponseParser(ParseTokenFromHttpResponse.class)
    @MapBinder(BindPasswordAuthToJsonPayload.class)
    @Override
    Token authenticatePassword(TenantAndCredentials<PasswordCredentials> credentials);
 
    @Named("token:create")
    @POST
-   @ResponseParser(ParseTokenFromHttpResponse.class) //ParseToken.class)
+   @ResponseParser(ParseTokenFromHttpResponse.class)
    @MapBinder(BindTokenAuthToJsonPayload.class)
    @Override
    Token authenticateToken(TenantAndCredentials<TokenCredentials> credentials);

http://git-wip-us.apache.org/repos/asf/jclouds/blob/278ecf57/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/config/KeystoneHttpApiModule.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/config/KeystoneHttpApiModule.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/config/KeystoneHttpApiModule.java
new file mode 100644
index 0000000..6458726
--- /dev/null
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/config/KeystoneHttpApiModule.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.keystone.v3.config;
+
+import java.net.URI;
+
+import org.jclouds.openstack.keystone.v2_0.config.NamespaceAliases;
+import org.jclouds.openstack.keystone.v3.KeystoneApi;
+import org.jclouds.rest.ConfiguresHttpApi;
+import org.jclouds.rest.config.HttpApiModule;
+
+import com.google.inject.Binder;
+import com.google.inject.multibindings.MapBinder;
+
+/**
+ * Configures the Keystone API.
+ */
+@ConfiguresHttpApi
+public class KeystoneHttpApiModule extends HttpApiModule<KeystoneApi> {
+
+   public KeystoneHttpApiModule() {
+   }
+
+   // Allow providers to cleanly contribute their own aliases
+   public static MapBinder<URI, URI> namespaceAliasBinder(Binder binder) {
+      return MapBinder.newMapBinder(binder, URI.class, URI.class, NamespaceAliases.class).permitDuplicates();
+   }
+
+   @Override
+   protected void configure() {
+      super.configure();
+      namespaceAliasBinder(binder());
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/278ecf57/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/config/KeystoneParserModule.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/config/KeystoneParserModule.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/config/KeystoneParserModule.java
new file mode 100644
index 0000000..f76e28b
--- /dev/null
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/config/KeystoneParserModule.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.keystone.v3.config;
+
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.json.config.GsonModule.DateAdapter;
+
+import com.google.inject.AbstractModule;
+
+public class KeystoneParserModule extends AbstractModule {
+
+   @Override
+   protected void configure() {
+      bind(DateAdapter.class).to(GsonModule.Iso8601DateAdapter.class);
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/278ecf57/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/TokenApi.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/TokenApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/TokenApi.java
index bba190a..75ade88 100644
--- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/TokenApi.java
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/TokenApi.java
@@ -20,11 +20,7 @@ import java.util.List;
 import java.util.Set;
 
 import javax.inject.Named;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.HEAD;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
+import javax.ws.rs.*;
 import javax.ws.rs.core.MediaType;
 
 import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
@@ -39,6 +35,7 @@ import org.jclouds.openstack.keystone.v3.domain.Region;
 import org.jclouds.openstack.keystone.v3.domain.Token;
 import org.jclouds.openstack.v2_0.services.Identity;
 import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.Headers;
 import org.jclouds.rest.annotations.RequestFilters;
 import org.jclouds.rest.annotations.SelectJson;
 
@@ -58,9 +55,10 @@ public interface TokenApi {
    @Named("token:get")
    @GET
    @SelectJson("token")
-   @Path("/auth/tokens/{token}")
+   @Path("/auth/tokens")
    @Fallback(NullOnNotFoundOr404.class)
    @Nullable
+   @Headers( keys = "X-Subject-Token", values = "{token}")
    Token get(@PathParam("token") String token);
 
    /**

http://git-wip-us.apache.org/repos/asf/jclouds/blob/278ecf57/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiLiveTest.java
new file mode 100644
index 0000000..acde256
--- /dev/null
+++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiLiveTest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.keystone.v3.internal;
+
+import java.util.Properties;
+
+import org.jclouds.apis.BaseApiLiveTest;
+import org.jclouds.openstack.keystone.config.KeystoneProperties;
+import org.jclouds.openstack.keystone.v3.KeystoneApi;
+
+public class BaseV3KeystoneApiLiveTest extends BaseApiLiveTest<KeystoneApi> {
+
+   public BaseV3KeystoneApiLiveTest() {
+      provider = "openstack-keystone-3";
+   }
+
+   @Override
+   protected Properties setupProperties() {
+      Properties props = super.setupProperties();
+      props.setProperty("jclouds.api-version", "v3");
+      setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
+      return props;
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/278ecf57/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiMockTest.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiMockTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiMockTest.java
new file mode 100644
index 0000000..1d134e0
--- /dev/null
+++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiMockTest.java
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.keystone.v3.internal;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.collect.Iterables.getOnlyElement;
+import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService;
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.jclouds.ContextBuilder;
+import org.jclouds.concurrent.config.ExecutorServiceModule;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.keystone.v3.KeystoneApi;
+import org.jclouds.openstack.keystone.v3.KeystoneApiMetadata;
+import org.jclouds.rest.ApiContext;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+
+import com.google.common.base.Charsets;
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.io.Resources;
+import com.google.common.reflect.TypeToken;
+import com.google.gson.JsonParser;
+import com.google.inject.Module;
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
+import com.squareup.okhttp.mockwebserver.RecordedRequest;
+
+public class BaseV3KeystoneApiMockTest {
+   
+   private static final String DEFAULT_ENDPOINT = new KeystoneApiMetadata().getDefaultEndpoint().orNull();
+   
+   private final Set<Module> modules = ImmutableSet.<Module> of(new ExecutorServiceModule(newDirectExecutorService()));
+   
+   protected MockWebServer server;
+   protected KeystoneApi api;
+   private Json json;
+   
+   // So that we can ignore formatting.
+   private final JsonParser parser = new JsonParser();
+   
+   @BeforeMethod
+   public void start() throws IOException {
+      server = new MockWebServer();
+      server.play();
+      ApiContext<KeystoneApi> ctx = ContextBuilder.newBuilder("openstack-keystone-3")
+              .credentials("identity", "credential")
+              .endpoint(url(""))
+              .modules(modules)
+              .overrides(overrides())
+              .build();
+      json = ctx.utils().injector().getInstance(Json.class);
+      api = ctx.getApi();
+   }
+
+   @AfterMethod(alwaysRun = true)
+   public void stop() throws IOException {
+      server.shutdown();
+      api.close();
+   }
+   
+   protected Properties overrides() {
+      return new Properties();
+   }
+
+   protected String url(String path) {
+      return server.getUrl(path).toString();
+   }
+
+   protected MockResponse jsonResponse(String resource) {
+      return new MockResponse().addHeader("Content-Type", "application/json").setBody(stringFromResource(resource));
+   }
+
+   protected MockResponse response404() {
+      return new MockResponse().setStatus("HTTP/1.1 404 Not Found");
+   }
+   
+   protected MockResponse response204() {
+      return new MockResponse().setStatus("HTTP/1.1 204 No Content");
+   }
+
+   protected String stringFromResource(String resourceName) {
+      try {
+         return Resources.toString(getClass().getResource(resourceName), Charsets.UTF_8)
+               .replace(DEFAULT_ENDPOINT, url(""));
+      } catch (IOException e) {
+         throw Throwables.propagate(e);
+      }
+   }
+   
+   protected <T> T onlyObjectFromResource(String resourceName, TypeToken<Map<String, T>> type) {
+      // Assume JSON objects passed here will be in the form: { "entity": { ... } }
+      String text = stringFromResource(resourceName);
+      Map<String, T> object = json.fromJson(text, type.getType());
+      checkArgument(!object.isEmpty(), "The given json does not contain any object: %s", text);
+      checkArgument(object.keySet().size() == 1, "The given json does not contain more than one object: %s", text);
+      return object.get(getOnlyElement(object.keySet()));
+   }
+   
+   protected <T> T objectFromResource(String resourceName, Class<T> type) {
+      String text = stringFromResource(resourceName);
+      return json.fromJson(text, type);
+   }
+
+   protected RecordedRequest assertSent(MockWebServer server, String method, String path) throws InterruptedException {
+      RecordedRequest request = server.takeRequest();
+      assertEquals(request.getMethod(), method);
+      assertEquals(request.getPath(), path);
+      assertEquals(request.getHeader("Accept"), "application/json");
+      assertEquals(request.getHeader("Authorization"), "X-Token " + "token");
+      return request;
+   }
+
+   protected RecordedRequest assertSent(MockWebServer server, String method, String path, String json)
+         throws InterruptedException {
+      RecordedRequest request = assertSent(server, method, path);
+      assertEquals(request.getHeader("Content-Type"), "application/json");
+      assertEquals(parser.parse(new String(request.getBody(), Charsets.UTF_8)), parser.parse(json));
+      return request;
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/278ecf57/apis/openstack-keystone/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/test/resources/logback-test.xml b/apis/openstack-keystone/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..4cac342
--- /dev/null
+++ b/apis/openstack-keystone/src/test/resources/logback-test.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<configuration scan="false">
+    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+        <file>target/test-data/jclouds.log</file>
+        <encoder>
+            <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
+        </encoder>
+    </appender>
+    <appender name="WIREFILE" class="ch.qos.logback.core.FileAppender">
+        <file>target/test-data/jclouds-wire.log</file>
+        <encoder>
+            <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
+        </encoder>
+    </appender>
+    <appender name="COMPUTEFILE" class="ch.qos.logback.core.FileAppender">
+        <file>target/jclouds-compute.log</file>
+        <encoder>
+            <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
+        </encoder>
+    </appender>
+
+    <logger name="org.jclouds">
+        <level value="DEBUG" />
+        <appender-ref ref="FILE" />
+    </logger>
+    <logger name="jclouds.compute">
+        <level value="DEBUG" />
+        <appender-ref ref="COMPUTEFILE" />
+    </logger>
+    <logger name="jclouds.wire">
+        <level value="DEBUG" />
+        <appender-ref ref="WIREFILE" />
+    </logger>
+    <logger name="jclouds.headers">
+        <level value="DEBUG" />
+        <appender-ref ref="WIREFILE" />
+    </logger>
+    
+    <root>
+        <level value="INFO" />
+    </root>
+</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds/blob/278ecf57/apis/openstack-keystone/src/test/resources/logback.xml
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/test/resources/logback.xml b/apis/openstack-keystone/src/test/resources/logback.xml
deleted file mode 100644
index 98b1ea9..0000000
--- a/apis/openstack-keystone/src/test/resources/logback.xml
+++ /dev/null
@@ -1,64 +0,0 @@
-<?xml version="1.0"?>
-<configuration scan="false">
-    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
-        <file>target/test-data/jclouds.log</file>
-
-        <encoder>
-            <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
-        </encoder>
-    </appender>
-
-    <appender name="WIREFILE" class="ch.qos.logback.core.FileAppender">
-        <file>target/test-data/jclouds-wire.log</file>
-
-        <encoder>
-            <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
-        </encoder>
-    </appender>
-
-    <appender name="COMPUTEFILE" class="ch.qos.logback.core.FileAppender">
-        <file>target/test-data/jclouds-compute.log</file>
-
-        <encoder>
-            <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
-        </encoder>
-    </appender>
-    
-    <appender name="SSHFILE" class="ch.qos.logback.core.FileAppender">
-        <file>target/test-data/jclouds-ssh.log</file>
-
-        <encoder>
-            <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
-        </encoder>
-    </appender>
-
-    <root>
-        <level value="warn" />
-    </root>
-
-    <logger name="org.jclouds">
-        <level value="DEBUG" />
-        <appender-ref ref="FILE" />
-    </logger>
-
-    <logger name="jclouds.wire">
-        <level value="DEBUG" />
-        <appender-ref ref="WIREFILE" />
-    </logger>
-
-    <logger name="jclouds.headers">
-        <level value="DEBUG" />
-        <appender-ref ref="WIREFILE" />
-    </logger>
-
-    <logger name="jclouds.compute">
-        <level value="DEBUG" />
-        <appender-ref ref="COMPUTEFILE" />
-    </logger>
-    
-    <logger name="jclouds.ssh">
-        <level value="DEBUG" />
-        <appender-ref ref="SSHFILE" />
-    </logger>
-
-</configuration>

http://git-wip-us.apache.org/repos/asf/jclouds/blob/278ecf57/apis/openstack-keystone/src/test/resources/v3/token.json
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/test/resources/v3/token.json b/apis/openstack-keystone/src/test/resources/v3/token.json
new file mode 100644
index 0000000..1e8906d
--- /dev/null
+++ b/apis/openstack-keystone/src/test/resources/v3/token.json
@@ -0,0 +1,510 @@
+{
+  "token": {
+    "methods": [
+      "password"
+    ],
+    "roles": [
+      {
+        "id": "9fe2ff9ee4384b1894a90878d3e92bab",
+        "name": "_member_"
+      },
+      {
+        "id": "df7d043a09d34a7c9e2bad15926ee097",
+        "name": "cpf_org_manager"
+      },
+      {
+        "id": "3af119c426a742999e7890f6d1f70b36",
+        "name": "cpf_admin"
+      }
+    ],
+    "expires_at": "2017-12-10T11:48:46.546830Z",
+    "project": {
+      "domain": {
+        "id": "2347b158dcaf488496b44cc4edfd2bd8",
+        "name": "0kjFQF29"
+      },
+      "id": "2233c4d7d5c044b1b48e1bef25c1f305",
+      "name": "0kjFQF29-prj"
+    },
+    "catalog": [
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://objectstorage.uk-1.cloud.global.fujitsu.com/v1/AUTH_2233c4d7d5c044b1b48e1bef25c1f305",
+            "region": "uk-1",
+            "interface": "public",
+            "id": "b506af0e016a4b5fb592f196da569a41",
+            "name": "objectstorage"
+          }
+        ],
+        "type": "object-store",
+        "id": "024329e4fde148e58ecd90b7d9872438",
+        "name": "objectstorage"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://keymanagement.uk-1.cloud.global.fujitsu.com/v1",
+            "region": "uk-1",
+            "interface": "public",
+            "id": "0419c448001845af8f6828cf49745e72",
+            "name": "keymanagement"
+          }
+        ],
+        "type": "keystore",
+        "id": "07f309b0ef9d42758ea4de47bdca9c32",
+        "name": "keymanagement"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://certificate.uk-1.cloud.global.fujitsu.com/v1",
+            "region": "uk-1",
+            "interface": "public",
+            "id": "e1cc93936fb94cdbadc20f17c4ad3140",
+            "name": "certificate"
+          }
+        ],
+        "type": "certificate",
+        "id": "0bd9a971e97d4c15af6b94311e4e9c15",
+        "name": "certificate"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://orchestration.uk-1.cloud.global.fujitsu.com/v1/2233c4d7d5c044b1b48e1bef25c1f305",
+            "region": "uk-1",
+            "interface": "public",
+            "id": "c3ee708a6ae24ddf92c078526c36a446",
+            "name": "orchestration"
+          }
+        ],
+        "type": "orchestration",
+        "id": "0dafa2a9240c41268c37818979769c88",
+        "name": "orchestration"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://blockstorage.uk-1.cloud.global.fujitsu.com/v1/2233c4d7d5c044b1b48e1bef25c1f305",
+            "region": "uk-1",
+            "interface": "public",
+            "id": "ba9061d324954b1a9f6b1c1f5d4a5c5e",
+            "name": "blockstorage"
+          }
+        ],
+        "type": "volume",
+        "id": "0ec640e57e4d4374841d2ab7b292f2c2",
+        "name": "blockstorage"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://loadbalancing.uk-1.cloud.global.fujitsu.com",
+            "region": "uk-1",
+            "interface": "public",
+            "id": "169bcb3f92384f709232864f4d5304eb",
+            "name": "loadbalancing"
+          }
+        ],
+        "type": "loadbalancing",
+        "id": "15ef761fa00a438985213aec7b6fb18a",
+        "name": "loadbalancing"
+      },
+      {
+        "endpoints": [],
+        "type": "dwh",
+        "id": "1a53a2e82370422d90174c4acf585ea9",
+        "name": "dwh"
+      },
+      {
+        "endpoints": [],
+        "type": "contract",
+        "id": "1b35fa74ae0e46ebbc2014f976fec0e1",
+        "name": "contract"
+      },
+      {
+        "endpoints": [],
+        "type": "appplatform",
+        "id": "253096ed430c49c48c9f3549e867b538",
+        "name": "appplatform"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://compute-w.uk-1.cloud.global.fujitsu.com",
+            "region": "uk-1",
+            "interface": "public",
+            "id": "e26ad89a682d4c8f8a71c9e76cd785b4",
+            "name": "compute-w"
+          }
+        ],
+        "type": "compute-w",
+        "id": "327c11710f184555b43bc6fdfc47626b",
+        "name": "compute-w"
+      },
+      {
+        "endpoints": [],
+        "type": "notification",
+        "id": "3435ad7a1da04b1cb2e249665529eb51",
+        "name": "notification"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://compute.uk-1.cloud.global.fujitsu.com/v2/2233c4d7d5c044b1b48e1bef25c1f305",
+            "region": "uk-1",
+            "interface": "public",
+            "id": "f70e51b9a6a74a87a4c7055b8df8bedf",
+            "name": "compute"
+          }
+        ],
+        "type": "compute",
+        "id": "3e19093f50cc4590973c8953e2c327f9",
+        "name": "compute"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://queue.uk-1.cloud.global.fujitsu.com",
+            "region": "uk-1",
+            "interface": "public",
+            "id": "c46b5ec51ab04402a9ffd8177743ba6f",
+            "name": "queue"
+          }
+        ],
+        "type": "queue",
+        "id": "4a9ab69b74ec4948a0a6958177d30387",
+        "name": "queue"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://autoscale.uk-1.cloud.global.fujitsu.com/autoscale_schedulers",
+            "region": "uk-1",
+            "interface": "public",
+            "id": "071ee50be4b341558e37f84abac47d02",
+            "name": "autoscale"
+          }
+        ],
+        "type": "autoscale",
+        "id": "4f158b2836434c7ca6ee47e40a3ee56c",
+        "name": "autoscale"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://telemetry.uk-1.cloud.global.fujitsu.com",
+            "region": "uk-1",
+            "interface": "public",
+            "id": "6ac15657fbc548d7ab2ed986b8d94192",
+            "name": "telemetry"
+          }
+        ],
+        "type": "metering",
+        "id": "54ee7596f0e1433cb8db6201be2cf772",
+        "name": "telemetry"
+      },
+      {
+        "endpoints": [],
+        "type": "cdn",
+        "id": "5954129d136e4a76b7cd6f3d1f3808b5",
+        "name": "cdn"
+      },
+      {
+        "endpoints": [],
+        "type": "oss",
+        "id": "5a252878ffd7402498b6b74b575a899a",
+        "name": "oss"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://rolemanagement.uk-1.cloud.global.fujitsu.com/v1",
+            "region": "uk-1",
+            "interface": "public",
+            "id": "2d600a5de6ec42c6a5eab7b519832d87",
+            "name": "rolemanagement"
+          }
+        ],
+        "type": "rolemanagement",
+        "id": "5bc90099f0ad490c811239a6a3a8f853",
+        "name": "rolemanagement"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://compute-b.uk-1.cloud.global.fujitsu.com",
+            "region": "uk-1",
+            "interface": "public",
+            "id": "768450282d5546409395d2cb35502dad",
+            "name": "compute-b"
+          }
+        ],
+        "type": "compute-b",
+        "id": "65f754202b6049578e9a292a801e28f7",
+        "name": "compute-b"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://networking.uk-1.cloud.global.fujitsu.com",
+            "region": "uk-1",
+            "interface": "public",
+            "id": "675910513a7e466c84c39c5ca9445b81",
+            "name": "networking"
+          }
+        ],
+        "type": "network",
+        "id": "6cf37e33dc7140b9b032faabfa53a53e",
+        "name": "networking"
+      },
+      {
+        "endpoints": [],
+        "type": "dns",
+        "id": "7426c97af5174c1abdb8b84ba02227ce",
+        "name": "dns"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://database.uk-1.cloud.global.fujitsu.com/v1.0/2233c4d7d5c044b1b48e1bef25c1f305",
+            "region": "uk-1",
+            "interface": "public",
+            "id": "6976cbeed14c464da15c13e949b41607",
+            "name": "database"
+          }
+        ],
+        "type": "database",
+        "id": "75c0280f15844d7a9eb22b1ad5a978e8",
+        "name": "database"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://identity.uk-1.cloud.global.fujitsu.com/v2.0",
+            "region": "uk-1",
+            "interface": "admin",
+            "id": "db15a7126d4a4f1f81903bb4d56be32b",
+            "name": "identity"
+          }
+        ],
+        "type": "identity",
+        "id": "79066fe949064550930a61b33a49eb53",
+        "name": "identity"
+      },
+      {
+        "endpoints": [],
+        "type": "intdns",
+        "id": "804190a423804019aab8fd934db0086e",
+        "name": "intdns"
+      },
+      {
+        "endpoints": [],
+        "type": "invoicing",
+        "id": "8d364df08cbc4d7188f0cf83744b0336",
+        "name": "invoicing"
+      },
+      {
+        "endpoints": [],
+        "type": "catalog",
+        "id": "9674ae5917af401397071c028ff33b68",
+        "name": "catalog"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://software.uk-1.cloud.global.fujitsu.com/v1.0",
+            "region": "uk-1",
+            "interface": "public",
+            "id": "fd6g35fgknrzumut7bx6p6bwzehkfhrz",
+            "name": "software"
+          }
+        ],
+        "type": "software",
+        "id": "9760973e49b04b00b41e60c180a80562",
+        "name": "software"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://blockstorage.uk-1.cloud.global.fujitsu.com/v2/2233c4d7d5c044b1b48e1bef25c1f305",
+            "region": "uk-1",
+            "interface": "public",
+            "id": "8c4ace3bbbd44883b5762a9ad8432a46",
+            "name": "blockstoragev2"
+          }
+        ],
+        "type": "volumev2",
+        "id": "9bf82d0466714eee86e304ab3301aec9",
+        "name": "blockstorage"
+      },
+      {
+        "endpoints": [],
+        "type": "dnsadmin",
+        "id": "a2b90094346c48deabb9ca645bacf588",
+        "name": "dnsadmin"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://vmimport.uk-1.cloud.global.fujitsu.com",
+            "region": "uk-1",
+            "interface": "public",
+            "id": "225257ec50ef47668185587cc6edb95d",
+            "name": "vmimport"
+          }
+        ],
+        "type": "vmimport",
+        "id": "c73fa07c3b604b4f89d5a2b9c4621cf2",
+        "name": "vmimport"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://identity.uk-1.cloud.global.fujitsu.com/v3",
+            "region": "uk-1",
+            "interface": "public",
+            "id": "27dc2bba1c5d4a14b68657fc8fdd4e3e",
+            "name": "identityv3"
+          }
+        ],
+        "type": "identityv3",
+        "id": "cc6f50d496884ef0a751acb2e1eceedd",
+        "name": "identityv3"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://applicationmanagement.uk-1.cloud.global.fujitsu.com",
+            "region": "uk-1",
+            "interface": "public",
+            "id": "06fbcf8235434f23a08faed03b4af9ac",
+            "name": "appmanagement"
+          }
+        ],
+        "type": "appmanagement",
+        "id": "ce2f6bbe7a9f446b82d63725bd7bb484",
+        "name": "appmanagement"
+      },
+      {
+        "endpoints": [],
+        "type": "nosql",
+        "id": "d07aa581c0734b6bb85cd496115b5110",
+        "name": "nosql"
+      },
+      {
+        "endpoints": [],
+        "type": "baremetal",
+        "id": "d2f57dcae4c84466ac357220ff3d8900",
+        "name": "baremetal"
+      },
+      {
+        "endpoints": [],
+        "type": "mail",
+        "id": "d4601f51af8f43f3b0e3409e4cbac690",
+        "name": "mail"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://networking-ex.uk-1.cloud.global.fujitsu.com",
+            "region": "uk-1",
+            "interface": "public",
+            "id": "bf356065e45349a5bde5e043c95a1923",
+            "name": "networking-ex"
+          }
+        ],
+        "type": "networking-ex",
+        "id": "d4937aa1275c41378bf2ae1dbe829c68",
+        "name": "networking-ex"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "jp-east-1",
+            "url": "https://identity.gls.cloud.global.fujitsu.com/v3",
+            "region": "jp-east-1",
+            "interface": "public",
+            "id": "dc2ebf9d6fc04f1facc263a733cf754d",
+            "name": "global-identity"
+          }
+        ],
+        "type": "global-identity",
+        "id": "e74b9c29d6504f10a8fb8e1495f3f5c6",
+        "name": "global-identity"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://image.uk-1.cloud.global.fujitsu.com",
+            "region": "uk-1",
+            "interface": "public",
+            "id": "a832d640886b4ef89027339a2edf8fcd",
+            "name": "image"
+          }
+        ],
+        "type": "image",
+        "id": "ea850dab0e964e12a9f66787ee8623ae",
+        "name": "image"
+      },
+      {
+        "endpoints": [],
+        "type": "billing",
+        "id": "f1302a2477bf492bb3e867952175974a",
+        "name": "billing"
+      },
+      {
+        "endpoints": [
+          {
+            "region_id": "uk-1",
+            "url": "https://import-export.uk-1.cloud.global.fujitsu.com",
+            "region": "uk-1",
+            "interface": "public",
+            "id": "e8bde8fe61a14a88b414e5568fc17201",
+            "name": "import-export"
+          }
+        ],
+        "type": "import-export",
+        "id": "fc302725919645199373077fa299fc6e",
+        "name": "import-export"
+      }
+    ],
+    "extras": {},
+    "user": {
+      "domain": {
+        "id": "2347b158dcaf488496b44cc4edfd2bd8",
+        "name": "0kjFQF29"
+      },
+      "id": "f1f24aea666542eeb58dc129c29734f0",
+      "name": "cloudsoft"
+    },
+    "audit_ids": [
+      "kr9Qqe-1QFOOlrt2XP6AqA"
+    ],
+    "issued_at": "2017-12-10T08:48:46.546877Z"
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds/blob/278ecf57/providers/digitalocean2/src/test/resources/token.json
----------------------------------------------------------------------
diff --git a/providers/digitalocean2/src/test/resources/token.json b/providers/digitalocean2/src/test/resources/token.json
new file mode 100644
index 0000000..e69de29


[2/3] jclouds git commit: wip

Posted by an...@apache.org.
wip


Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/f4250d1b
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/f4250d1b
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/f4250d1b

Branch: refs/heads/keystonev3
Commit: f4250d1b68edb84229f05d05ffd4fc7b4d1d809c
Parents: 278ecf5
Author: Andrea Turli <an...@gmail.com>
Authored: Tue Dec 12 09:39:30 2017 +0100
Committer: Andrea Turli <an...@gmail.com>
Committed: Tue Dec 12 09:39:30 2017 +0100

----------------------------------------------------------------------
 .../keystone/v3/features/TokenApiLiveTest.java  | 55 ++++++++++++++++++
 .../keystone/v3/features/TokenApiMockTest.java  | 61 ++++++++++++++++++++
 2 files changed, 116 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/f4250d1b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/TokenApiLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/TokenApiLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/TokenApiLiveTest.java
new file mode 100644
index 0000000..8799efa
--- /dev/null
+++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/TokenApiLiveTest.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.keystone.v3.features;
+
+import com.google.common.collect.Iterables;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest;
+import org.jclouds.openstack.keystone.v3.KeystoneApi;
+import org.jclouds.openstack.keystone.v3.internal.BaseV3KeystoneApiLiveTest;
+import org.testng.annotations.Test;
+
+import java.util.Properties;
+
+@Test(groups = "live", testName = "TokenApiLiveTest")
+public class TokenApiLiveTest extends BaseV3KeystoneApiLiveTest {
+
+   protected String token;
+
+   @Override
+   protected KeystoneApi create(Properties props, Iterable<Module> modules) {
+      Injector injector = newBuilder().modules(modules).overrides(props).buildInjector();
+      grabToken(injector.getInstance(AuthenticateRequest.class));
+      return injector.getInstance(KeystoneApi.class);
+   }
+
+   // Get the token currently in use
+   private void grabToken(AuthenticateRequest ar) {
+      HttpRequest test = ar.filter(HttpRequest.builder().method("GET").endpoint(endpoint).build());
+      token = Iterables.getOnlyElement(test.getHeaders().get("X-Auth-Token"));
+   }
+
+   public void testGetToken() {
+      System.out.println(api().get(token));
+   }
+
+   private TokenApi api() {
+      return api.getTokenApi();
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/f4250d1b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/TokenApiMockTest.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/TokenApiMockTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/TokenApiMockTest.java
new file mode 100644
index 0000000..ff64eb3
--- /dev/null
+++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/TokenApiMockTest.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.keystone.v3.features;
+
+import java.util.Map;
+
+import org.jclouds.openstack.keystone.v3.domain.Token;
+import org.jclouds.openstack.keystone.v3.internal.BaseV3KeystoneApiMockTest;
+import org.testng.annotations.Test;
+
+import com.google.common.reflect.TypeToken;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+
+@Test(groups = "unit", testName = "TokenApiMockTest", singleThreaded = true)
+public class TokenApiMockTest extends BaseV3KeystoneApiMockTest {
+
+   public void testGetToken() throws InterruptedException {
+      server.enqueue(jsonResponse("/v3/token.json").addHeader("X-Subject-Token", "bf583aefb74e45108346b4c1c8527a10"));
+
+      Token token = api.getTokenApi().get("bf583aefb74e45108346b4c1c8527a10");
+
+      assertEquals(token, tokenFromResource("/v3/token.json"));
+
+      assertEquals(server.getRequestCount(), 1);
+      assertSent(server, "GET", "/token/bf583aefb74e45108346b4c1c8527a10");
+   }
+
+   public void testGetTokenReturns404() throws InterruptedException {
+      server.enqueue(response404());
+
+      Token token = api.getTokenApi().get("bf583aefb74e45108346b4c1c8527a10");
+
+      assertNull(token);
+
+      assertEquals(server.getRequestCount(), 2);
+      assertSent(server, "POST", "/auth/tokens");
+      assertSent(server, "GET", "/token/bf583aefb74e45108346b4c1c8527a10");
+   }
+   
+   private Token tokenFromResource(String resource) {
+      return onlyObjectFromResource(resource, new TypeToken<Map<String, Token>>() {
+         private static final long serialVersionUID = 1L;
+      });
+   }
+}


[3/3] jclouds git commit: some minor fixes to keystone

Posted by an...@apache.org.
some minor fixes to keystone


Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/05b9195b
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/05b9195b
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/05b9195b

Branch: refs/heads/keystonev3
Commit: 05b9195b76e6ecf73ad3d3a1d6647e5b76011f24
Parents: f4250d1
Author: Andrea Turli <an...@gmail.com>
Authored: Tue Dec 19 15:04:10 2017 +0100
Committer: Andrea Turli <an...@gmail.com>
Committed: Tue Dec 19 15:04:10 2017 +0100

----------------------------------------------------------------------
 .../openstack/keystone/v3/domain/Auth.java      |  2 +-
 .../keystone/v3/features/TokenApi.java          | 11 +++-
 .../v3/auth/V3AuthenticationApiLiveTest.java    | 68 ++++++++++++++++++++
 .../keystone/v3/features/TokenApiLiveTest.java  | 15 ++---
 .../keystone/v3/features/TokenApiMockTest.java  |  2 +-
 .../v3/internal/BaseV3KeystoneApiLiveTest.java  | 12 +++-
 .../v3/internal/BaseV3KeystoneApiMockTest.java  |  2 +-
 .../src/test/resources/logback-test.xml         | 42 ------------
 .../src/test/resources/logback.xml              | 42 ++++++++++++
 9 files changed, 138 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/05b9195b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Auth.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Auth.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Auth.java
index fb2caf5..e716d35 100644
--- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Auth.java
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/domain/Auth.java
@@ -38,7 +38,7 @@ public abstract class Auth {
       
       public abstract List<String> methods();
       @Nullable public abstract TokenAuth token();
-      public abstract PasswordAuth password();
+      @Nullable public abstract PasswordAuth password();
 
       @SerializedNames({ "methods", "token", "password" })
       public static Identity create(List<String> methods, TokenAuth token, PasswordAuth password) {

http://git-wip-us.apache.org/repos/asf/jclouds/blob/05b9195b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/TokenApi.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/TokenApi.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/TokenApi.java
index 75ade88..34d9b42 100644
--- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/TokenApi.java
+++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v3/features/TokenApi.java
@@ -20,7 +20,11 @@ import java.util.List;
 import java.util.Set;
 
 import javax.inject.Named;
-import javax.ws.rs.*;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.HEAD;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
 import javax.ws.rs.core.MediaType;
 
 import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
@@ -80,9 +84,10 @@ public interface TokenApi {
     *
     * @return true if the token is valid
     */
-   @Named("token:valid")
+   @Named("token:check")
    @HEAD
-   @Path("/auth/tokens/{token}")
+   @Path("/auth/tokens")
+   @Headers( keys = "X-Subject-Token", values = "{token}")
    @Fallback(FalseOnNotFoundOr404.class)
    boolean isValid(@PathParam("token") String token);
 

http://git-wip-us.apache.org/repos/asf/jclouds/blob/05b9195b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/auth/V3AuthenticationApiLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/auth/V3AuthenticationApiLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/auth/V3AuthenticationApiLiveTest.java
new file mode 100644
index 0000000..55b4216
--- /dev/null
+++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/auth/V3AuthenticationApiLiveTest.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openstack.keystone.v3.auth;
+
+import static org.testng.Assert.assertNotNull;
+
+import org.jclouds.openstack.keystone.auth.AuthenticationApi;
+import org.jclouds.openstack.keystone.auth.domain.PasswordCredentials;
+import org.jclouds.openstack.keystone.auth.domain.TenantAndCredentials;
+import org.jclouds.openstack.keystone.auth.domain.TokenCredentials;
+import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest;
+import org.jclouds.openstack.keystone.v3.KeystoneApi;
+import org.jclouds.openstack.keystone.v3.internal.BaseV3KeystoneApiLiveTest;
+import org.jclouds.rest.ApiContext;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Splitter;
+import com.google.common.collect.Iterables;
+import com.google.common.reflect.TypeToken;
+
+@Test(groups = "live", testName = "V3AuthenticationApiLiveTest")
+public class V3AuthenticationApiLiveTest extends BaseV3KeystoneApiLiveTest {
+
+   private String tenant;
+   private String user;
+   private ApiContext<KeystoneApi> context;
+
+   @BeforeClass
+   public void parseCredentials() {
+      tenant = Iterables.get(Splitter.on(":").split(identity), 0);
+      user = Iterables.get(Splitter.on(":").split(identity), 1);
+      context = newBuilder().modules(setupModules()).overrides(setupProperties())
+            .build(new TypeToken<ApiContext<KeystoneApi>>() {
+            });
+
+      grabToken(context.utils().injector().getInstance(AuthenticateRequest.class));
+   }
+
+   public void testAuthenticatePassword() {
+      assertNotNull(api().authenticatePassword(TenantAndCredentials.<PasswordCredentials> builder().tenantName(tenant)
+            .credentials(PasswordCredentials.builder().username(user).password(credential).build()).build()));
+   }
+
+   public void testAuthenticateToken() {
+      assertNotNull(api().authenticateToken(TenantAndCredentials.<TokenCredentials> builder().tenantName(tenant)
+            .credentials(TokenCredentials.builder().id(token).build()).build()));
+   }
+
+   protected AuthenticationApi api() {
+      return context.utils().injector().getInstance(AuthenticationApi.class);
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/05b9195b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/TokenApiLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/TokenApiLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/TokenApiLiveTest.java
index 8799efa..79e9647 100644
--- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/TokenApiLiveTest.java
+++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/TokenApiLiveTest.java
@@ -16,10 +16,8 @@
  */
 package org.jclouds.openstack.keystone.v3.features;
 
-import com.google.common.collect.Iterables;
 import com.google.inject.Injector;
 import com.google.inject.Module;
-import org.jclouds.http.HttpRequest;
 import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest;
 import org.jclouds.openstack.keystone.v3.KeystoneApi;
 import org.jclouds.openstack.keystone.v3.internal.BaseV3KeystoneApiLiveTest;
@@ -27,11 +25,12 @@ import org.testng.annotations.Test;
 
 import java.util.Properties;
 
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
 @Test(groups = "live", testName = "TokenApiLiveTest")
 public class TokenApiLiveTest extends BaseV3KeystoneApiLiveTest {
 
-   protected String token;
-
    @Override
    protected KeystoneApi create(Properties props, Iterable<Module> modules) {
       Injector injector = newBuilder().modules(modules).overrides(props).buildInjector();
@@ -39,14 +38,12 @@ public class TokenApiLiveTest extends BaseV3KeystoneApiLiveTest {
       return injector.getInstance(KeystoneApi.class);
    }
 
-   // Get the token currently in use
-   private void grabToken(AuthenticateRequest ar) {
-      HttpRequest test = ar.filter(HttpRequest.builder().method("GET").endpoint(endpoint).build());
-      token = Iterables.getOnlyElement(test.getHeaders().get("X-Auth-Token"));
+   public void testIsTokenValid() {
+      assertTrue(api().isValid(token));
    }
 
    public void testGetToken() {
-      System.out.println(api().get(token));
+      assertNotNull(api().get(token));
    }
 
    private TokenApi api() {

http://git-wip-us.apache.org/repos/asf/jclouds/blob/05b9195b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/TokenApiMockTest.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/TokenApiMockTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/TokenApiMockTest.java
index ff64eb3..118b2fd 100644
--- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/TokenApiMockTest.java
+++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/TokenApiMockTest.java
@@ -54,7 +54,7 @@ public class TokenApiMockTest extends BaseV3KeystoneApiMockTest {
    }
    
    private Token tokenFromResource(String resource) {
-      return onlyObjectFromResource(resource, new TypeToken<Map<String, Token>>() {
+      return onlyObjectFromResource(resource, new TypeToken<Token>() {
          private static final long serialVersionUID = 1L;
       });
    }

http://git-wip-us.apache.org/repos/asf/jclouds/blob/05b9195b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiLiveTest.java
index acde256..ac917a7 100644
--- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiLiveTest.java
+++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiLiveTest.java
@@ -18,12 +18,17 @@ package org.jclouds.openstack.keystone.v3.internal;
 
 import java.util.Properties;
 
+import com.google.common.collect.Iterables;
 import org.jclouds.apis.BaseApiLiveTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest;
 import org.jclouds.openstack.keystone.config.KeystoneProperties;
 import org.jclouds.openstack.keystone.v3.KeystoneApi;
 
 public class BaseV3KeystoneApiLiveTest extends BaseApiLiveTest<KeystoneApi> {
 
+   protected String token;
+
    public BaseV3KeystoneApiLiveTest() {
       provider = "openstack-keystone-3";
    }
@@ -31,9 +36,14 @@ public class BaseV3KeystoneApiLiveTest extends BaseApiLiveTest<KeystoneApi> {
    @Override
    protected Properties setupProperties() {
       Properties props = super.setupProperties();
-      props.setProperty("jclouds.api-version", "v3");
       setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
       return props;
    }
 
+   // Get the token currently in use
+   protected void grabToken(AuthenticateRequest ar) {
+      HttpRequest test = ar.filter(HttpRequest.builder().method("GET").endpoint(endpoint).build());
+      token = Iterables.getOnlyElement(test.getHeaders().get("X-Auth-Token"));
+   }
+
 }

http://git-wip-us.apache.org/repos/asf/jclouds/blob/05b9195b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiMockTest.java
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiMockTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiMockTest.java
index 1d134e0..1d87cf8 100644
--- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiMockTest.java
+++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/internal/BaseV3KeystoneApiMockTest.java
@@ -108,7 +108,7 @@ public class BaseV3KeystoneApiMockTest {
       }
    }
    
-   protected <T> T onlyObjectFromResource(String resourceName, TypeToken<Map<String, T>> type) {
+   protected <T> T onlyObjectFromResource(String resourceName, TypeToken<T> type) {
       // Assume JSON objects passed here will be in the form: { "entity": { ... } }
       String text = stringFromResource(resourceName);
       Map<String, T> object = json.fromJson(text, type.getType());

http://git-wip-us.apache.org/repos/asf/jclouds/blob/05b9195b/apis/openstack-keystone/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/test/resources/logback-test.xml b/apis/openstack-keystone/src/test/resources/logback-test.xml
deleted file mode 100644
index 4cac342..0000000
--- a/apis/openstack-keystone/src/test/resources/logback-test.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0"?>
-<configuration scan="false">
-    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
-        <file>target/test-data/jclouds.log</file>
-        <encoder>
-            <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
-        </encoder>
-    </appender>
-    <appender name="WIREFILE" class="ch.qos.logback.core.FileAppender">
-        <file>target/test-data/jclouds-wire.log</file>
-        <encoder>
-            <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
-        </encoder>
-    </appender>
-    <appender name="COMPUTEFILE" class="ch.qos.logback.core.FileAppender">
-        <file>target/jclouds-compute.log</file>
-        <encoder>
-            <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
-        </encoder>
-    </appender>
-
-    <logger name="org.jclouds">
-        <level value="DEBUG" />
-        <appender-ref ref="FILE" />
-    </logger>
-    <logger name="jclouds.compute">
-        <level value="DEBUG" />
-        <appender-ref ref="COMPUTEFILE" />
-    </logger>
-    <logger name="jclouds.wire">
-        <level value="DEBUG" />
-        <appender-ref ref="WIREFILE" />
-    </logger>
-    <logger name="jclouds.headers">
-        <level value="DEBUG" />
-        <appender-ref ref="WIREFILE" />
-    </logger>
-    
-    <root>
-        <level value="INFO" />
-    </root>
-</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds/blob/05b9195b/apis/openstack-keystone/src/test/resources/logback.xml
----------------------------------------------------------------------
diff --git a/apis/openstack-keystone/src/test/resources/logback.xml b/apis/openstack-keystone/src/test/resources/logback.xml
new file mode 100644
index 0000000..4cf5016
--- /dev/null
+++ b/apis/openstack-keystone/src/test/resources/logback.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<configuration scan="false">
+    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+        <file>target/test-data/jclouds.log</file>
+        <encoder>
+            <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
+        </encoder>
+    </appender>
+    <appender name="WIREFILE" class="ch.qos.logback.core.FileAppender">
+        <file>target/test-data/jclouds-wire.log</file>
+        <encoder>
+            <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
+        </encoder>
+    </appender>
+    <appender name="COMPUTEFILE" class="ch.qos.logback.core.FileAppender">
+        <file>target/jclouds-compute.log</file>
+        <encoder>
+            <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
+        </encoder>
+    </appender>
+
+    <logger name="org.jclouds">
+        <level value="DEBUG" />
+        <appender-ref ref="FILE" />
+    </logger>
+    <logger name="jclouds.compute">
+        <level value="DEBUG" />
+        <appender-ref ref="COMPUTEFILE" />
+    </logger>
+    <logger name="jclouds.wire">
+        <level value="DEBUG" />
+        <appender-ref ref="WIREFILE" />
+    </logger>
+    <logger name="jclouds.headers">
+        <level value="DEBUG" />
+        <appender-ref ref="WIREFILE" />
+    </logger>
+
+    <root>
+        <level value="INFO" />
+    </root>
+</configuration>
\ No newline at end of file