james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [1/8] james-project git commit: JAMES-2589 Encrypted Payload Configuration should work
Date Tue, 04 Dec 2018 08:48:54 GMT
Repository: james-project
Updated Branches:
  refs/heads/master 0e3ffde31 -> d78ea34ec


JAMES-2589 Encrypted Payload Configuration should work


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

Branch: refs/heads/master
Commit: f454266fa6a3eaac0812c3426782cc39c34e4876
Parents: eccab45
Author: tran tien duc <dtran@linagora.com>
Authored: Thu Nov 29 18:49:04 2018 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Tue Dec 4 15:47:08 2018 +0700

----------------------------------------------------------------------
 .../ObjectStorageBlobConfiguration.java         |  4 ++++
 .../ObjectStorageDependenciesModule.java        |  8 +------
 .../james/CassandraRabbitMQJamesServerTest.java | 25 +++++++++-----------
 3 files changed, 16 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/f454266f/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/ObjectStorageBlobConfiguration.java
----------------------------------------------------------------------
diff --git a/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/ObjectStorageBlobConfiguration.java
b/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/ObjectStorageBlobConfiguration.java
index a58a8d9..7be4a96 100644
--- a/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/ObjectStorageBlobConfiguration.java
+++ b/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/ObjectStorageBlobConfiguration.java
@@ -26,6 +26,7 @@ import java.util.Optional;
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.james.blob.objectstorage.ContainerName;
+import org.apache.james.blob.objectstorage.PayloadCodec;
 import org.apache.james.blob.objectstorage.swift.SwiftKeystone2ObjectStorage;
 import org.apache.james.blob.objectstorage.swift.SwiftKeystone3ObjectStorage;
 import org.apache.james.blob.objectstorage.swift.SwiftTempAuthObjectStorage;
@@ -257,6 +258,9 @@ public class ObjectStorageBlobConfiguration {
         return payloadCodec;
     }
 
