You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by GitBox <gi...@apache.org> on 2022/11/24 10:30:02 UTC
[GitHub] [james-project] quantranhong1999 commented on a diff in pull request #1320: JAMES-3461 - Fix Mailbox/changes do not take isSubscribe changes into account
quantranhong1999 commented on code in PR #1320:
URL: https://github.com/apache/james-project/pull/1320#discussion_r1031347624
##########
server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala:
##########
@@ -7981,4 +8000,101 @@ trait MailboxSetMethodContract {
.statusCode(SC_OK)
.body("methodResponses[0][1].oldState", not(equalTo(state)))
}
+
+ @Test
+ def webSocketShouldPushNewMessageWhenChangeSubscriptionOfMailbox(server: GuiceJamesServer): Unit = {
+ val bobPath = MailboxPath.inbox(BOB)
+ val mailboxId = server.getProbe(classOf[MailboxProbeImpl]).createMailbox(bobPath)
+ Thread.sleep(100)
+
+ val socketPort = server.getProbe(classOf[JmapGuiceProbe])
+ .getJmapPort
+ .getValue
+
+ val response: Either[String, List[String]] =
+ basicRequest.get(Uri.apply(new URI(s"ws://127.0.0.1:$socketPort/jmap/ws")))
+ .header("Authorization", "Basic Ym9iQGRvbWFpbi50bGQ6Ym9icGFzc3dvcmQ=")
+ .header("Accept", ACCEPT_RFC8621_VERSION_HEADER)
+ .response(asWebSocket[Identity, List[String]] {
+ ws =>
+ ws.send(WebSocketFrame.text(
+ """{
+ | "@type": "WebSocketPushEnable",
+ | "dataTypes": ["Mailbox"]
+ |}""".stripMargin))
+
+ Thread.sleep(100)
+
+ ws.send(WebSocketFrame.text(
+ s"""{
+ | "@type": "Request",
+ | "id": "req-36",
+ | "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"],
+ | "methodCalls": [
+ | ["Mailbox/set", {
+ | "accountId": "$ACCOUNT_ID",
+ | "update": {
+ | "${mailboxId.serialize}" : {
+ | "isSubscribed": true
+ | }
+ | }
+ | }, "c1"]]
+ |}""".stripMargin))
+
+ List(ws.receive()
+ .map { case t: Text =>
+ t.payload
+ })
+ })
+ .send(backend)
+ .body
+
+ Thread.sleep(200)
+ assertThat(response.toOption.get.asJava)
+ .hasSize(1)
+ assertThat(response.toOption.get.head)
+ .startsWith("{\"@type\":\"StateChange\",\"changed\":{\"29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6\":{\"Mailbox\":")
+ }
+
+ @Test
+ def sseShouldHasNewEventWhenChangeSubscribeOfMailbox(server: GuiceJamesServer): Unit = {
Review Comment:
CI:
```java
Error Message
Assertion condition defined as a lambda expression in org.apache.james.jmap.rfc8621.contract.MailboxSetMethodContract that uses scala.collection.mutable.ListBuffer
Expected size: 1 but was: 0 in:
[] within 1 minutes 40 seconds.
Stacktrace
org.awaitility.core.ConditionTimeoutException:
Assertion condition defined as a lambda expression in org.apache.james.jmap.rfc8621.contract.MailboxSetMethodContract that uses scala.collection.mutable.ListBuffer
Expected size: 1 but was: 0 in:
[] within 1 minutes 40 seconds.
Caused by: java.lang.AssertionError:
Expected size: 1 but was: 0 in:
[]
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org