james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [2/4] james-project git commit: JAMES-2366 Fix a bug in getAllMappings
Date Wed, 18 Apr 2018 11:43:05 GMT
JAMES-2366 Fix a bug in getAllMappings

We were never actually examining the detailed content of this call.

It turned out to be buggy for both HBASE and Cassandra. I fixed it for Cassandra implementation.


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

Branch: refs/heads/master
Commit: aeda0fff08f81e1c760d4641ae06743f2d15725a
Parents: 01dd746
Author: benwa <btellier@linagora.com>
Authored: Tue Apr 17 15:20:04 2018 +0700
Committer: benwa <btellier@linagora.com>
Committed: Wed Apr 18 18:42:25 2018 +0700

----------------------------------------------------------------------
 .../CassandraRecipientRewriteTable.java         |  2 +-
 .../hbase/HBaseRecipientRewriteTableTest.java   |  7 ++++++
 .../lib/AbstractRecipientRewriteTableTest.java  | 25 ++++++++++++++++++++
 .../WebAdminServerIntegrationTest.java          | 16 +++++++++++++
 4 files changed, 49 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/aeda0fff/server/data/data-cassandra/src/main/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTable.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/main/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTable.java
b/server/data/data-cassandra/src/main/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTable.java
index e4bdd03..0a2b098 100644
--- a/server/data/data-cassandra/src/main/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTable.java
+++ b/server/data/data-cassandra/src/main/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTable.java
@@ -171,7 +171,7 @@ public class CassandraRecipientRewriteTable extends AbstractRecipientRewriteTabl
         }
 
         public String asKey() {
-            return getUser() + "@" + getDomain();
+            return getUser() + "@" + getDomain().asString();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/aeda0fff/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java
b/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java
index d425db9..81e2c59 100644
--- a/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java
+++ b/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java
@@ -28,6 +28,7 @@ import org.apache.james.system.hbase.TablePool;
 import org.apache.james.user.hbase.def.HUsersRepository;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Ignore;
 
 /**
  * Tests for the HBase RecipientRewriteTable implementation.
@@ -60,4 +61,10 @@ public class HBaseRecipientRewriteTableTest extends AbstractRecipientRewriteTabl
         rrt.configure(new DefaultConfigurationBuilder());
         return rrt;
     }
+
+    @Ignore("JAMES-2376 HBASE RRT getAllMappings is buggy")
+    @Override
+    public void getAllMappingsShouldListAllEntries() {
+
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/aeda0fff/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java
b/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java
index 143fb27..69b6d28 100644
--- a/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java
+++ b/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java
@@ -23,6 +23,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import java.util.Map;
 
+import org.apache.commons.lang3.tuple.Pair;
 import org.apache.james.core.Domain;
 import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.james.rrt.api.RecipientRewriteTable;
@@ -113,6 +114,30 @@ public abstract class AbstractRecipientRewriteTableTest {
     }
 
     @Test
+    public void getAllMappingsShouldListAllEntries() throws ErrorMappingException, RecipientRewriteTableException
{
+        String user = "test";
+        String user2 = "test2";
+        String regex = "(.*)@localhost";
+        String regex2 = "(.+)@test";
+
+
+        addMapping(user, Domain.LOCALHOST, regex, Type.Regex);
+        addMapping(user, Domain.LOCALHOST, regex2, Type.Regex);
+        addMapping(user2, Domain.LOCALHOST, user + "@" + Domain.LOCALHOST.asString(), Type.Address);
+
+        assertThat(virtualUserTable.getAllMappings())
+            .describedAs("One mappingline")
+            .containsOnly(
+                Pair.of(user + "@" + Domain.LOCALHOST.asString(), MappingsImpl.builder()
+                    .add(MappingImpl.regex(regex))
+                    .add(MappingImpl.regex(regex2))
+                    .build()),
+                Pair.of(user2 + "@" + Domain.LOCALHOST.asString(), MappingsImpl.builder()
+                    .add(MappingImpl.address(user + "@" + Domain.LOCALHOST.asString()))
+                    .build()));
+    }
+
+    @Test
     public void testStoreAndRetrieveAddressMapping() throws ErrorMappingException, RecipientRewriteTableException
{
 
         String user = "test";

http://git-wip-us.apache.org/repos/asf/james-project/blob/aeda0fff/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
index f2d0d7f..d882331 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
+++ b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
@@ -296,6 +296,22 @@ public class WebAdminServerIntegrationTest {
     }
 
     @Test
+    public void addressForwardsEndpointShouldListForwardAddresses() throws Exception {
+        dataProbe.addForwardMapping("from1", "domain.com", "user1@domain.com");
+        dataProbe.addForwardMapping("from2", "domain.com", "user2@domain.com");
+
+        List<String> members = when()
+            .get("/address/forwards")
+        .then()
+            .statusCode(HttpStatus.OK_200)
+            .contentType(JSON_CONTENT_TYPE)
+            .extract()
+            .jsonPath()
+            .getList(".");
+        assertThat(members).containsOnly("from1@domain.com", "from2@domain.com");
+    }
+
+    @Test
     public void getSwaggerShouldReturnJsonDataForSwagger() throws Exception {
         when()
             .get(SwaggerRoutes.SWAGGER_ENDPOINT)


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