james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [02/21] james-project git commit: JAMES-2455 GET group members should not be impacted by other mappings
Date Fri, 06 Jul 2018 09:27:28 GMT
JAMES-2455 GET group members should not be impacted by other mappings


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

Branch: refs/heads/master
Commit: d79d4529c6f2236517d7a1cd4c9eeffe93450be6
Parents: deea61d
Author: benwa <btellier@linagora.com>
Authored: Thu Jul 5 10:03:57 2018 +0700
Committer: benwa <btellier@linagora.com>
Committed: Thu Jul 5 12:14:35 2018 +0700

----------------------------------------------------------------------
 .../james/webadmin/routes/GroupsRoutes.java     |  5 ++-
 .../james/webadmin/routes/GroupsRoutesTest.java | 41 ++++++++++++++++++++
 2 files changed, 44 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/d79d4529/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/GroupsRoutes.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/GroupsRoutes.java
b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/GroupsRoutes.java
index 85771f8..7f7a6ed 100644
--- a/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/GroupsRoutes.java
+++ b/server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/GroupsRoutes.java
@@ -236,11 +236,12 @@ public class GroupsRoutes implements Routes {
     })
     public ImmutableSortedSet<String> listGroupMembers(Request request, Response response)
throws RecipientRewriteTable.ErrorMappingException, RecipientRewriteTableException {
         MailAddress groupAddress = parseMailAddress(request.params(GROUP_ADDRESS));
-        Mappings mappings = recipientRewriteTable.getMappings(groupAddress.getLocalPart(),
groupAddress.getDomain());
+        Mappings mappings = recipientRewriteTable.getMappings(groupAddress.getLocalPart(),
groupAddress.getDomain())
+            .select(Mapping.Type.Group);
 
         ensureNonEmptyMappings(mappings);
 
-        return mappings.select(Mapping.Type.Group)
+        return mappings
                 .asStream()
                 .map(Mapping::asMailAddress)
                 .flatMap(OptionalUtils::toStream)

http://git-wip-us.apache.org/repos/asf/james-project/blob/d79d4529/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java
b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java
index 5da0d8c..805aa43 100644
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/GroupsRoutesTest.java
@@ -41,6 +41,7 @@ import org.apache.james.domainlist.memory.MemoryDomainList;
 import org.apache.james.metrics.logger.DefaultMetricFactory;
 import org.apache.james.rrt.api.RecipientRewriteTable;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
+import org.apache.james.rrt.lib.Mapping;
 import org.apache.james.rrt.lib.MappingSource;
 import org.apache.james.rrt.memory.MemoryRecipientRewriteTable;
 import org.apache.james.user.api.UsersRepository;
@@ -171,6 +172,46 @@ class GroupsRoutesTest {
         }
 
         @Test
+        void getGroupShouldReturnNotFoundWhenNonGroupMappings() {
+            memoryRecipientRewriteTable.addMapping(
+                MappingSource.fromDomain(DOMAIN),
+                Mapping.domain(Domain.of("target.tld")));
+
+            Map<String, Object> errors = when()
+                .get(GROUP1)
+            .then()
+                .statusCode(HttpStatus.NOT_FOUND_404)
+                .contentType(ContentType.JSON)
+                .extract()
+                .body()
+                .jsonPath()
+                .getMap(".");
+
+            assertThat(errors)
+                .containsEntry("statusCode", HttpStatus.NOT_FOUND_404)
+                .containsEntry("type", "InvalidArgument")
+                .containsEntry("message", "The group does not exist");
+        }
+
+        @Test
+        void getGroupShouldReturnNotFoundWhenNoGroupMappings() {
+            Map<String, Object> errors = when()
+                .get(GROUP1)
+            .then()
+                .statusCode(HttpStatus.NOT_FOUND_404)
+                .contentType(ContentType.JSON)
+                .extract()
+                .body()
+                .jsonPath()
+                .getMap(".");
+
+            assertThat(errors)
+                .containsEntry("statusCode", HttpStatus.NOT_FOUND_404)
+                .containsEntry("type", "InvalidArgument")
+                .containsEntry("message", "The group does not exist");
+        }
+
+        @Test
         void putUserInGroupShouldReturnNoContent() {
             when()
                 .put(GROUP1 + SEPARATOR + USER_A)


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