JAMES-2186 cucumber: adapt Upload test to work in stateless context

Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/8e2efe40
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/8e2efe40
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/8e2efe40

Branch: refs/heads/master
Commit: 8e2efe4069da9141e386710b9b6977a2387fd014
Parents: 42b4807
Author: Luc DUZAN <[email protected]>
Authored: Thu Oct 19 16:55:30 2017 +0700
Committer: Matthieu Baechler <[email protected]>
Committed: Mon Oct 23 13:50:39 2017 +0200

----------------------------------------------------------------------
 .../integration/cucumber/UploadStepdefs.java    | 21 ++++++++++++++------
 .../resources/cucumber/UploadEndpoint.feature   |  6 +++---
 2 files changed, 18 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/8e2efe40/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 0f55e73..7c9fa68 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
@@ -107,9 +107,15 @@ public class UploadStepdefs {
         AccessToken accessToken = userStepdefs.getTokenForUser(username);
         Request request = Request.Post(uploadUri)
             .bodyStream(new BufferedInputStream(new ZeroedInputStream(_1M), 
_1M), org.apache.http.entity.ContentType.DEFAULT_BINARY);
-        if (accessToken != null) {
-            request.addHeader("Authorization", accessToken.serialize());
-        }
+
+        request.addHeader("Authorization", accessToken.serialize());
+        response = 
Executor.newInstance(HttpClientBuilder.create().disableAutomaticRetries().build()).execute(request).returnResponse();
+    }
+
+    @When("^someone upload a content without authentification$")
+    public void userUploadContentWithoutAuthentification() throws Throwable {
+        Request request = Request.Post(uploadUri)
+            .bodyStream(new BufferedInputStream(new ZeroedInputStream(_1M), 
_1M), org.apache.http.entity.ContentType.DEFAULT_BINARY);
         response = 
Executor.newInstance(HttpClientBuilder.create().disableAutomaticRetries().build()).execute(request).returnResponse();
     }
 
@@ -139,9 +145,12 @@ public class UploadStepdefs {
     public void optionUpload(String username) throws Throwable {
         AccessToken accessToken = userStepdefs.getTokenForUser(username);
         Request request = Request.Options(uploadUri);
-        if (accessToken != null) {
-            request.addHeader("Authorization", accessToken.serialize());
-        }
+        response = request.execute().returnResponse();
+    }
+
+    @When("^someone checks without authentification for the availability of 
the upload endpoint$")
+    public void optionUploadWithoutAuthentification() throws Throwable {
+        Request request = Request.Options(uploadUri);
         response = request.execute().returnResponse();
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/8e2efe40/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 2a33fd9..42fc889 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
@@ -23,18 +23,18 @@ Feature: An upload endpoint should be available to upload 
contents
 
   Background:
     Given a domain named "domain.tld"
-    And a connected user "[email protected]"
+    And a user "[email protected]"
 
   Scenario: An authenticated user should initiate the access to the upload 
endpoint
     When "[email protected]" checks for the availability of the upload 
endpoint
     Then the user should receive an authorized response
 
   Scenario: An unauthenticated user should initiate the access to the download 
endpoint
-    When "[email protected]" checks for the availability of the 
upload endpoint
+    When someone checks without authentification for the availability of the 
upload endpoint
     Then the user should receive an authorized response
 
   Scenario: Uploading a content without being authenticated
-    When "[email protected]" upload a content
+    When someone upload a content without authentification
     Then the user should receive a not authorized response
 
   @Ignore


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to