james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [03/14] james-project git commit: JAMES-2525 adds keystone v2 and v3 capability to DockerSwiftExtension
Date Fri, 05 Oct 2018 11:12:46 GMT
JAMES-2525 adds keystone v2 and v3 capability to DockerSwiftExtension

Since the extension is no longer TempAuth specific it is renamed to
remove the reference to TempAuth


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

Branch: refs/heads/master
Commit: db660ef11ba41af22b99b764c3fe5ccb07605bdd
Parents: b885ac2
Author: Jean Helou <jhe@codamens.fr>
Authored: Thu Aug 30 12:46:34 2018 +0200
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Fri Oct 5 18:11:42 2018 +0700

----------------------------------------------------------------------
 .../james/blob/objectstorage/DockerSwift.java   |  46 ++++++++
 .../objectstorage/DockerSwiftExtension.java     | 104 +++++++++++++++++++
 .../DockerSwiftTempAuthExtension.java           |  76 --------------
 .../ObjectStorageBlobsDAOTest.java              |   6 +-
 4 files changed, 153 insertions(+), 79 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/db660ef1/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/DockerSwift.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/DockerSwift.java
b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/DockerSwift.java
new file mode 100644
index 0000000..b0ce73a
--- /dev/null
+++ b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/DockerSwift.java
@@ -0,0 +1,46 @@
+/****************************************************************
+ * 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.apache.james.blob.objectstorage;
+
+import java.net.URI;
+
+public class DockerSwift {
+    private final URI keystoneV2Endpoint;
+    private final URI keystoneV3Endpoint;
+    private final URI swiftEndpoint;
+
+    public DockerSwift(URI keystoneV2Endpoint, URI keystoneV3Endpoint, URI swiftEndpoint)
{
+        this.keystoneV2Endpoint = keystoneV2Endpoint;
+        this.keystoneV3Endpoint = keystoneV3Endpoint;
+        this.swiftEndpoint = swiftEndpoint;
+    }
+
+    public URI keystoneV2Endpoint() {
+        return keystoneV2Endpoint;
+    }
+
+    public URI keystoneV3Endpoint() {
+        return keystoneV3Endpoint;
+    }
+
+    public URI swiftEndpoint() {
+        return swiftEndpoint;
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/db660ef1/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/DockerSwiftExtension.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/DockerSwiftExtension.java
b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/DockerSwiftExtension.java
new file mode 100644
index 0000000..9d77b13
--- /dev/null
+++ b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/DockerSwiftExtension.java
@@ -0,0 +1,104 @@
+/****************************************************************
+ * 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.apache.james.blob.objectstorage;
+
+import static org.testcontainers.containers.wait.strategy.Wait.forHttp;
+
+import java.net.URI;
+
+import org.apache.james.util.docker.RateLimiters;
+import org.junit.jupiter.api.extension.AfterAllCallback;
+import org.junit.jupiter.api.extension.BeforeAllCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.ParameterContext;
+import org.junit.jupiter.api.extension.ParameterResolutionException;
+import org.junit.jupiter.api.extension.ParameterResolver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.Container;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.wait.strategy.WaitAllStrategy;
+
+class DockerSwiftExtension implements ParameterResolver, BeforeAllCallback,
+    AfterAllCallback {
+    private static final Logger LOGGER = LoggerFactory.getLogger(DockerSwiftExtension.class);
+    private static final String SWIFT_DOCKER_IMAGE = "jeantil/openstack-keystone-swift:pike";
+    private static final int SWIFT_PORT = 8080;
+    private static final int KEYSTONE_ADMIN_PORT = 35357;
+
+    private final GenericContainer<?> swiftContainer;
+
+    private DockerSwift dockerSwift;
+
+    public DockerSwiftExtension() {
+        swiftContainer = new GenericContainer<>(SWIFT_DOCKER_IMAGE)
+            .withExposedPorts(KEYSTONE_ADMIN_PORT)
+            .withExposedPorts(SWIFT_PORT)
+            .waitingFor(
+                new WaitAllStrategy().withStrategy(
+                    forHttp("/v3")
+                        .forPort(KEYSTONE_ADMIN_PORT)
+                        .forStatusCode(200)
+                        .withRateLimiter(RateLimiters.DEFAULT)
+                ).withStrategy(
+                    forHttp("/info")
+                        .forPort(SWIFT_PORT)
+                        .forStatusCode(200)
+                        .withRateLimiter(RateLimiters.DEFAULT)
+                )
+            );
+    }
+
+    @Override
+    public void beforeAll(ExtensionContext context) throws Exception {
+        swiftContainer.start();
+        Integer keystonePort = swiftContainer.getMappedPort(KEYSTONE_ADMIN_PORT);
+        Integer swiftPort = swiftContainer.getMappedPort(SWIFT_PORT);
+        String containerIpAddress = swiftContainer.getContainerIpAddress();
+        Container.ExecResult execResult = swiftContainer.execInContainer("/swift/bin/register-swift-endpoint.sh",
"http://" + containerIpAddress + ":" + swiftPort);
+        if (!execResult.getStdout().isEmpty()) {
+            LOGGER.debug(execResult.getStdout());
+        }
+        if (!execResult.getStderr().isEmpty()) {
+            LOGGER.error(execResult.getStderr());
+        }
+        URI keystoneV2Endpoint =
+            URI.create("http://" + containerIpAddress + ":" + keystonePort + "/v2.0");
+        URI keystoneV3Endpoint = URI.create("http://" + containerIpAddress + ":" + keystonePort
+ "/v3");
+        URI swiftEndpoint = URI.create("http://" + containerIpAddress + ":" + swiftPort +
"/auth/v1.0");
+        dockerSwift = new DockerSwift(keystoneV2Endpoint, keystoneV3Endpoint, swiftEndpoint);
+    }
+
+    @Override
+    public void afterAll(ExtensionContext context) throws Exception {
+        swiftContainer.stop();
+    }
+
+    @Override
+    public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext
extensionContext) throws ParameterResolutionException {
+        return (parameterContext.getParameter().getType() == DockerSwift.class);
+    }
+
+    @Override
+    public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
throws ParameterResolutionException {
+        return dockerSwift;
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/james-project/blob/db660ef1/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/DockerSwiftTempAuthExtension.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/DockerSwiftTempAuthExtension.java
b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/DockerSwiftTempAuthExtension.java
deleted file mode 100644
index b442bbe..0000000
--- a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/DockerSwiftTempAuthExtension.java
+++ /dev/null
@@ -1,76 +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.apache.james.blob.objectstorage;
-
-import java.net.URI;
-
-import org.apache.james.util.docker.RateLimiters;
-import org.junit.jupiter.api.extension.AfterAllCallback;
-import org.junit.jupiter.api.extension.BeforeAllCallback;
-import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.jupiter.api.extension.ParameterContext;
-import org.junit.jupiter.api.extension.ParameterResolutionException;
-import org.junit.jupiter.api.extension.ParameterResolver;
-import org.testcontainers.containers.GenericContainer;
-import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy;
-
-class DockerSwiftTempAuthExtension implements ParameterResolver, BeforeAllCallback, AfterAllCallback
{
-    public static final int SWIFT_PORT = 8080;
-    private static GenericContainer<?> swiftContainer =
-        new GenericContainer<>("bouncestorage/swift-aio:ea10837d")
-            .withExposedPorts(SWIFT_PORT)
-            .waitingFor(new HostPortWaitStrategy().withRateLimiter(RateLimiters.DEFAULT));
-    private DockerSwift dockerSwift;
-
-    @Override
-    public void beforeAll(ExtensionContext context) throws Exception {
-        swiftContainer.start();
-        String host = swiftContainer.getContainerIpAddress();
-        Integer port = swiftContainer.getMappedPort(SWIFT_PORT);
-        dockerSwift = new DockerSwift(new URI("http", null, host, port, "/auth/v1.0", null,
null));
-    }
-
-    @Override
-    public void afterAll(ExtensionContext context) throws Exception {
-        swiftContainer.stop();
-    }
-
-    @Override
-    public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext
extensionContext) throws ParameterResolutionException {
-        return (parameterContext.getParameter().getType() == DockerSwift.class);
-    }
-
-    @Override
-    public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
throws ParameterResolutionException {
-        return dockerSwift;
-    }
-
-    public static class DockerSwift {
-        private final URI endpoint;
-
-        public DockerSwift(URI endpoint) {
-            this.endpoint = endpoint;
-        }
-
-        public URI getEndpoint() {
-            return endpoint;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/db660ef1/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java
b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java
index 92debe1..7db44bc 100644
--- a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java
+++ b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java
@@ -35,7 +35,7 @@ import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.extension.ExtendWith;
 
-@ExtendWith(DockerSwiftTempAuthExtension.class)
+@ExtendWith(DockerSwiftExtension.class)
 public class ObjectStorageBlobsDAOTest implements BlobStoreContract {
     private static final String TENANT_NAME = "test";
     private static final String USER_NAME = "tester";
@@ -47,12 +47,12 @@ public class ObjectStorageBlobsDAOTest implements BlobStoreContract {
     private org.jclouds.blobstore.BlobStore blobStore;
 
     @BeforeEach
-    void setUp(DockerSwiftTempAuthExtension.DockerSwift dockerSwift) throws Exception {
+    void setUp(DockerSwift dockerSwift) throws Exception {
         final Properties overrides = new Properties();
         overrides.setProperty(KeystoneProperties.CREDENTIAL_TYPE, "tempAuthCredentials");
         overrides.setProperty(TempAuthHeaders.TEMP_AUTH_HEADER_USER, "X-Storage-User");
         overrides.setProperty(TempAuthHeaders.TEMP_AUTH_HEADER_PASS, "X-Storage-Pass");
-        swiftEndpoint = dockerSwift.getEndpoint();
+        swiftEndpoint = dockerSwift.swiftEndpoint();
         BlobStoreContext blobStoreContext = ContextBuilder.newBuilder("openstack-swift")
             .endpoint(swiftEndpoint.toString())
             .credentials(IDENTITY.value(), PASSWORD.value())


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message