chibenwa commented on code in PR #2624: URL: https://github.com/apache/james-project/pull/2624#discussion_r1942613046
########## server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailSubmissionSetMethodContract.scala: ########## @@ -1877,6 +1877,61 @@ trait EmailSubmissionSetMethodContract { |}""".stripMargin) } + @Test + def setShouldRejectWhenMissingFromMimeField(server: GuiceJamesServer): Unit = { + val message: Message = Message.Builder + .of + .setSubject("test") + .setTo(ANDRE.asString) + .setBody("testmail", StandardCharsets.UTF_8) + .build + + val bobDraftsPath = MailboxPath.forUser(BOB, DefaultMailboxes.DRAFTS) + server.getProbe(classOf[MailboxProbeImpl]).createMailbox(bobDraftsPath) + val messageId: MessageId = server.getProbe(classOf[MailboxProbeImpl]).appendMessage(BOB.asString(), bobDraftsPath, AppendCommand.builder() + .build(message)) + .getMessageId + + val requestBob = + s"""{ + | "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail", "urn:ietf:params:jmap:submission"], + | "methodCalls": [ + | ["EmailSubmission/set", { + | "accountId": "$ACCOUNT_ID", + | "create": { + | "k1490": { + | "emailId": "${messageId.serialize}", + | "envelope": { + | "mailFrom": {"email": "${BOB.asString}"}, + | "rcptTo": [{"email": "${ANDRE.asString}"}] + | } + | } + | } + | }, "c1"]] + |}""".stripMargin + + val response = `given` + .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER) + .body(requestBob) + .when + .post + .`then` + .statusCode(SC_OK) + .contentType(JSON) + .extract + .body + .asString + + assertThatJson(response) + .inPath("methodResponses[0][1].notCreated") + .isEqualTo("""{ + | "k1490": { + | "type": "invalidArguments", Review Comment: This should be forbiddenHeaderFrom IMO (as we forbid that there's none!) the failure will be more informative. -- 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-unsubscr...@james.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org