You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ad...@apache.org on 2017/11/21 16:40:52 UTC

[3/7] james-project git commit: JAMES-2225 Encoded slashes should be allowed in group API

JAMES-2225 Encoded slashes should be allowed in group API


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

Branch: refs/heads/master
Commit: 66295df5ce845ff5da2facac315ccda8ed296c26
Parents: 5ae8fa2
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Mon Nov 20 10:53:21 2017 +0100
Committer: Raphael Ouazana <ra...@linagora.com>
Committed: Mon Nov 20 15:04:30 2017 +0100

----------------------------------------------------------------------
 .../james/webadmin/routes/GroupsRoutesTest.java | 36 ++++++++++++++++++++
 1 file changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/66295df5/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 9cda34c..26c8ebc 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
@@ -67,6 +67,8 @@ public class GroupsRoutesTest {
     private static final String DOMAIN = "b.com";
     private static final String GROUP1 = "group1" + "@" + DOMAIN;
     private static final String GROUP2 = "group2" + "@" + DOMAIN;
+    private static final String GROUP_WITH_SLASH = "group10/10" + "@" + DOMAIN;
+    private static final String GROUP_WITH_ENCODED_SLASH = "group10%2F10" + "@" + DOMAIN;
     private static final String USER_A = "a" + "@" + DOMAIN;
     private static final String USER_B = "b" + "@" + DOMAIN;
 
@@ -177,6 +179,32 @@ public class GroupsRoutesTest {
         }
 
         @Test
+        public void putUserInGroupWithEncodedSlashShouldReturnCreated() {
+            when()
+                .put(GROUP_WITH_ENCODED_SLASH + SEPARATOR + USER_A)
+            .then()
+                .statusCode(HttpStatus.CREATED_201);
+        }
+
+        @Test
+        public void putUserInGroupWithEncodedSlashShouldCreateGroup() {
+            when()
+                .put(GROUP_WITH_ENCODED_SLASH + SEPARATOR + USER_A);
+
+            List<String> addresses =
+                when()
+                    .get(GROUP_WITH_ENCODED_SLASH)
+                .then()
+                    .contentType(ContentType.JSON)
+                    .statusCode(HttpStatus.OK_200)
+                    .extract()
+                    .body()
+                    .jsonPath()
+                    .getList(".");
+            assertThat(addresses).containsExactly(USER_A);
+        }
+
+        @Test
         public void putSameUserInGroupTwiceShouldBeIdempotent() {
             given()
                 .put(GROUP1 + SEPARATOR + USER_A);
@@ -329,6 +357,14 @@ public class GroupsRoutesTest {
         }
 
         @Test
+        public void putUserInGroupWithSlashShouldReturnNotFound() {
+            when()
+                .put(GROUP_WITH_SLASH + SEPARATOR + USER_A)
+            .then()
+                .statusCode(HttpStatus.NOT_FOUND_404);
+        }
+
+        @Test
         public void putMalformedAddressShouldReturnBadRequest() {
             when()
                 .put(GROUP1 + SEPARATOR + "not-an-address")


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