You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2020/10/06 08:22:09 UTC
[james-project] 05/06: JAMES-3401 Add integration test for
unsupported Filter on MailboxQuery/EmailQuery
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit df59bae53c7723e2fb866be5b7b4980fba999b9a
Author: duc91 <vd...@linagora.com>
AuthorDate: Mon Oct 5 11:59:30 2020 +0700
JAMES-3401 Add integration test for unsupported Filter on MailboxQuery/EmailQuery
---
.../contract/EmailQueryMethodContract.scala | 39 ++++++++++++++++++++++
.../contract/MailboxQueryMethodContract.scala | 39 ++++++++++++++++++++++
2 files changed, 78 insertions(+)
diff --git a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailQueryMethodContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailQueryMethodContract.scala
index 3465b6a..fd75e05 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailQueryMethodContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailQueryMethodContract.scala
@@ -5456,6 +5456,45 @@ trait EmailQueryMethodContract {
}
@Test
+ def shouldReturnInvalidArgumentsWhenInvalidFilterCondition(): Unit = {
+ val request =
+ s"""{
+ | "using": [
+ | "urn:ietf:params:jmap:core",
+ | "urn:ietf:params:jmap:mail"],
+ | "methodCalls": [[
+ | "Email/query",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "filter":{
+ | "unsupported_option": "blahh_blahh",
+ | "role":"Inbox"
+ | }
+ | },
+ | "c1"]]
+ |}""".stripMargin
+
+ val response = `given`
+ .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+ .body(request)
+ .when
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .contentType(JSON)
+ .extract
+ .body
+ .asString
+
+ assertThatJson(response)
+ .inPath("methodResponses[0][1]")
+ .isEqualTo(
+ """{
+ | "type":"invalidArguments","description":"{\"errors\":[{\"path\":\"obj.filter\",\"messages\":[\"Unsupported filter\"]}]}"}
+ """.stripMargin)
+ }
+
+ @Test
def priorityOfNestedOperatorsShouldBePreserved(server: GuiceJamesServer): Unit = {
val message: Message = buildTestMessage
server.getProbe(classOf[MailboxProbeImpl]).createMailbox(MailboxPath.inbox(BOB))
diff --git a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxQueryMethodContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxQueryMethodContract.scala
index 76a6ec2..ac6599d 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxQueryMethodContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxQueryMethodContract.scala
@@ -438,6 +438,45 @@ trait MailboxQueryMethodContract {
}
@Test
+ def shouldReturnInvalidArgumentsWhenInvalidFilterCondition(): Unit = {
+ val request =
+ s"""{
+ | "using": [
+ | "urn:ietf:params:jmap:core",
+ | "urn:ietf:params:jmap:mail"],
+ | "methodCalls": [[
+ | "Mailbox/query",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "filter":{
+ | "unsupported_option": "blahh_blahh",
+ | "role":"Inbox"
+ | }
+ | },
+ | "c1"]]
+ |}""".stripMargin
+
+ val response = `given`
+ .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+ .body(request)
+ .when
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .contentType(JSON)
+ .extract
+ .body
+ .asString
+
+ assertThatJson(response)
+ .inPath("methodResponses[0][1]")
+ .isEqualTo(
+ """{
+ | "type":"invalidArguments","description":"{\"errors\":[{\"path\":\"obj.filter\",\"messages\":[\"Unsupported filter\"]}]}"}
+ """.stripMargin)
+ }
+
+ @Test
def filterShouldBeCompulsory(): Unit = {
val request =
s"""{
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org