+    public PayloadCodec getPayloadCodec() {
+        return payloadCodec.create(this);
+    }
 
     public Optional<String> getAesSalt() {
         return aesSalt;

http://git-wip-us.apache.org/repos/asf/james-project/blob/f454266f/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/ObjectStorageDependenciesModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/ObjectStorageDependenciesModule.java
b/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/ObjectStorageDependenciesModule.java
index 4577159..0aeb26d 100644
--- a/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/ObjectStorageDependenciesModule.java
+++ b/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/ObjectStorageDependenciesModule.java
@@ -32,7 +32,6 @@ import org.apache.james.blob.api.BlobId;
 import org.apache.james.blob.api.HashBlobId;
 import org.apache.james.blob.objectstorage.ObjectStorageBlobsDAO;
 import org.apache.james.blob.objectstorage.ObjectStorageBlobsDAOBuilder;
-import org.apache.james.blob.objectstorage.PayloadCodec;
 import org.apache.james.blob.objectstorage.swift.SwiftKeystone2ObjectStorage;
 import org.apache.james.blob.objectstorage.swift.SwiftKeystone3ObjectStorage;
 import org.apache.james.blob.objectstorage.swift.SwiftTempAuthObjectStorage;
@@ -54,12 +53,6 @@ public class ObjectStorageDependenciesModule extends AbstractModule {
 
     @Provides
     @Singleton
-    private PayloadCodec buildPayloadCodec(ObjectStorageBlobConfiguration configuration)
{
-        return configuration.getPayloadCodecFactory().create(configuration);
-    }
-
-    @Provides
-    @Singleton
     private ObjectStorageBlobConfiguration getObjectStorageConfiguration(PropertiesProvider
propertiesProvider) throws ConfigurationException {
         try {
             Configuration configuration = propertiesProvider.getConfiguration(ConfigurationComponent.NAME);
@@ -75,6 +68,7 @@ public class ObjectStorageDependenciesModule extends AbstractModule {
         ObjectStorageBlobsDAO dao = selectDaoBuilder(configuration)
             .container(configuration.getNamespace())
             .blobIdFactory(blobIdFactory)
+            .payloadCodec(configuration.getPayloadCodec())
             .build();
         dao.createContainer(configuration.getNamespace()).get(1, TimeUnit.MINUTES);
         return dao;

http://git-wip-us.apache.org/repos/asf/james-project/blob/f454266f/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/CassandraRabbitMQJamesServerTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/CassandraRabbitMQJamesServerTest.java
b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/CassandraRabbitMQJamesServerTest.java
index 61fe428..2ab287d 100644
--- a/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/CassandraRabbitMQJamesServerTest.java
+++ b/server/container/guice/cassandra-rabbitmq-guice/src/test/java/org/apache/james/CassandraRabbitMQJamesServerTest.java
@@ -23,6 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.awaitility.Duration.ONE_HUNDRED_MILLISECONDS;
 import static org.junit.jupiter.api.TestInstance.Lifecycle;
 
+import org.apache.james.blob.objectstorage.AESPayloadCodec;
 import org.apache.james.blob.objectstorage.DefaultPayloadCodec;
 import org.apache.james.blob.objectstorage.PayloadCodec;
 import org.apache.james.core.Domain;
@@ -94,21 +95,18 @@ class CassandraRabbitMQJamesServerTest {
     @TestInstance(Lifecycle.PER_CLASS)
     class WithEncryptedSwift implements ContractSuite {
         @RegisterExtension
-        JamesServerExtension testExtension = new JamesServerExtensionBuilder()
-            .extension(new EmbeddedElasticSearchExtension())
-            .extension(new CassandraExtension())
-            .extension(new RabbitMQExtension())
+        JamesServerExtension testExtension = baseExtensionBuilder()
             .extension(new SwiftBlobStoreExtension(PayloadCodecFactory.AES256))
             .server(CONFIGURATION_BUILDER)
             .build();
 
         @Test
-        void encryptedPayloadShouldBeConfiguredWhenProvidingEncryptedPayloadConfigurationButNot(GuiceJamesServer
jamesServer) {
+        void encryptedPayloadShouldBeConfiguredWhenProvidingEncryptedPayloadConfiguration(GuiceJamesServer
jamesServer) {
             PayloadCodec payloadCodec = jamesServer.getProbe(DockerSwiftTestRule.TestSwiftBlobStoreProbe.class)
                 .getSwiftPayloadCodec();
 
             assertThat(payloadCodec)
-                .isInstanceOf(DefaultPayloadCodec.class);
+                .isInstanceOf(AESPayloadCodec.class);
         }
     }
 
@@ -116,12 +114,8 @@ class CassandraRabbitMQJamesServerTest {
     @TestInstance(Lifecycle.PER_CLASS)
     class WithDefaultSwift implements ContractSuite {
         @RegisterExtension
-        JamesServerExtension testExtension = new JamesServerExtensionBuilder()
-            .extension(new EmbeddedElasticSearchExtension())
-            .extension(new CassandraExtension())
-            .extension(new RabbitMQExtension())
+        JamesServerExtension testExtension = baseExtensionBuilder()
             .extension(new SwiftBlobStoreExtension())
-            .server(CONFIGURATION_BUILDER)
             .build();
 
         @Test
@@ -138,11 +132,14 @@ class CassandraRabbitMQJamesServerTest {
     @TestInstance(Lifecycle.PER_CLASS)
     class WithoutSwift implements ContractSuite {
         @RegisterExtension
-        JamesServerExtension testExtension = new JamesServerExtensionBuilder()
+        JamesServerExtension testExtension = baseExtensionBuilder().build();
+    }
+
+    private static JamesServerExtensionBuilder baseExtensionBuilder() {
+        return new JamesServerExtensionBuilder()
             .extension(new EmbeddedElasticSearchExtension())
             .extension(new CassandraExtension())
             .extension(new RabbitMQExtension())
-            .server(CONFIGURATION_BUILDER)
-            .build();
+            .server(CONFIGURATION_BUILDER);
     }
 }


---------------------------------------------------------------------
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