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 2018/09/06 07:54:45 UTC
[2/6] james-project git commit: JAMES-2428 Add some missing webadmin
DLP endpoints
JAMES-2428 Add some missing webadmin DLP endpoints
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/2139e383
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/2139e383
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/2139e383
Branch: refs/heads/master
Commit: 2139e38317c1f6b9fa832743e0358cacbd99d3a0
Parents: 01160d0
Author: Benoit Tellier <bt...@linagora.com>
Authored: Fri Aug 31 11:00:02 2018 +0700
Committer: Antoine Duprat <ad...@linagora.com>
Committed: Thu Sep 6 09:49:34 2018 +0200
----------------------------------------------------------------------
.../routes/DLPConfigurationRoutesTest.java | 127 +++++++++++++++++++
1 file changed, 127 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/2139e383/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DLPConfigurationRoutesTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DLPConfigurationRoutesTest.java b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DLPConfigurationRoutesTest.java
index 72d5a8a..6887cc9 100644
--- a/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DLPConfigurationRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/DLPConfigurationRoutesTest.java
@@ -331,6 +331,133 @@ class DLPConfigurationRoutesTest {
.body("message", is("Invalid request for domain: dr@strange.com"))
.body("details", is("Domain can not be empty nor contain `@`"));
}
+
+ @Test
+ void putShouldUpdateTheConfigurations() {
+ String storeBody =
+ "{\"rules\": [" +
+ " {" +
+ " \"id\": \"1\"," +
+ " \"expression\": \"expression 1\"," +
+ " \"explanation\": \"explanation 1\"," +
+ " \"targetsSender\": true," +
+ " \"targetsRecipients\": true," +
+ " \"targetsContent\": true" +
+ " }," +
+ " {" +
+ " \"id\": \"2\"," +
+ " \"expression\": \"expression 2\"," +
+ " \"explanation\": \"explanation 2\"," +
+ " \"targetsSender\": false," +
+ " \"targetsRecipients\": false," +
+ " \"targetsContent\": false" +
+ " }," +
+ " {" +
+ " \"id\": \"3\"," +
+ " \"expression\": \"expression 3\"," +
+ " \"explanation\": \"explanation 3\"," +
+ " \"targetsSender\": false," +
+ " \"targetsRecipients\": false," +
+ " \"targetsContent\": true" +
+ " }]}";
+ String updatedBody =
+ "{\"rules\": [" +
+ " {" +
+ " \"id\": \"4\"," +
+ " \"expression\": \"expression 4\"," +
+ " \"explanation\": \"explanation 4\"," +
+ " \"targetsSender\": true," +
+ " \"targetsRecipients\": true," +
+ " \"targetsContent\": true" +
+ " }," +
+ " {" +
+ " \"id\": \"2\"," +
+ " \"expression\": \"expression 2\"," +
+ " \"explanation\": \"explanation 2\"," +
+ " \"targetsSender\": false," +
+ " \"targetsRecipients\": false," +
+ " \"targetsContent\": false" +
+ " }," +
+ " {" +
+ " \"id\": \"3\"," +
+ " \"expression\": \"expression 3 updated\"," +
+ " \"explanation\": \"explanation 3 updated\"," +
+ " \"targetsSender\": false," +
+ " \"targetsRecipients\": false," +
+ " \"targetsContent\": true" +
+ " }]}";
+
+ given()
+ .body(storeBody)
+ .when()
+ .put(DEFAULT_DOMAIN)
+ .then()
+ .statusCode(HttpStatus.NO_CONTENT_204);
+
+ given()
+ .body(updatedBody)
+ .when()
+ .put(DEFAULT_DOMAIN)
+ .then()
+ .statusCode(HttpStatus.NO_CONTENT_204);
+
+ String retrievedBody = with()
+ .get(DEFAULT_DOMAIN)
+ .then()
+ .statusCode(HttpStatus.OK_200)
+ .contentType(ContentType.JSON)
+ .extract()
+ .body().asString();
+
+ assertThatJson(retrievedBody).isEqualTo(updatedBody);
+ }
+
+ @Test
+ void putShouldClearTheConfigurationsWhenNoRule() {
+ String storeBody =
+ "{\"rules\": [" +
+ " {" +
+ " \"id\": \"1\"," +
+ " \"expression\": \"expression 1\"," +
+ " \"explanation\": \"explanation 1\"," +
+ " \"targetsSender\": true," +
+ " \"targetsRecipients\": true," +
+ " \"targetsContent\": true" +
+ " }," +
+ " {" +
+ " \"id\": \"2\"," +
+ " \"expression\": \"expression 2\"," +
+ " \"explanation\": \"explanation 2\"," +
+ " \"targetsSender\": false," +
+ " \"targetsRecipients\": false," +
+ " \"targetsContent\": false" +
+ " }]}";
+ String updatedBody = "{\"rules\": []}";
+
+ given()
+ .body(storeBody)
+ .when()
+ .put(DEFAULT_DOMAIN)
+ .then()
+ .statusCode(HttpStatus.NO_CONTENT_204);
+
+ given()
+ .body(updatedBody)
+ .when()
+ .put(DEFAULT_DOMAIN)
+ .then()
+ .statusCode(HttpStatus.NO_CONTENT_204);
+
+ String retrievedBody = with()
+ .get(DEFAULT_DOMAIN)
+ .then()
+ .statusCode(HttpStatus.OK_200)
+ .contentType(ContentType.JSON)
+ .extract()
+ .body().asString();
+
+ assertThatJson(retrievedBody).isEqualTo(updatedBody);
+ }
}
@Nested
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org