Skip to content

Commit

Permalink
Try to fix tests in LinagoraCalendarEventAcceptMethodContract
Browse files Browse the repository at this point in the history
- Not fixed :(
  • Loading branch information
HoussemNasri committed Dec 19, 2024
1 parent 5a58fc5 commit 0adf9d3
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
To: Bob <[email protected]>
From: Alice <[email protected]>
Subject: Event Invitation from Alice
Message-ID: <[email protected]>
Date: Tue, 5 Sep 2017 09:54:16 +0200
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="------------D24E361990BDBA143D4D8794"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------D24E361990BDBA143D4D8794
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
The message has a text attachment.
--------------D24E361990BDBA143D4D8794
Content-Type: text/calendar; charset=UTF-8; method=REQUEST
Content-Disposition: attachment;
Content-Transfer-Encoding: base64
QkVHSU46VkNBTEVOREFSClBST0RJRDotLy9BbGlhc291cmNlIEdyb3VwZSBMSU5BR09SQS8vT0JNIENhbGVuZGFyIDM
uMi4xLXJjMi8vRlIKQ0FMU0NBTEU6R1JFR09SSUFOClgtT0JNLVRJTUU6MTQ4MzcwMzQzNgpWRVJTSU9OOjIuMApNRV
RIT0Q6UkVRVUVTVApCRUdJTjpWRVZFTlQKQ1JFQVRFRDoyMDE3MDEwNlQxMTUwMzVaCkxBU1QtTU9ESUZJRUQ6MjAxN
zAxMDZUMTE1MDM2WgpEVFNUQU1QOjIwMTcwMTA2VDExNTAzNloKRFRTVEFSVDoyMDE3MDExMVQwOTAwMDBaCkRVUkFU
SU9OOlBUMUgzME0KVFpJRDpBc2lhL0hvX0NoaV9NaW5oClRSQU5TUDpPUEFRVUUKU0VRVUVOQ0U6MApTVU1NQVJZOlN
wcmludCBwbGFubmluZyAjMjMKREVTQ1JJUFRJT046IGRlc2NyaXB0aW9uIDEyMwpDTEFTUzpQVUJMSUMKUFJJT1JJVF
k6NQpPUkdBTklaRVI7WC1PQk0tSUQ9MTI4O0NOPVJhcGhhZWwgT1VBWkFOQTpNQUlMVE86YWxpY2VAZG9tYWluLnRsZ
ApYLU9QRU5QQUFTLVZJREVPQ09ORkVSRU5DRTpodHRwczovL2ppdHNpLmxpbmFnb3JhLmNvbS9hYmNkCkxPQ0FUSU9O
OkhhbmdvdXQKUlJVTEU6RlJFUT1ZRUFSTFk7QllNT05USD0xMDtCWURBWT1NTztCWVNFVFBPUz0xLDI7VU5USUw9MjA
yNDAxMTFUMDkwMDAwWgpFWFJVTEU6RlJFUT1ZRUFSTFk7QllNT05USD0xMDtCWURBWT1NTztCWVNFVFBPUz0xO1VOVE
lMPTIwMjMwMTExVDA5MDAwMFoKQ0FURUdPUklFUzoKVUlEOmVhMTI3NjkwLTA0NDAtNDA0Yi1hZjk4LTk4MjNjODU1Y
TI4MwpBVFRFTkRFRTtDVVRZUEU9SU5ESVZJRFVBTDtST0xFPUFETUlOO1JTVlA9VFJVRTtDTj1NYXR0aGlldSBFWFRf
QkFFQ0hMRVI7UEFSVFNUQVQ9TkVFCiBEUy1BQ1RJT047WC1PQk0tSUQ9MzAyOk1BSUxUTzphbm90aGVyQGRvbWFpbi5
0bGQKQVRURU5ERUU7Q1VUWVBFPUlORElWSURVQUw7UlNWUD1UUlVFO0NOPUxhdXJhIFJPWUVUO1BBUlRTVEFUPU5FRU
RTLUFDVElPTjsKIFgtT0JNLUlEPTcyMzpNQUlMVE86Ym9iQGRvbWFpbi50bGQKU1RBVFVTOkNPTkZJUk1FRApFTkQ6V
kVWRU5UCkVORDpWQ0FMRU5EQVI=
--------------D24E361990BDBA143D4D8794--
Content-Type: application/ics; name=meeting.ics
Content-Disposition: attachment; filename=meeting.ics
Content-Transfer-Encoding: base64
QkVHSU46VkNBTEVOREFSClBST0RJRDotLy9BbGlhc291cmNlIEdyb3VwZSBMSU5BR09SQS8vT0JNIENhbGVuZGFyIDM
uMi4xLXJjMi8vRlIKQ0FMU0N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1BSUxUTzphbm90aGVyQGRvbWFpbi5
0bGQKQVRURU5ERUU7Q1VUWVBFPUlORElWSURVQUw7UlNWUD1UUlVFO0NOPUxhdXJhIFJPWUVUO1BBUlRTVEFUPU5FRU
RTLUFDVElPTjsKIFgtT0JNLUlEPTcyMzpNQUlMVE86Ym9iQGRvbWFpbi50bGQKU1RBVFVTOkNPTkZJUk1FRApFTkQ6V
kVWRU5UCkVORDpWQ0FMRU5EQVI=
--------------D24E361990BDBA143D4D8794--
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.linagora.tmail.james.common

import java.io.{ByteArrayInputStream, InputStream}
import java.util.concurrent.TimeUnit

import io.netty.handler.codec.http.HttpHeaderNames.ACCEPT
import io.restassured.RestAssured.{`given`, requestSpecification}
import io.restassured.http.ContentType.JSON
Expand All @@ -15,11 +14,13 @@ import org.apache.http.HttpStatus.{SC_CREATED, SC_OK}
import org.apache.james.GuiceJamesServer
import org.apache.james.jmap.core.ResponseObject.SESSION_STATE
import org.apache.james.jmap.http.UserCredential
import org.apache.james.jmap.rfc8621.contract.Fixture.{ACCEPT_RFC8621_VERSION_HEADER, ACCOUNT_ID, ANDRE, ANDRE_ACCOUNT_ID, ANDRE_PASSWORD, BOB, BOB_PASSWORD, DOMAIN, authScheme, baseRequestSpecBuilder}
import org.apache.james.jmap.rfc8621.contract.Fixture._
import org.apache.james.jmap.rfc8621.contract.probe.DelegationProbe
import org.apache.james.jmap.rfc8621.contract.tags.CategoryTags
import org.apache.james.mailbox.MessageManager.AppendCommand
import org.apache.james.mailbox.model.MailboxPath
import org.apache.james.modules.MailboxProbeImpl
import org.apache.james.util.ClassLoaderUtils
import org.apache.james.utils.DataProbeImpl
import org.hamcrest.Matchers
import org.junit.jupiter.api.{BeforeEach, Tag, Test}
Expand All @@ -44,8 +45,18 @@ trait LinagoraCalendarEventAcceptMethodContract {
def randomBlobId: String

@Test
def acceptShouldSucceed(): Unit = {
val blobId: String = uploadAndGetBlobId(ClassLoader.getSystemResourceAsStream("ics/aliceInviteBob.ics"))
def acceptShouldSucceed(server: GuiceJamesServer): Unit = {
val mailInputStream = ClassLoaderUtils.getSystemResourceAsSharedStream("emailWithAliceInviteBobIcsAttachment.eml")

server.getProbe(classOf[MailboxProbeImpl]).createMailbox(MailboxPath.inbox(BOB))

val appendResult = server.getProbe(classOf[MailboxProbeImpl])
.appendMessageAndGetAppendResult(
BOB.asString(),
MailboxPath.inbox(BOB),
AppendCommand.from(mailInputStream))

// val blobId: String = uploadAndGetBlobId(ClassLoader.getSystemResourceAsStream("ics/aliceInviteBob.ics"))

val request: String =
s"""{
Expand All @@ -56,7 +67,7 @@ trait LinagoraCalendarEventAcceptMethodContract {
| "CalendarEvent/accept",
| {
| "accountId": "$ACCOUNT_ID",
| "blobIds": [ "$blobId" ]
| "blobIds": [ "${appendResult.getMessageAttachments.getFirst.getAttachmentId}" ]
| },
| "c1"]]
|}""".stripMargin
Expand All @@ -80,7 +91,7 @@ trait LinagoraCalendarEventAcceptMethodContract {
| "CalendarEvent/accept",
| {
| "accountId": "$ACCOUNT_ID",
| "accepted": [ "$blobId" ]
| "accepted": [ "${appendResult.getMessageAttachments.getFirst.getAttachmentId}" ]
| },
| "c1"
|]""".stripMargin)
Expand Down Expand Up @@ -570,6 +581,7 @@ trait LinagoraCalendarEventAcceptMethodContract {
@Test
def shouldSucceedWhenDelegated(server: GuiceJamesServer): Unit = {
val blobId: String = uploadAndGetBlobId(ClassLoader.getSystemResourceAsStream("ics/aliceInviteBob.ics"))
println(blobId)
server.getProbe(classOf[DelegationProbe]).addAuthorizedUser(BOB, ANDRE)

val bobAccountId = ACCOUNT_ID
Expand Down

0 comments on commit 0adf9d3

Please sign in to comment.