JAMES-2186 cucumber test: make downloads test "stateless"
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/d5ce773f Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/d5ce773f Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/d5ce773f Branch: refs/heads/master Commit: d5ce773f3ba132598de7b5808daba168ef090de3 Parents: 4d28230 Author: Luc DUZAN <[email protected]> Authored: Thu Oct 19 16:32:10 2017 +0700 Committer: Matthieu Baechler <[email protected]> Committed: Mon Oct 23 13:50:39 2017 +0200 ---------------------------------------------------------------------- .../integration/cucumber/DownloadStepdefs.java | 70 +++++++++++++++++--- .../cucumber/GetMessageListMethodStepdefs.java | 2 +- .../cucumber/GetMessagesMethodStepdefs.java | 2 +- .../cucumber/SetMailboxesMethodStepdefs.java | 6 +- .../cucumber/SetMessagesMethodStepdefs.java | 6 +- .../integration/cucumber/UploadStepdefs.java | 12 ++-- .../integration/cucumber/UserStepdefs.java | 15 +++-- .../resources/cucumber/DownloadEndpoint.feature | 8 +-- .../test/resources/cucumber/DownloadGet.feature | 33 +++++---- 9 files changed, 103 insertions(+), 51 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/d5ce773f/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/DownloadStepdefs.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/DownloadStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/DownloadStepdefs.java index 80d378c..6a97810 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/DownloadStepdefs.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/DownloadStepdefs.java @@ -137,7 +137,7 @@ public class DownloadStepdefs { @When("^\"([^\"]*)\" checks for the availability of the attachment endpoint$") public void optionDownload(String username) throws Throwable { - AccessToken accessToken = userStepdefs.tokenByUser.get(username); + AccessToken accessToken = userStepdefs.getTokenForUser(username); URI target = mainStepdefs.baseUri().setPath("/download/" + ONE_ATTACHMENT_EML_ATTACHMENT_BLOB_ID).build(); Request request = Request.Options(target); if (accessToken != null) { @@ -156,6 +156,21 @@ public class DownloadStepdefs { downLoad(username, attachmentIdOrMessageId); } + @When("^un-authenticated user downloads \"([^\"]*)\"$") + public void downloadsUnAuthenticated(String blobId) throws Throwable { + String attachmentIdOrMessageId = Optional.ofNullable(blobIdByAttachmentId.get(blobId)) + .orElse(Optional.ofNullable(inputToMessageId.get(blobId)) + .map(MessageId::serialize) + .orElse(null)); + + response = Request.Get( + mainStepdefs.baseUri() + .setPath("/download/" + attachmentIdOrMessageId) + .build()) + .execute() + .returnResponse(); + } + @When("^\"([^\"]*)\" downloads the message by its blobId$") public void downloads(String username) throws Throwable { downLoad(username, getMessagesMethodStepdefs.getBlobId()); @@ -167,7 +182,7 @@ public class DownloadStepdefs { } private Request authenticatedDownloadRequest(URIBuilder uriBuilder, String blobId, String username) throws URISyntaxException { - AccessToken accessToken = userStepdefs.tokenByUser.get(username); + AccessToken accessToken = userStepdefs.getTokenForUser(username); AttachmentAccessTokenKey key = new AttachmentAccessTokenKey(username, blobId); if (attachmentAccessTokens.containsKey(key)) { uriBuilder.addParameter("access_token", attachmentAccessTokens.get(key).serialize()); @@ -179,6 +194,11 @@ public class DownloadStepdefs { return request; } + private Request unAuthenticatedDownloadRequest(URIBuilder uriBuilder, String blobId, String username) throws URISyntaxException { + Request request = Request.Get(uriBuilder.build()); + return request; + } + @When("^\"([^\"]*)\" is trusted for attachment \"([^\"]*)\"$") public void attachmentAccessTokenFor(String username, String attachmentId) throws Throwable { userStepdefs.connectUser(username); @@ -222,7 +242,7 @@ public class DownloadStepdefs { private void trustForBlobId(String blobId, String username) throws Exception { Response tokenGenerationResponse = Request.Post(mainStepdefs.baseUri().setPath("/download/" + blobId).build()) - .addHeader("Authorization", userStepdefs.tokenByUser.get(username).serialize()) + .addHeader("Authorization", userStepdefs.getTokenForUser(username).serialize()) .execute(); String serializedAttachmentAccessToken = tokenGenerationResponse.returnContent().asString(); attachmentAccessTokens.put( @@ -234,11 +254,14 @@ public class DownloadStepdefs { @When("^\"([^\"]*)\" downloads \"([^\"]*)\" with a valid authentication token but a bad blobId$") public void downloadsWithValidToken(String username, String attachmentId) throws Throwable { - URIBuilder uriBuilder = mainStepdefs.baseUri().setPath("/download/badblobId"); - response = Request.Get(uriBuilder.build()) - .addHeader("Authorization", userStepdefs.tokenByUser.get(username).serialize()) - .execute() - .returnResponse(); + userStepdefs.execWithUser(username, () -> { + URIBuilder uriBuilder = mainStepdefs.baseUri().setPath("/download/badblobId"); + response = Request.Get(uriBuilder.build()) + .addHeader("Authorization", userStepdefs.getTokenForUser(username).serialize()) + .execute() + .returnResponse(); + + }); } @When("^\"([^\"]*)\" downloads \"([^\"]*)\" without any authentication token$") @@ -314,7 +337,7 @@ public class DownloadStepdefs { @When("^\"([^\"]*)\" asks for a token for attachment \"([^\"]*)\"$") public void postDownload(String username, String attachmentId) throws Throwable { String blobId = blobIdByAttachmentId.get(attachmentId); - AccessToken accessToken = userStepdefs.tokenByUser.get(username); + AccessToken accessToken = userStepdefs.getTokenForUser(username); response = Request.Post(mainStepdefs.baseUri().setPath("/download/" + blobId).build()) .addHeader("Authorization", accessToken.serialize()) .execute() @@ -350,17 +373,32 @@ public class DownloadStepdefs { assertThat(response.getStatusLine().getStatusCode()).isIn(200, 404); } + @Then("^\"([^\"]*)\" be authorized$") + public void httpStatusDifferentFromUnauthorized(String username) throws Throwable { + userStepdefs.execWithUser(username, this::httpStatusDifferentFromUnauthorized); + } + @Then("^the user should not be authorized$") public void httpUnauthorizedStatus() throws IOException { assertThat(response.getStatusLine().getStatusCode()).isEqualTo(401); } + @Then("^\"([^\"]*)\" should not be authorized$") + public void httpUnauthorizedStatus(String username) throws Throwable { + userStepdefs.execWithUser(username, this::httpUnauthorizedStatus); + } + @Then("^the user should receive a bad request response$") public void httpBadRequestStatus() throws IOException { assertThat(response.getStatusLine().getStatusCode()).isEqualTo(400); } - @Then("^the user can read that blob") + @Then("^\"([^\"]*)\" should receive a bad request response$") + public void httpBadRequestStatus(String username) throws Throwable { + userStepdefs.execWithUser(username, this::httpBadRequestStatus); + } + + @Then("^(?:he|she|the user) can read that blob") public void httpOkStatusAndExpectedContent() throws IOException { assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200); assertThat(IOUtils.toString(response.getEntity().getContent(), Charsets.UTF_8)).isNotEmpty(); @@ -371,6 +409,11 @@ public class DownloadStepdefs { assertThat(response.getStatusLine().getStatusCode()).isEqualTo(404); } + @Then("^\"([^\"]*)\" should receive a not found response$") + public void httpNotFoundStatus(String username) throws Throwable { + userStepdefs.execWithUser(username, this::httpNotFoundStatus); + } + @Then("^the user should receive an attachment access token$") public void accessTokenResponse() throws Throwable { assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200); @@ -378,6 +421,11 @@ public class DownloadStepdefs { assertThat(IOUtils.toString(response.getEntity().getContent(), Charsets.UTF_8)).isNotEmpty(); } + @Then("^\"([^\"]*)\" should receive an attachment access token$") + public void accessTokenResponse(String username) throws Throwable { + userStepdefs.execWithUser(username, this::accessTokenResponse); + } + @Then("^the attachment is named \"([^\"]*)\"$") public void assertContentDisposition(String name) throws IOException { if (!CharMatcher.ASCII.matchesAllOf(name)) { @@ -401,7 +449,7 @@ public class DownloadStepdefs { } private String extractFilename(String contentDispositionHeader) { - return contentDispositionHeader.substring(UTF8_CONTENT_DIPOSITION_START.length(), + return contentDispositionHeader.substring(UTF8_CONTENT_DIPOSITION_START.length(), contentDispositionHeader.length() - 1); } http://git-wip-us.apache.org/repos/asf/james-project/blob/d5ce773f/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessageListMethodStepdefs.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessageListMethodStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessageListMethodStepdefs.java index 74346e0..b578c77 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessageListMethodStepdefs.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessageListMethodStepdefs.java @@ -105,7 +105,7 @@ public class GetMessageListMethodStepdefs { private void post(String requestBody) throws Exception { response = Request.Post(mainStepdefs.baseUri().setPath("/jmap").build()) - .addHeader("Authorization", userStepdefs.tokenByUser.get(userStepdefs.getConnectedUser()).serialize()) + .addHeader("Authorization", userStepdefs.getTokenForUser(userStepdefs.getConnectedUser()).serialize()) .addHeader("Accept", org.apache.http.entity.ContentType.APPLICATION_JSON.getMimeType()) .bodyString(requestBody, org.apache.http.entity.ContentType.APPLICATION_JSON) .execute() http://git-wip-us.apache.org/repos/asf/james-project/blob/d5ce773f/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java index 2be46bf..81f6e9d 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java @@ -498,7 +498,7 @@ public class GetMessagesMethodStepdefs { private void post(String requestBody) throws Exception { response = Request.Post(mainStepdefs.baseUri().setPath("/jmap").build()) - .addHeader("Authorization", userStepdefs.tokenByUser.get(userStepdefs.getConnectedUser()).serialize()) + .addHeader("Authorization", userStepdefs.getTokenForUser(userStepdefs.getConnectedUser()).serialize()) .addHeader("Accept", org.apache.http.entity.ContentType.APPLICATION_JSON.getMimeType()) .bodyString(requestBody, org.apache.http.entity.ContentType.APPLICATION_JSON) .execute() http://git-wip-us.apache.org/repos/asf/james-project/blob/d5ce773f/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMailboxesMethodStepdefs.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMailboxesMethodStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMailboxesMethodStepdefs.java index 5104a28..6adabc2 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMailboxesMethodStepdefs.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMailboxesMethodStepdefs.java @@ -98,7 +98,7 @@ public class SetMailboxesMethodStepdefs { " ]" + "]"; Request.Post(mainStepdefs.baseUri().setPath("/jmap").build()) - .addHeader("Authorization", userStepdefs.tokenByUser.get(username).serialize()) + .addHeader("Authorization", userStepdefs.getTokenForUser(username).serialize()) .bodyString(requestBody, ContentType.APPLICATION_JSON) .execute() .discardContent(); @@ -127,7 +127,7 @@ public class SetMailboxesMethodStepdefs { "]"; Request.Post(mainStepdefs.baseUri().setPath("/jmap").build()) - .addHeader("Authorization", userStepdefs.tokenByUser.get(username).serialize()) + .addHeader("Authorization", userStepdefs.getTokenForUser(username).serialize()) .bodyString(requestBody, ContentType.APPLICATION_JSON) .execute() .discardContent(); @@ -142,7 +142,7 @@ public class SetMailboxesMethodStepdefs { Awaitility.await().atMost(Duration.FIVE_SECONDS).pollDelay(slowPacedPollInterval).pollInterval(slowPacedPollInterval).until(() -> { HttpResponse response = Request.Post(mainStepdefs.baseUri().setPath("/jmap").build()) - .addHeader("Authorization", userStepdefs.tokenByUser.get(username).serialize()) + .addHeader("Authorization", userStepdefs.getTokenForUser(username).serialize()) .bodyString("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"" + mailboxId + "\"]}}, \"#0\"]]", ContentType.APPLICATION_JSON) .execute().returnResponse(); http://git-wip-us.apache.org/repos/asf/james-project/blob/d5ce773f/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java index 5438e27..9c0bb43 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java @@ -69,7 +69,7 @@ public class SetMessagesMethodStepdefs { " ]" + "]"; Request.Post(mainStepdefs.baseUri().setPath("/jmap").build()) - .addHeader("Authorization", userStepdefs.tokenByUser.get(username).serialize()) + .addHeader("Authorization", userStepdefs.getTokenForUser(username).serialize()) .bodyString(requestBody, ContentType.APPLICATION_JSON) .execute() .discardContent(); @@ -101,7 +101,7 @@ public class SetMessagesMethodStepdefs { " ]" + "]"; Request.Post(mainStepdefs.baseUri().setPath("/jmap").build()) - .addHeader("Authorization", userStepdefs.tokenByUser.get(username).serialize()) + .addHeader("Authorization", userStepdefs.getTokenForUser(username).serialize()) .bodyString(requestBody, ContentType.APPLICATION_JSON) .execute() .discardContent(); @@ -118,7 +118,7 @@ public class SetMessagesMethodStepdefs { .collect(Collectors.joining(",")); Request.Post(mainStepdefs.baseUri().setPath("/jmap").build()) - .addHeader("Authorization", userStepdefs.tokenByUser.get(username).serialize()) + .addHeader("Authorization", userStepdefs.getTokenForUser(username).serialize()) .bodyString("[" + " [" + " \"setMessages\","+ http://git-wip-us.apache.org/repos/asf/james-project/blob/d5ce773f/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 b17a098..0f55e73 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 @@ -73,7 +73,7 @@ public class UploadStepdefs { @Given("^\"([^\"]*)\" is starting uploading a content$") public void userStartUploadContent(String username) throws Throwable { - AccessToken accessToken = userStepdefs.tokenByUser.get(username); + AccessToken accessToken = userStepdefs.getTokenForUser(username); CountDownLatch startSignal = new CountDownLatch(2); CountDownConsumeInputStream bodyStream = new CountDownConsumeInputStream(startSignal); @@ -104,7 +104,7 @@ public class UploadStepdefs { @When("^\"([^\"]*)\" upload a content$") public void userUploadContent(String username) throws Throwable { - AccessToken accessToken = userStepdefs.tokenByUser.get(username); + 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) { @@ -115,7 +115,7 @@ public class UploadStepdefs { @When("^\"([^\"]*)\" upload a content without content type$") public void userUploadContentWithoutContentType(String username) throws Throwable { - AccessToken accessToken = userStepdefs.tokenByUser.get(username); + AccessToken accessToken = userStepdefs.getTokenForUser(username); Request request = Request.Post(uploadUri) .bodyByteArray("some text".getBytes(Charsets.UTF_8)); if (accessToken != null) { @@ -126,7 +126,7 @@ public class UploadStepdefs { @When("^\"([^\"]*)\" upload a too big content$") public void userUploadTooBigContent(String username) throws Throwable { - AccessToken accessToken = userStepdefs.tokenByUser.get(username); + AccessToken accessToken = userStepdefs.getTokenForUser(username); Request request = Request.Post(uploadUri) .bodyStream(new BufferedInputStream(new ZeroedInputStream(_10M), _10M), org.apache.http.entity.ContentType.DEFAULT_BINARY); if (accessToken != null) { @@ -137,7 +137,7 @@ public class UploadStepdefs { @When("^\"([^\"]*)\" checks for the availability of the upload endpoint$") public void optionUpload(String username) throws Throwable { - AccessToken accessToken = userStepdefs.tokenByUser.get(username); + AccessToken accessToken = userStepdefs.getTokenForUser(username); Request request = Request.Options(uploadUri); if (accessToken != null) { request.addHeader("Authorization", accessToken.serialize()); @@ -194,7 +194,7 @@ public class UploadStepdefs { @Then("^\"([^\"]*)\" should be able to retrieve the content$") public void contentShouldBeRetrievable(String username) throws Exception { - AccessToken accessToken = userStepdefs.tokenByUser.get(username); + AccessToken accessToken = userStepdefs.getTokenForUser(username); Request request = Request.Get(mainStepdefs.baseUri().setPath("/download/" + _1M_ZEROED_FILE_BLOB_ID).build()); if (accessToken != null) { request.addHeader("Authorization", accessToken.serialize()); http://git-wip-us.apache.org/repos/asf/james-project/blob/d5ce773f/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java index c435b3c..497c337 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java @@ -51,7 +51,7 @@ public class UserStepdefs { protected Map<String, String> passwordByUser; protected Set<String> domains; - protected Map<String, AccessToken> tokenByUser; + private Map<String, AccessToken> tokenByUser; protected Optional<String> lastConnectedUser; @Inject @@ -117,12 +117,19 @@ public class UserStepdefs { @Given("^\"([^\"]*)\" is connected$") public void connectUser(String username) throws Throwable { - String password = passwordByUser.get(username); - Preconditions.checkState(password != null, "unknown user " + username); - AccessToken accessToken = HttpJmapAuthentication.authenticateJamesUser(mainStepdefs.baseUri(), username, password); + AccessToken accessToken = getTokenForUser(username); tokenByUser.put(username, accessToken); lastConnectedUser = Optional.of(username); } + + public AccessToken getTokenForUser(String username) { + return tokenByUser.computeIfAbsent(username, (user) -> { + String password = passwordByUser.get(user); + Preconditions.checkState(password != null, "unknown user " + user); + + return HttpJmapAuthentication.authenticateJamesUser(mainStepdefs.baseUri(), user, password); + }); + } @Given("^\"([^\"]*)\" shares its mailbox \"([^\"]*)\" with \"([^\"]*)\"$") public void shareMailbox(String owner, String mailbox, String shareTo) throws Throwable { http://git-wip-us.apache.org/repos/asf/james-project/blob/d5ce773f/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadEndpoint.feature ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadEndpoint.feature b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadEndpoint.feature index 3e18329..979907d 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadEndpoint.feature +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadEndpoint.feature @@ -27,6 +27,10 @@ Feature: Download endpoint And "[email protected]" has a mailbox "INBOX" And "[email protected]" mailbox "INBOX" contains a message "m1" with an attachment "a1" + Scenario: An unauthenticated user should not have access to the download endpoint + When un-authenticated user downloads "a1" + Then the user should not be authorized + Scenario: An authenticated user should initiate the access to the download endpoint Given "[email protected]" is connected When "[email protected]" checks for the availability of the attachment endpoint @@ -36,10 +40,6 @@ Feature: Download endpoint When "[email protected]" checks for the availability of the attachment endpoint Then the user should be authorized - Scenario: An unauthenticated user should not have access to the download endpoint - When "[email protected]" downloads "a1" - Then the user should not be authorized - Scenario: A user should not have access to the download endpoint without the authentication token When "[email protected]" downloads "a1" without any authentication token Then the user should not be authorized http://git-wip-us.apache.org/repos/asf/james-project/blob/d5ce773f/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature index 6619d5d..402b8ef 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature @@ -23,80 +23,77 @@ Feature: Download GET Background: Given a domain named "domain.tld" - And a connected user "[email protected]" + And a user "[email protected]" + And a user "[email protected]" And "[email protected]" has a mailbox "INBOX" And "[email protected]" has a mailbox "sharedMailbox" Scenario: Getting an attachment previously stored Given "[email protected]" mailbox "INBOX" contains a message "1" with an attachment "2" When "[email protected]" downloads "2" - Then the user can read that blob + Then she can read that blob And the blob size is 3071 Scenario: Getting an attachment with an unknown blobId Given "[email protected]" mailbox "INBOX" contains a message "1" with an attachment "2" When "[email protected]" downloads "2" with a valid authentication token but a bad blobId - Then the user should receive a not found response + Then "[email protected]" should receive a not found response Scenario: Getting an attachment previously stored with a desired name Given "[email protected]" mailbox "INBOX" contains a message "1" with an attachment "2" When "[email protected]" downloads "2" with "myFileName.txt" name - Then the user can read that blob + Then she can read that blob And the attachment is named "myFileName.txt" Scenario: Getting an attachment previously stored with a non ASCII name Given "[email protected]" mailbox "INBOX" contains a message "1" with an attachment "2" When "[email protected]" downloads "2" with "دÙÙØ§ØµÙر.odt" name - Then the user can read that blob + Then she can read that blob And the attachment is named "دÙÙØ§ØµÙر.odt" Scenario: Getting a message blob previously stored Given "[email protected]" mailbox "INBOX" contains a message "1" When "[email protected]" downloads "1" - Then the user can read that blob + Then she can read that blob And the blob size is 4963 Scenario: Getting a message then getting its blob - Given the user has a message "m1" in "INBOX" mailbox with subject "my test subject", content "testmail" - And the user ask for messages "m1" + Given "[email protected]" has a message "m1" in "INBOX" mailbox with subject "my test subject", content "testmail" + And "[email protected]" ask for messages "m1" When "[email protected]" downloads the message by its blobId - Then the user can read that blob + Then she can read that blob And the blob size is 36 Scenario: Deleted message should revoke attachment blob download rights Given "[email protected]" mailbox "INBOX" contains a message "1" with an attachment "2" And "[email protected]" delete mailbox "INBOX" When "[email protected]" downloads "2" - Then the user should receive a not found response + Then "[email protected]" should receive a not found response Scenario: User cannot download attachment of another user Given "[email protected]" mailbox "INBOX" contains a message "1" with an attachment "2" - And a connected user "[email protected]" And "[email protected]" has a mailbox "INBOX" When "[email protected]" downloads "2" - Then the user should receive a not found response + Then "[email protected]" should receive a not found response Scenario: User cannot download message blob of another user Given "[email protected]" mailbox "INBOX" contains a message "1" with an attachment "2" - And a connected user "[email protected]" And "[email protected]" has a mailbox "INBOX" When "[email protected]" downloads "1" - Then the user should receive a not found response + Then "[email protected]" should receive a not found response Scenario: User can download attachment of another user when shared mailbox Given "[email protected]" mailbox "sharedMailbox" contains a message "1" with an attachment "2" And "[email protected]" shares its mailbox "sharedMailbox" with "[email protected]" - And a connected user "[email protected]" And "[email protected]" has a mailbox "sharedMailbox" When "[email protected]" downloads "2" - Then the user can read that blob + Then he can read that blob And the blob size is 3071 Scenario: User can download message blob of another user when shared mailbox Given "[email protected]" mailbox "sharedMailbox" contains a message "1" with an attachment "2" And "[email protected]" shares its mailbox "sharedMailbox" with "[email protected]" - And a connected user "[email protected]" And "[email protected]" has a mailbox "sharedMailbox" When "[email protected]" downloads "1" - Then the user can read that blob + Then he can read that blob And the blob size is 4963 \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
