This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
The following commit(s) were added to refs/heads/master by this push:
new c9bacf6 JAMES-3625 JMAP session: Remove trailing / in session
download url (#576)
c9bacf6 is described below
commit c9bacf66df94fc1a3d4458d3bcd16c0d220bcb0d
Author: Tellier Benoit <[email protected]>
AuthorDate: Mon Aug 9 08:49:17 2021 +0700
JAMES-3625 JMAP session: Remove trailing / in session download url (#576)
Also remove upload trailing URL slash
---
.../rfc8621/contract/CustomMethodContract.scala | 4 ++--
.../rfc8621/contract/EmailImportContract.scala | 16 +++++++--------
.../rfc8621/contract/EmailSetMethodContract.scala | 24 +++++++++++-----------
.../rfc8621/contract/SessionRoutesContract.scala | 4 ++--
.../jmap/rfc8621/contract/UploadContract.scala | 10 ++++-----
.../james/jmap/core/JmapRfc8621Configuration.scala | 2 +-
.../apache/james/jmap/routes/UploadRoutes.scala | 16 +++++++--------
.../jmap/core/JmapRfc8621ConfigurationTest.scala | 4 ++--
.../james/jmap/routes/SessionRoutesTest.scala | 2 +-
9 files changed, 41 insertions(+), 41 deletions(-)
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/CustomMethodContract.scala
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/CustomMethodContract.scala
index d879bd6..7edfb4f 100644
---
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/CustomMethodContract.scala
+++
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/CustomMethodContract.scala
@@ -22,6 +22,7 @@ package org.apache.james.jmap.rfc8621.contract
import java.io.{ByteArrayInputStream, InputStream}
import java.net.URI
import java.nio.charset.StandardCharsets
+
import com.google.inject.AbstractModule
import com.google.inject.multibindings.Multibinder
import eu.timepit.refined.auto._
@@ -30,7 +31,6 @@ import eu.timepit.refined.refineV
import io.netty.handler.codec.http.HttpHeaderNames.ACCEPT
import io.restassured.RestAssured._
import io.restassured.http.ContentType.JSON
-
import javax.inject.{Inject, Named}
import net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson
import org.apache.http.HttpStatus.SC_OK
@@ -164,7 +164,7 @@ object CustomMethodContract {
| },
| "username" : "[email protected]",
| "apiUrl" : "http://domain.com/jmap",
- | "downloadUrl" :
"http://domain.com/download/{accountId}/{blobId}/?type={type}&name={name}",
+ | "downloadUrl" :
"http://domain.com/download/{accountId}/{blobId}?type={type}&name={name}",
| "uploadUrl" : "http://domain.com/upload/{accountId}",
| "eventSourceUrl" :
"http://domain.com/eventSource?types={types}&closeAfter={closeafter}&ping={ping}",
| "state" : "2c9f1b12-b35a-43e6-9af2-0106fb53a943"
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/EmailImportContract.scala
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailImportContract.scala
index 18f00c4..e6cf040 100644
---
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailImportContract.scala
+++
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailImportContract.scala
@@ -151,7 +151,7 @@ trait EmailImportContract {
.header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
.body(ClassLoader.getSystemResourceAsStream("eml/alternative.eml"))
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_CREATED)
.extract
@@ -278,7 +278,7 @@ trait EmailImportContract {
.header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
.body(ClassLoader.getSystemResourceAsStream("eml/alternative.eml"))
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_CREATED)
.extract
@@ -290,7 +290,7 @@ trait EmailImportContract {
.header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
.body(ClassLoader.getSystemResourceAsStream("eml/html.eml"))
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_CREATED)
.extract
@@ -428,7 +428,7 @@ trait EmailImportContract {
.header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
.body(ClassLoader.getSystemResourceAsStream("eml/alternative.eml"))
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_CREATED)
.extract
@@ -520,7 +520,7 @@ trait EmailImportContract {
.header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
.body("whatever")
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_CREATED)
.extract
@@ -595,7 +595,7 @@ trait EmailImportContract {
.header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
.body(ClassLoader.getSystemResourceAsStream("eml/alternative.eml"))
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_CREATED)
.extract
@@ -834,7 +834,7 @@ trait EmailImportContract {
.header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
.body("whatever")
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_CREATED)
.extract
@@ -903,7 +903,7 @@ trait EmailImportContract {
.header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
.body("whatever")
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_CREATED)
.extract
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/EmailSetMethodContract.scala
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailSetMethodContract.scala
index f77c7c1..0b05f9a 100644
---
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailSetMethodContract.scala
+++
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailSetMethodContract.scala
@@ -2052,7 +2052,7 @@ trait EmailSetMethodContract {
.contentType("text/plain")
.body(payload)
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_CREATED)
.extract
@@ -2183,7 +2183,7 @@ trait EmailSetMethodContract {
.contentType("text/plain")
.body(payload)
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_CREATED)
.extract
@@ -2252,7 +2252,7 @@ trait EmailSetMethodContract {
.contentType("text/plain")
.body(payload)
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_CREATED)
.extract
@@ -2394,7 +2394,7 @@ trait EmailSetMethodContract {
.contentType("text/plain")
.body(payload)
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_CREATED)
.extract
@@ -2658,7 +2658,7 @@ trait EmailSetMethodContract {
.contentType("text/plain")
.body(payload)
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_CREATED)
.extract
@@ -2832,7 +2832,7 @@ trait EmailSetMethodContract {
.contentType("text/plain")
.body(payload)
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_CREATED)
.extract
@@ -2983,7 +2983,7 @@ trait EmailSetMethodContract {
.contentType("text/plain")
.body(payload)
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_CREATED)
.extract
@@ -3115,7 +3115,7 @@ trait EmailSetMethodContract {
.contentType("text/plain")
.body(payload)
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_CREATED)
.extract
@@ -3261,7 +3261,7 @@ trait EmailSetMethodContract {
.contentType("text/plain")
.body(payload)
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_CREATED)
.extract
@@ -3528,7 +3528,7 @@ trait EmailSetMethodContract {
.contentType("text/plain")
.body(payload)
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_CREATED)
.extract
@@ -3688,7 +3688,7 @@ trait EmailSetMethodContract {
.contentType("text/plain")
.body(payload)
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_CREATED)
.extract
@@ -3968,7 +3968,7 @@ trait EmailSetMethodContract {
.contentType("text/plain")
.body(payload)
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_CREATED)
.extract
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/SessionRoutesContract.scala
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/SessionRoutesContract.scala
index 80e5039..0a22aab 100644
---
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/SessionRoutesContract.scala
+++
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/SessionRoutesContract.scala
@@ -123,7 +123,7 @@ object SessionRoutesContract {
| },
| "username" : "[email protected]",
| "apiUrl" : "http://domain.com/jmap",
- | "downloadUrl" :
"http://domain.com/download/{accountId}/{blobId}/?type={type}&name={name}",
+ | "downloadUrl" :
"http://domain.com/download/{accountId}/{blobId}?type={type}&name={name}",
| "uploadUrl" :
"http://domain.com/upload/{accountId}",
| "eventSourceUrl" :
"http://domain.com/eventSource?types={types}&closeAfter={closeafter}&ping={ping}",
| "state" : "2c9f1b12-b35a-43e6-9af2-0106fb53a943"
@@ -163,7 +163,7 @@ trait SessionRoutesContract {
.get("/session")
.`then`
.statusCode(SC_OK)
- .header("Content-Length", "3026")
+ .header("Content-Length", "3025")
.contentType(JSON)
.extract()
.body()
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/UploadContract.scala
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/UploadContract.scala
index ce6066d..2e1faa6 100644
---
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/UploadContract.scala
+++
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/UploadContract.scala
@@ -62,7 +62,7 @@ trait UploadContract {
.header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
.body(VALID_INPUT)
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_CREATED)
.extract
@@ -93,7 +93,7 @@ trait UploadContract {
.header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
.body(VALID_INPUT)
.when
- .post(s"/upload/$ALICE_ACCOUNT_ID/")
+ .post(s"/upload/$ALICE_ACCOUNT_ID")
.`then`
.statusCode(SC_FORBIDDEN)
.header("Content-Length", "84")
@@ -109,7 +109,7 @@ trait UploadContract {
.header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
.body(VALID_INPUT)
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_CREATED)
.extract
@@ -139,7 +139,7 @@ trait UploadContract {
.contentType(ContentType.BINARY)
.body(BIG_INPUT)
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_BAD_REQUEST)
.body("status", equalTo(400))
@@ -157,7 +157,7 @@ trait UploadContract {
.contentType(ContentType.BINARY)
.body(VALID_INPUT)
.when
- .post(s"/upload/$ACCOUNT_ID/")
+ .post(s"/upload/$ACCOUNT_ID")
.`then`
.statusCode(SC_UNAUTHORIZED)
.header("WWW-Authenticate", "Basic realm=\"simple\", Bearer
realm=\"JWT\"")
diff --git
a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/JmapRfc8621Configuration.scala
b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/JmapRfc8621Configuration.scala
index d100f2b..cda97f7 100644
---
a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/JmapRfc8621Configuration.scala
+++
b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/core/JmapRfc8621Configuration.scala
@@ -48,7 +48,7 @@ object JmapRfc8621Configuration {
case class JmapRfc8621Configuration(urlPrefixString: String,
websocketPrefixString: String, maxUploadSize: MaxSizeUpload =
UPLOAD_LIMIT_30_MB) {
val urlPrefix: URL = new URL(urlPrefixString)
val apiUrl: URL = new URL(s"$urlPrefixString/jmap")
- val downloadUrl: URL = new URL(urlPrefixString +
"/download/{accountId}/{blobId}/?type={type}&name={name}")
+ val downloadUrl: URL = new URL(urlPrefixString +
"/download/{accountId}/{blobId}?type={type}&name={name}")
val uploadUrl: URL = new URL(s"$urlPrefixString/upload/{accountId}")
val eventSourceUrl: URL = new
URL(s"$urlPrefixString/eventSource?types={types}&closeAfter={closeafter}&ping={ping}")
val webSocketUrl: URI = new URI(s"$websocketPrefixString/jmap/ws")
diff --git
a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/UploadRoutes.scala
b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/UploadRoutes.scala
index ff30311..4eba28e 100644
---
a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/UploadRoutes.scala
+++
b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/routes/UploadRoutes.scala
@@ -19,9 +19,16 @@
package org.apache.james.jmap.routes
+import java.io.InputStream
+import java.nio.ByteBuffer
+import java.nio.charset.StandardCharsets
+import java.util.stream
+import java.util.stream.Stream
+
import io.netty.handler.codec.http.HttpHeaderNames.{CONTENT_LENGTH,
CONTENT_TYPE}
import io.netty.handler.codec.http.HttpResponseStatus.{BAD_REQUEST, CREATED,
FORBIDDEN, INTERNAL_SERVER_ERROR, UNAUTHORIZED}
import io.netty.handler.codec.http.{HttpMethod, HttpResponseStatus}
+import javax.inject.{Inject, Named}
import org.apache.commons.fileupload.util.LimitedInputStream
import org.apache.james.jmap.HttpConstants.JSON_CONTENT_TYPE
import org.apache.james.jmap.api.model.Size.{Size, sanitizeSize}
@@ -44,13 +51,6 @@ import reactor.core.scala.publisher.SMono
import reactor.core.scheduler.Schedulers
import reactor.netty.http.server.{HttpServerRequest, HttpServerResponse}
-import java.io.InputStream
-import java.nio.ByteBuffer
-import java.nio.charset.StandardCharsets
-import java.util.stream
-import java.util.stream.Stream
-import javax.inject.{Inject, Named}
-
case class TooBigUploadException() extends RuntimeException
object UploadRoutes {
@@ -71,7 +71,7 @@ class UploadRoutes @Inject()(@Named(InjectionKeys.RFC_8621)
val authenticator: A
class MaxFileSizeUploadException extends RuntimeException
private val accountIdParam: String = "accountId"
- private val uploadURI = s"/upload/{$accountIdParam}/"
+ private val uploadURI = s"/upload/{$accountIdParam}"
override def routes(): stream.Stream[JMAPRoute] = Stream.of(
JMAPRoute.builder
diff --git
a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/core/JmapRfc8621ConfigurationTest.scala
b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/core/JmapRfc8621ConfigurationTest.scala
index e8c0005..8bc3c64 100644
---
a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/core/JmapRfc8621ConfigurationTest.scala
+++
b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/core/JmapRfc8621ConfigurationTest.scala
@@ -42,7 +42,7 @@ class JmapRfc8621ConfigurationTest extends AnyWordSpec with
Matchers {
val jmapRfc8621Configuration: JmapRfc8621Configuration =
JmapRfc8621Configuration.from(providedConfiguration())
jmapRfc8621Configuration.apiUrl must be(new
URL("http://random-domain.com/jmap"))
- jmapRfc8621Configuration.downloadUrl must be(new
URL("http://random-domain.com/download/{accountId}/{blobId}/?type={type}&name={name}"))
+ jmapRfc8621Configuration.downloadUrl must be(new
URL("http://random-domain.com/download/{accountId}/{blobId}?type={type}&name={name}"))
jmapRfc8621Configuration.uploadUrl must be(new
URL("http://random-domain.com/upload/{accountId}"))
jmapRfc8621Configuration.eventSourceUrl must be(new
URL("http://random-domain.com/eventSource?types={types}&closeAfter={closeafter}&ping={ping}"))
}
@@ -51,7 +51,7 @@ class JmapRfc8621ConfigurationTest extends AnyWordSpec with
Matchers {
val jmapRfc8621Configuration: JmapRfc8621Configuration =
JmapRfc8621Configuration.from(emptyConfiguration)
jmapRfc8621Configuration.apiUrl must be(new URL("http://localhost/jmap"))
- jmapRfc8621Configuration.downloadUrl must be(new
URL("http://localhost/download/{accountId}/{blobId}/?type={type}&name={name}"))
+ jmapRfc8621Configuration.downloadUrl must be(new
URL("http://localhost/download/{accountId}/{blobId}?type={type}&name={name}"))
jmapRfc8621Configuration.uploadUrl must be(new
URL("http://localhost/upload/{accountId}"))
jmapRfc8621Configuration.eventSourceUrl must be(new
URL("http://localhost/eventSource?types={types}&closeAfter={closeafter}&ping={ping}"))
}
diff --git
a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/routes/SessionRoutesTest.scala
b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/routes/SessionRoutesTest.scala
index 0e81e21..c4833a7 100644
---
a/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/routes/SessionRoutesTest.scala
+++
b/server/protocols/jmap-rfc-8621/src/test/scala/org/apache/james/jmap/routes/SessionRoutesTest.scala
@@ -119,7 +119,7 @@ class SessionRoutesTest extends AnyFlatSpec with
BeforeAndAfter with Matchers {
.thenReturn
.getBody
.asString()
- val downloadPath: String =
"download/{accountId}/{blobId}/?type={type}&name={name}"
+ val downloadPath: String =
"download/{accountId}/{blobId}?type={type}&name={name}"
val expectedJson = s"""{
| "capabilities" : {
| "urn:ietf:params:jmap:submission": {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]