You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ad...@apache.org on 2016/07/04 14:46:19 UTC
[4/5] james-project git commit: JAMES-1788 Ignoring size limit
control for now
JAMES-1788 Ignoring size limit control for now
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/5fc0e783
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/5fc0e783
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/5fc0e783
Branch: refs/heads/master
Commit: 5fc0e7831796084d9ef2c132156dd17f423d1a28
Parents: 447b5dc
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Fri Jul 1 14:56:17 2016 +0200
Committer: Raphael Ouazana <ra...@linagora.com>
Committed: Mon Jul 4 14:57:38 2016 +0200
----------------------------------------------------------------------
.../integration/cucumber/UploadStepdefs.java | 47 ++++++++++++++++++++
.../resources/cucumber/UploadEndpoint.feature | 5 +++
2 files changed, 52 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/5fc0e783/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UploadStepdefs.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UploadStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UploadStepdefs.java
index bb31263..10023ac 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UploadStepdefs.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UploadStepdefs.java
@@ -21,10 +21,14 @@ package org.apache.james.jmap.methods.integration.cucumber;
import static com.jayway.restassured.RestAssured.with;
+import java.io.BufferedInputStream;
+import java.io.InputStream;
+
import javax.inject.Inject;
import org.apache.james.jmap.api.access.AccessToken;
+import com.jayway.restassured.http.ContentType;
import com.jayway.restassured.response.Response;
import com.jayway.restassured.specification.RequestSpecification;
@@ -34,6 +38,8 @@ import cucumber.runtime.java.guice.ScenarioScoped;
@ScenarioScoped
public class UploadStepdefs {
+ private static final int _1M = 1024 * 1024;
+ private static final int _10M = 10 * _1M;
private final UserStepdefs userStepdefs;
private Response response;
@@ -54,6 +60,19 @@ public class UploadStepdefs {
.post("/upload");
}
+ @When("^\"([^\"]*)\" upload a too big content$")
+ public void userUploadTooBigContent(String username) throws Throwable {
+ AccessToken accessToken = userStepdefs.tokenByUser.get(username);
+ RequestSpecification with = with();
+ if (accessToken != null) {
+ with.header("Authorization", accessToken.serialize());
+ }
+ response = with
+ .contentType(ContentType.BINARY)
+ .content(new BufferedInputStream(new ZeroedInputStream(_10M), _10M))
+ .post("/upload");
+ }
+
@When("^\"([^\"]*)\" checks for the availability of the upload endpoint$")
public void optionUpload(String username) throws Throwable {
AccessToken accessToken = userStepdefs.tokenByUser.get(username);
@@ -82,4 +101,32 @@ public class UploadStepdefs {
response.then()
.statusCode(401);
}
+
+ @Then("^the user should receive a request entity too large response$")
+ public void httpRequestEntityTooBigStatus() throws Exception {
+ response.then()
+ .statusCode(413);
+ }
+
+ public static class ZeroedInputStream extends InputStream {
+ public static final int RETURNED_VALUE = 0;
+
+ private final int max;
+ private int pos;
+
+ public ZeroedInputStream(int max) {
+ this.max = max;
+ this.pos = 0;
+ }
+
+ @Override
+ public int read() {
+ if (pos < max) {
+ pos++;
+ return RETURNED_VALUE;
+ }
+ return -1;
+ }
+ }
+
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/5fc0e783/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/UploadEndpoint.feature
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/UploadEndpoint.feature b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/UploadEndpoint.feature
index 6564f60..1379ddf 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/UploadEndpoint.feature
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/UploadEndpoint.feature
@@ -18,6 +18,11 @@ Feature: An upload endpoint should be available to upload contents
When "non-authenticated@domain.tld" upload a content
Then the user should receive a not authorized response
+ @Ignore
+ Scenario: Uploading a too big content
+ When "username@domain.tld" upload a too big content
+ Then the user should receive a request entity too large response
+
Scenario: Uploading a content being authenticated
When "username@domain.tld" upload a content
Then the user should receive a created response
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org