Repository: jclouds
Updated Branches:
  refs/heads/apache-keystone3 [created] 930c0fe84


wip - adding keystone v3 tests


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

Branch: refs/heads/apache-keystone3
Commit: 930c0fe84d27c0a73e3fb637c55abb41becee011
Parents: 62ed9ec
Author: Andrea Turli <[email protected]>
Authored: Tue Jan 9 10:18:34 2018 +0100
Committer: Andrea Turli <[email protected]>
Committed: Tue Jan 9 10:18:34 2018 +0100

----------------------------------------------------------------------
 .../keystone/v3/features/AuthApiLiveTest.java   | 53 ++++++++++++++++++
 .../keystone/v3/features/AuthApiMockTest.java   | 54 +++++++++++++++++++
 .../v3/features/CatalogApiLiveTest.java         | 49 +++++++++++++++++
 .../v3/features/CatalogApiMockTest.java         | 56 ++++++++++++++++++++
 .../keystone/v3/features/TokenApiLiveTest.java  | 53 ------------------
 .../keystone/v3/features/TokenApiMockTest.java  | 54 -------------------
 .../v3/internal/BaseV3KeystoneApiLiveTest.java  |  3 ++
 7 files changed, 215 insertions(+), 107 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/930c0fe8/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/AuthApiLiveTest.java
----------------------------------------------------------------------
diff --git 
a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/AuthApiLiveTest.java
 
b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/AuthApiLiveTest.java
new file mode 100644
index 0000000..325c0ae
--- /dev/null
+++ 
b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/AuthApiLiveTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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 static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Properties;
+
+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 com.google.inject.Injector;
+import com.google.inject.Module;
+
+@Test(groups = "live", testName = "TokenApiLiveTest")
+public class AuthApiLiveTest extends BaseV3KeystoneApiLiveTest {
+
+   @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);
+   }
+
+   public void testIsTokenValid() {
+      assertTrue(api().isValid(token));
+   }
+
+   public void testGetToken() {
+      assertNotNull(api().get(token));
+   }
+
+   private AuthApi api() {
+      return api.getAuthApi();
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/930c0fe8/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/AuthApiMockTest.java
----------------------------------------------------------------------
diff --git 
a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/AuthApiMockTest.java
 
b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/AuthApiMockTest.java
new file mode 100644
index 0000000..216df80
--- /dev/null
+++ 
b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/AuthApiMockTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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 static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+
+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;
+
+@Test(groups = "unit", testName = "AuthApiMockTest", singleThreaded = true)
+public class AuthApiMockTest extends BaseV3KeystoneApiMockTest {
+
+   public void testGetToken() throws InterruptedException {
+      
server.enqueue(jsonResponse("/v3/token.json").addHeader("X-Subject-Token", 
"bf583aefb74e45108346b4c1c8527a10"));
+
+      Token token = api.getAuthApi().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.getAuthApi().get("bf583aefb74e45108346b4c1c8527a10");
+
+      assertNull(token);
+
+      assertEquals(server.getRequestCount(), 2);
+      assertSent(server, "POST", "/auth/tokens");
+      assertSent(server, "GET", "/token/bf583aefb74e45108346b4c1c8527a10");
+   }
+   
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/930c0fe8/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/CatalogApiLiveTest.java
----------------------------------------------------------------------
diff --git 
a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/CatalogApiLiveTest.java
 
b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/CatalogApiLiveTest.java
new file mode 100644
index 0000000..3a74a75
--- /dev/null
+++ 
b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/CatalogApiLiveTest.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.features;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest;
+import org.jclouds.openstack.keystone.v2_0.domain.Tenant;
+import org.jclouds.openstack.keystone.v3.KeystoneApi;
+import org.jclouds.openstack.keystone.v3.domain.Endpoint;
+import org.jclouds.openstack.keystone.v3.internal.BaseV3KeystoneApiLiveTest;
+import org.testng.annotations.Test;
+
+import com.google.inject.Injector;
+import com.google.inject.Module;
+
+@Test(groups = "live", testName = "CatalogApiLiveTest")
+public class CatalogApiLiveTest extends BaseV3KeystoneApiLiveTest {
+
+   public void testTenants() {
+      List<Endpoint> result = api.getCatalogApi().endpoints();
+      assertNotNull(result);
+      assertFalse(result.isEmpty());
+
+      for (Endpoint endpoint : result) {
+         assertNotNull(endpoint.id());
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/930c0fe8/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/CatalogApiMockTest.java
----------------------------------------------------------------------
diff --git 
a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/CatalogApiMockTest.java
 
b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/CatalogApiMockTest.java
new file mode 100644
index 0000000..9e43f1f
--- /dev/null
+++ 
b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/CatalogApiMockTest.java
@@ -0,0 +1,56 @@
+/*
+ * 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 static com.google.common.collect.Iterables.size;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+
+import org.jclouds.openstack.keystone.v3.domain.Endpoint;
+import org.jclouds.openstack.keystone.v3.domain.Token;
+import org.jclouds.openstack.keystone.v3.internal.BaseV3KeystoneApiMockTest;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+@Test(groups = "unit", testName = "CatalogApiMockTest", singleThreaded = true)
+public class CatalogApiMockTest extends BaseV3KeystoneApiMockTest {
+
+   public void testListEndpoints() throws InterruptedException {
+      server.enqueue(jsonResponse("/v3/endpoints.json"));
+
+      List<Endpoint> endpoints = api.getCatalogApi().endpoints();
+
+      assertEquals(size(endpoints), 8);
+      assertEquals(server.getRequestCount(), 2);
+
+      assertSent(server, "GET", "/endpoints");
+   }
+
+   public void testGetTokenReturns404() throws InterruptedException {
+      server.enqueue(response404());
+
+      Token token = api.getAuthApi().get("bf583aefb74e45108346b4c1c8527a10");
+
+      assertNull(token);
+
+      assertEquals(server.getRequestCount(), 2);
+      assertSent(server, "POST", "/auth/tokens");
+      assertSent(server, "GET", "/token/bf583aefb74e45108346b4c1c8527a10");
+   }
+   
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/930c0fe8/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
deleted file mode 100644
index 523f638..0000000
--- 
a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/TokenApiLiveTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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 static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import java.util.Properties;
-
-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 com.google.inject.Injector;
-import com.google.inject.Module;
-
-@Test(groups = "live", testName = "TokenApiLiveTest")
-public class TokenApiLiveTest extends BaseV3KeystoneApiLiveTest {
-
-   @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);
-   }
-
-   public void testIsTokenValid() {
-      assertTrue(api().isValid(token));
-   }
-
-   public void testGetToken() {
-      assertNotNull(api().get(token));
-   }
-
-   private AuthApi api() {
-      return api.getAuthApi();
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/930c0fe8/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
deleted file mode 100644
index ba33431..0000000
--- 
a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v3/features/TokenApiMockTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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 static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNull;
-
-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;
-
-@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.getAuthApi().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.getAuthApi().get("bf583aefb74e45108346b4c1c8527a10");
-
-      assertNull(token);
-
-      assertEquals(server.getRequestCount(), 2);
-      assertSent(server, "POST", "/auth/tokens");
-      assertSent(server, "GET", "/token/bf583aefb74e45108346b4c1c8527a10");
-   }
-   
-}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/930c0fe8/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 ac917a7..f3a718a 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
@@ -25,6 +25,8 @@ import 
org.jclouds.openstack.keystone.auth.filters.AuthenticateRequest;
 import org.jclouds.openstack.keystone.config.KeystoneProperties;
 import org.jclouds.openstack.keystone.v3.KeystoneApi;
 
+import static 
org.jclouds.openstack.keystone.config.KeystoneProperties.SERVICE_TYPE;
+
 public class BaseV3KeystoneApiLiveTest extends BaseApiLiveTest<KeystoneApi> {
 
    protected String token;
@@ -37,6 +39,7 @@ public class BaseV3KeystoneApiLiveTest extends 
BaseApiLiveTest<KeystoneApi> {
    protected Properties setupProperties() {
       Properties props = super.setupProperties();
       setIfTestSystemPropertyPresent(props, 
KeystoneProperties.CREDENTIAL_TYPE);
+      props.setProperty(SERVICE_TYPE, "identityv3");
       return props;
    }
 

Reply via email to