Repository: james-project Updated Branches: refs/heads/master 662fa4a95 -> 5c7471cd9
JAMES-1795 port every cucumber tests from rest-assured to raw httpclient Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/88f1dbab Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/88f1dbab Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/88f1dbab Branch: refs/heads/master Commit: 88f1dbaba43cb865675ab0ee60f311cdf0c6d3b5 Parents: 1c294dd Author: Matthieu Baechler <[email protected]> Authored: Fri Jul 8 13:04:15 2016 +0200 Committer: Matthieu Baechler <[email protected]> Committed: Fri Jul 8 17:47:00 2016 +0200 ---------------------------------------------------------------------- .../jmap-integration-testing-common/pom.xml | 4 + .../james/jmap/HttpJmapAuthentication.java | 59 ++++++ .../integration/cucumber/DownloadStepdefs.java | 199 ++++++++++--------- .../cucumber/GetMessagesMethodStepdefs.java | 85 ++++---- .../integration/cucumber/MainStepdefs.java | 22 +- .../cucumber/SetMailboxesMethodStepdefs.java | 48 +++-- .../integration/cucumber/UploadStepdefs.java | 103 +++++----- .../integration/cucumber/UserStepdefs.java | 4 +- .../test/resources/cucumber/DownloadGet.feature | 4 +- 9 files changed, 298 insertions(+), 230 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/88f1dbab/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml index 6002d51..f75de8d 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml @@ -278,6 +278,10 @@ <version>18.0</version> <!--$NO-MVN-MAN-VER$--> </dependency> <dependency> + <groupId>com.jayway.jsonpath</groupId> + <artifactId>json-path</artifactId> + </dependency> + <dependency> <groupId>com.jayway.restassured</groupId> <artifactId>rest-assured</artifactId> <scope>test</scope> http://git-wip-us.apache.org/repos/asf/james-project/blob/88f1dbab/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/HttpJmapAuthentication.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/HttpJmapAuthentication.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/HttpJmapAuthentication.java new file mode 100644 index 0000000..07ad607 --- /dev/null +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/HttpJmapAuthentication.java @@ -0,0 +1,59 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.james.jmap; + +import java.io.IOException; +import java.net.URISyntaxException; + +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.fluent.Request; +import org.apache.http.client.fluent.Response; +import org.apache.http.client.utils.URIBuilder; +import org.apache.http.entity.ContentType; +import org.apache.james.jmap.api.access.AccessToken; + +import com.jayway.jsonpath.JsonPath; + +public class HttpJmapAuthentication { + + public static AccessToken authenticateJamesUser(URIBuilder uriBuilder, String username, String password) throws ClientProtocolException, IOException, URISyntaxException { + String continuationToken = getContinuationToken(uriBuilder, username); + + Response response = Request.Post(uriBuilder.setPath("/authentication").build()) + .bodyString("{\"token\": \"" + continuationToken + "\", \"method\": \"password\", \"password\": \"" + password + "\"}", + ContentType.APPLICATION_JSON) + .setHeader("Accept", ContentType.APPLICATION_JSON.getMimeType()) + .execute(); + + return AccessToken.fromString( + JsonPath.parse(response.returnContent().asString()) + .read("accessToken")); + } + + private static String getContinuationToken(URIBuilder uriBuilder, String username) throws ClientProtocolException, IOException, URISyntaxException { + Response response = Request.Post(uriBuilder.setPath("/authentication").build()) + .bodyString("{\"username\": \"" + username + "\", \"clientName\": \"Mozilla Thunderbird\", \"clientVersion\": \"42.0\", \"deviceName\": \"Joe Bloggâs iPhone\"}", + ContentType.APPLICATION_JSON) + .setHeader("Accept", ContentType.APPLICATION_JSON.getMimeType()) + .execute(); + return JsonPath.parse(response.returnContent().asString()) + .read("continuationToken"); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/88f1dbab/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 53fe11d..98dd128 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 @@ -19,10 +19,11 @@ package org.apache.james.jmap.methods.integration.cucumber; -import static com.jayway.restassured.RestAssured.with; -import static org.hamcrest.Matchers.isIn; -import static org.hamcrest.Matchers.notNullValue; +import static org.assertj.core.api.Assertions.assertThat; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -30,20 +31,22 @@ import java.util.Map; import javax.inject.Inject; import javax.mail.Flags; +import org.apache.commons.io.IOUtils; +import org.apache.http.Header; +import org.apache.http.HttpResponse; +import org.apache.http.client.fluent.Request; +import org.apache.http.client.fluent.Response; +import org.apache.http.client.utils.URIBuilder; import org.apache.james.jmap.api.access.AccessToken; import org.apache.james.jmap.model.AttachmentAccessToken; import org.apache.james.mailbox.model.MailboxConstants; import org.apache.james.mailbox.model.MailboxPath; +import com.google.common.base.Charsets; import com.google.common.base.MoreObjects; import com.google.common.base.Objects; import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ImmutableList; import com.google.common.collect.Multimap; -import com.jayway.restassured.http.ContentType; -import com.jayway.restassured.response.Response; -import com.jayway.restassured.response.ValidatableResponse; -import com.jayway.restassured.specification.RequestSpecification; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; @@ -63,10 +66,9 @@ public class DownloadStepdefs { private final UserStepdefs userStepdefs; private final MainStepdefs mainStepdefs; - private Response response; + private HttpResponse response; private Multimap<String, String> attachmentsByMessageId; private Map<String, String> blobIdByAttachmentId; - private ValidatableResponse validatableResponse; private Map<AttachmentAccessTokenKey, AttachmentAccessToken> attachmentAccessTokens; @Inject @@ -77,7 +79,7 @@ public class DownloadStepdefs { this.blobIdByAttachmentId = new HashMap<>(); this.attachmentAccessTokens = new HashMap<>(); } - + @Given("^\"([^\"]*)\" mailbox \"([^\"]*)\" contains a message \"([^\"]*)\" with an attachment \"([^\"]*)\"$") public void appendMessageWithAttachmentToMailbox(String user, String mailbox, String messageId, String attachmentId) throws Throwable { MailboxPath mailboxPath = new MailboxPath(MailboxConstants.USER_NAMESPACE, user, mailbox); @@ -104,32 +106,32 @@ 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); - RequestSpecification with = with(); + URI target = mainStepdefs.baseUri().setPath("/download/" + ONE_ATTACHMENT_EML_ATTACHEMENT_BLOB_ID).build(); + Request request = Request.Options(target); if (accessToken != null) { - with.header("Authorization", accessToken.serialize()); + request.addHeader("Authorization", accessToken.serialize()); } - - response = with - .options("/download/" + ONE_ATTACHMENT_EML_ATTACHEMENT_BLOB_ID); + response = request.execute().returnResponse(); } @When("^\"([^\"]*)\" downloads \"([^\"]*)\"$") public void downloads(String username, String attachmentId) throws Throwable { String blobId = blobIdByAttachmentId.get(attachmentId); - response = authenticatedDownloadRequest(blobId, username) - .get("/download/" + blobId); + URIBuilder uriBuilder = mainStepdefs.baseUri().setPath("/download/" + blobId); + response = authenticatedDownloadRequest(uriBuilder, blobId, username).execute().returnResponse(); } - private RequestSpecification authenticatedDownloadRequest(String blobId, String username) { + private Request authenticatedDownloadRequest(URIBuilder uriBuilder, String blobId, String username) throws URISyntaxException { AccessToken accessToken = userStepdefs.tokenByUser.get(username); AttachmentAccessTokenKey key = new AttachmentAccessTokenKey(username, blobId); if (attachmentAccessTokens.containsKey(key)) { - return with().param("access_token", attachmentAccessTokens.get(key).serialize()); + uriBuilder.addParameter("access_token", attachmentAccessTokens.get(key).serialize()); } + Request request = Request.Get(uriBuilder.build()); if (accessToken != null) { - return with().header("Authorization", accessToken.serialize()); + request.addHeader("Authorization", accessToken.serialize()); } - return with(); + return request; } @When("^\"([^\"]*)\" is trusted for attachment \"([^\"]*)\"$") @@ -173,14 +175,11 @@ public class DownloadStepdefs { } } - private void trustForBlobId(String blobId, String username) { - String serializedAttachmentAccessToken = - with() - .header("Authorization", userStepdefs.tokenByUser.get(username).serialize()) - .post("/download/" + blobId) - .then() - .extract() - .asString(); + 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()) + .execute(); + String serializedAttachmentAccessToken = tokenGenerationResponse.returnContent().asString(); attachmentAccessTokens.put( new AttachmentAccessTokenKey(username, blobId), AttachmentAccessToken.from( @@ -188,133 +187,149 @@ public class DownloadStepdefs { blobId)); } - @When("^\"([^\"]*)\" downloads \"([^\"]*)\" with a valid authentication token$") + @When("^\"([^\"]*)\" downloads \"([^\"]*)\" with a valid authentication token but a bad blobId$") public void downloadsWithValidToken(String username, String attachmentId) throws Throwable { - String blobId = blobIdByAttachmentId.get(attachmentId); - - response = requestWithQueryParameterAuthentication(username, blobId) - .get("/download/" + attachmentId); + URIBuilder uriBuilder = mainStepdefs.baseUri().setPath("/download/badblobId"); + response = Request.Get(uriBuilder.build()) + .addHeader("Authorization", userStepdefs.tokenByUser.get(username).serialize()) + .execute() + .returnResponse(); } @When("^\"([^\"]*)\" downloads \"([^\"]*)\" without any authentication token$") - public void getDownloadWithoutToken(String username, String attachmentId) { + public void getDownloadWithoutToken(String username, String attachmentId) throws Exception { String blobId = blobIdByAttachmentId.get(attachmentId); - response = with().get("/download/" + blobId); + response = Request.Get(mainStepdefs.baseUri().setPath("/download/" + blobId).build()) + .execute() + .returnResponse(); } @When("^\"([^\"]*)\" downloads \"([^\"]*)\" with an empty authentication token$") - public void getDownloadWithEmptyToken(String username, String attachmentId) { + public void getDownloadWithEmptyToken(String username, String attachmentId) throws Exception { String blobId = blobIdByAttachmentId.get(attachmentId); - response = with() - .param("access_token", "") - .get("/download/" + blobId); + response = Request.Get( + mainStepdefs.baseUri() + .setPath("/download/" + blobId) + .addParameter("access_token", "") + .build()) + .execute() + .returnResponse(); } @When("^\"([^\"]*)\" downloads \"([^\"]*)\" with a bad authentication token$") - public void getDownloadWithBadToken(String username, String attachmentId) { + public void getDownloadWithBadToken(String username, String attachmentId) throws Exception { String blobId = blobIdByAttachmentId.get(attachmentId); - response = with() - .param("access_token", "bad") - .get("/download/" + blobId); + response = Request.Get( + mainStepdefs.baseUri() + .setPath("/download/" + blobId) + .addParameter("access_token", "bad") + .build()) + .execute() + .returnResponse(); } @When("^\"([^\"]*)\" downloads \"([^\"]*)\" with an invalid authentication token$") - public void getDownloadWithUnknownToken(String username, String attachmentId) { + public void getDownloadWithUnknownToken(String username, String attachmentId) throws Exception { String blobId = blobIdByAttachmentId.get(attachmentId); - response = with() - .param("access_token", INVALID_ATTACHMENT_TOKEN) - .get("/download/" + blobId); + response = Request.Get( + mainStepdefs.baseUri() + .setPath("/download/" + blobId) + .addParameter("access_token", INVALID_ATTACHMENT_TOKEN) + .build()) + .execute() + .returnResponse(); } @When("^\"([^\"]*)\" downloads \"([^\"]*)\" without blobId parameter$") public void getDownloadWithoutBlobId(String username, String attachmentId) throws Throwable { String blobId = blobIdByAttachmentId.get(attachmentId); - response = requestWithQueryParameterAuthentication(username, blobId) - .get("/download/"); + URIBuilder uriBuilder = mainStepdefs.baseUri().setPath("/download/"); + trustForBlobId(blobId, username); + AttachmentAccessTokenKey key = new AttachmentAccessTokenKey(username, blobId); + uriBuilder.addParameter("access_token", attachmentAccessTokens.get(key).serialize()); + response = Request.Get(uriBuilder.build()) + .execute() + .returnResponse(); } @When("^\"([^\"]*)\" downloads \"([^\"]*)\" with wrong blobId$") public void getDownloadWithWrongBlobId(String username, String attachmentId) throws Throwable { String blobId = blobIdByAttachmentId.get(attachmentId); - response = requestWithQueryParameterAuthentication(username, blobId) - .get("/download/badbadbadbadbadbadbadbadbadbadbadbadbadb"); - } - - private RequestSpecification requestWithQueryParameterAuthentication(String username, String blobId) { + URIBuilder uriBuilder = mainStepdefs.baseUri().setPath("/download/badbadbadbadbadbadbadbadbadbadbadbadbadb"); trustForBlobId(blobId, username); - return authenticatedDownloadRequest(blobId, username); + AttachmentAccessTokenKey key = new AttachmentAccessTokenKey(username, blobId); + uriBuilder.addParameter("access_token", attachmentAccessTokens.get(key).serialize()); + response = Request.Get(uriBuilder.build()) + .execute() + .returnResponse(); } @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); - RequestSpecification with = with(); - if (accessToken != null) { - with = with.header("Authorization", accessToken.serialize()); - } - response = with - .post("/download/" + blobId); + response = Request.Post(mainStepdefs.baseUri().setPath("/download/" + blobId).build()) + .addHeader("Authorization", accessToken.serialize()) + .execute() + .returnResponse(); } @When("^\"([^\"]*)\" downloads \"([^\"]*)\" with \"([^\"]*)\" name$") - public void downloadsWithName(String username, String attachmentId, String name) { + public void downloadsWithName(String username, String attachmentId, String name) throws Exception { String blobId = blobIdByAttachmentId.get(attachmentId); - response = authenticatedDownloadRequest(blobId, username) - .get("/download/" + blobId + "/" + name); + URIBuilder uriBuilder = mainStepdefs.baseUri().setPath("/download/" + blobId + "/" + name); + response = authenticatedDownloadRequest(uriBuilder, blobId, username) + .execute() + .returnResponse(); } @When("^\"([^\"]*)\" downloads \"([^\"]*)\" with an expired token$") - public void getDownloadWithExpiredToken(String username, String attachmentId) { + public void getDownloadWithExpiredToken(String username, String attachmentId) throws Exception { String blobId = blobIdByAttachmentId.get(attachmentId); - response = with() - .param("access_token", EXPIRED_ATTACHMENT_TOKEN) - .get("/download/" + blobId); + response = Request.Get(mainStepdefs.baseUri().setPath("/download/" + blobId) + .addParameter("access_token", EXPIRED_ATTACHMENT_TOKEN) + .build()) + .execute() + .returnResponse(); } @Then("^the user should be authorized$") - public void httpStatusDifferentFromUnauthorized() { - response.then() - .statusCode(isIn(ImmutableList.of(200, 404))); + public void httpStatusDifferentFromUnauthorized() throws IOException { + assertThat(response.getStatusLine().getStatusCode()).isIn(200, 404); } @Then("^the user should not be authorized$") - public void httpUnauthorizedStatus() { - response.then() - .statusCode(401); + public void httpUnauthorizedStatus() throws IOException { + assertThat(response.getStatusLine().getStatusCode()).isEqualTo(401); } @Then("^the user should receive a bad request response$") - public void httpBadRequestStatus() { - response.then() - .statusCode(400); + public void httpBadRequestStatus() throws IOException { + assertThat(response.getStatusLine().getStatusCode()).isEqualTo(400); } @Then("^the user should receive that attachment$") - public void httpOkStatusAndExpectedContent() { - validatableResponse = response.then() - .statusCode(200) - .content(notNullValue()); + public void httpOkStatusAndExpectedContent() throws IOException { + assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200); + assertThat(IOUtils.toString(response.getEntity().getContent(), Charsets.UTF_8)).isNotEmpty(); } @Then("^the user should receive a not found response$") - public void httpNotFoundStatus() { - response.then() - .statusCode(404); + public void httpNotFoundStatus() throws IOException { + assertThat(response.getStatusLine().getStatusCode()).isEqualTo(404); } @Then("^the user should receive an attachment access token$") public void accessTokenResponse() throws Throwable { - response.then() - .statusCode(200) - .contentType(ContentType.TEXT) - .content(notNullValue()); + assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200); + assertThat(response.getHeaders("Content-Type")).extracting(Header::toString).containsExactly("Content-Type: text/plain"); + assertThat(IOUtils.toString(response.getEntity().getContent(), Charsets.UTF_8)).isNotEmpty(); } @Then("^the attachment is named \"([^\"]*)\"$") - public void assertContentDisposition(String name) { - validatableResponse.header("Content-Disposition", name); + public void assertContentDisposition(String name) throws IOException { + assertThat(response.getHeaders("Content-Disposition")).extracting(Header::toString).containsExactly("Content-Disposition: " + name); } } http://git-wip-us.apache.org/repos/asf/james-project/blob/88f1dbab/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 252afd0..bdaaff1 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 @@ -19,16 +19,12 @@ package org.apache.james.jmap.methods.integration.cucumber; -import static com.jayway.restassured.RestAssured.with; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.empty; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.nullValue; +import static org.assertj.core.api.Assertions.assertThat; import java.io.ByteArrayInputStream; import java.time.ZonedDateTime; import java.util.Date; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Optional; @@ -39,6 +35,9 @@ import java.util.stream.Collectors; import javax.inject.Inject; import javax.mail.Flags; +import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.http.HttpResponse; +import org.apache.http.client.fluent.Request; import org.apache.james.jmap.methods.integration.cucumber.util.TableRow; import org.apache.james.mailbox.model.MailboxConstants; import org.apache.james.mailbox.model.MailboxPath; @@ -46,15 +45,16 @@ import org.javatuples.Pair; import com.google.common.base.Charsets; import com.google.common.base.Joiner; -import com.jayway.restassured.response.Response; -import com.jayway.restassured.response.ValidatableResponse; +import com.jayway.jsonpath.Configuration; +import com.jayway.jsonpath.DocumentContext; +import com.jayway.jsonpath.JsonPath; +import com.jayway.jsonpath.Option; import cucumber.api.DataTable; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import cucumber.runtime.java.guice.ScenarioScoped; -import groovy.json.StringEscapeUtils; @ScenarioScoped public class GetMessagesMethodStepdefs { @@ -71,8 +71,8 @@ public class GetMessagesMethodStepdefs { private final MainStepdefs mainStepdefs; private final UserStepdefs userStepdefs; - private Response post; - private ValidatableResponse response; + private HttpResponse response; + private DocumentContext jsonPath; @Inject private GetMessagesMethodStepdefs(MainStepdefs mainStepdefs, UserStepdefs userStepdefs) { @@ -195,116 +195,117 @@ public class GetMessagesMethodStepdefs { return Joiner.on(": ").join(pair); } - private void post(String requestBody) { - post = with() - .header("Authorization", userStepdefs.tokenByUser.get(userStepdefs.lastConnectedUser).serialize()) - .body(requestBody) - .post("/jmap"); + private void post(String requestBody) throws Exception { + response = Request.Post(mainStepdefs.baseUri().setPath("/jmap").build()) + .addHeader("Authorization", userStepdefs.tokenByUser.get(userStepdefs.lastConnectedUser).serialize()) + .addHeader("Accept", org.apache.http.entity.ContentType.APPLICATION_JSON.getMimeType()) + .bodyString(requestBody, org.apache.http.entity.ContentType.APPLICATION_JSON) + .execute() + .returnResponse(); + jsonPath = JsonPath.using(Configuration.defaultConfiguration().addOptions(Option.SUPPRESS_EXCEPTIONS)).parse(response.getEntity().getContent()); } @Then("^an error \"([^\"]*)\" is returned$") public void error(String type) throws Throwable { - response = post.then() - .statusCode(200) - .body(NAME, equalTo("error")) - .body(ARGUMENTS + ".type", equalTo(type)); + assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200); + assertThat(jsonPath.<String>read(NAME)).isEqualTo("error"); + assertThat(jsonPath.<String>read(ARGUMENTS + ".type")).isEqualTo(type); } @Then("^no error is returned$") public void noError() throws Throwable { - response = post.then() - .statusCode(200) - .body(NAME, equalTo("messages")); + assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200); + assertThat(jsonPath.<String>read(NAME)).isEqualTo("messages"); } @Then("^the list of unknown messages is empty$") public void assertNotFoundIsEmpty() { - response.body(ARGUMENTS + ".notFound", empty()); + assertThat(jsonPath.<List<String>>read(ARGUMENTS + ".notFound")).isEmpty(); } @Then("^the list of messages is empty$") public void assertListIsEmpty() { - response.body(ARGUMENTS + ".list", empty()); + assertThat(jsonPath.<List<String>>read(ARGUMENTS + ".list")).isEmpty(); } @Then("^the description is \"(.*?)\"$") public void assertDescription(String description) throws Throwable { - response.body(ARGUMENTS + ".description", equalTo(description)); + assertThat(jsonPath.<String>read(ARGUMENTS + ".description")).isEqualTo(description); } @Then("^the notFound list should contains \"([^\"]*)\"$") public void assertNotFoundListContains(String ids) throws Throwable { - response.body(ARGUMENTS + ".notFound", contains(ids)); + assertThat(jsonPath.<List<String>>read(ARGUMENTS + ".notFound")).contains(ids); } @Then("^the list should contain (\\d+) message$") public void assertListContains(int numberOfMessages) throws Throwable { - response.body(ARGUMENTS + ".list", hasSize(numberOfMessages)); + assertThat(jsonPath.<List<String>>read(ARGUMENTS + ".list")).hasSize(numberOfMessages); } @Then("^the id of the message is \"([^\"]*)\"$") public void assertIdOfTheFirstMessage(String id) throws Throwable { - response.body(FIRST_MESSAGE + ".id", equalTo(id)); + assertThat(jsonPath.<String>read(FIRST_MESSAGE + ".id")).isEqualTo(id); } @Then("^the threadId of the message is \"([^\"]*)\"$") public void assertThreadIdOfTheFirstMessage(String threadId) throws Throwable { - response.body(FIRST_MESSAGE + ".threadId", equalTo(threadId)); + assertThat(jsonPath.<String>read(FIRST_MESSAGE + ".threadId")).isEqualTo(threadId); } @Then("^the subject of the message is \"([^\"]*)\"$") public void assertSubjectOfTheFirstMessage(String subject) throws Throwable { - response.body(FIRST_MESSAGE + ".subject", equalTo(subject)); + assertThat(jsonPath.<String>read(FIRST_MESSAGE + ".subject")).isEqualTo(subject); } @Then("^the textBody of the message is \"([^\"]*)\"$") public void assertTextBodyOfTheFirstMessage(String textBody) throws Throwable { - response.body(FIRST_MESSAGE + ".textBody", equalTo(StringEscapeUtils.unescapeJava(textBody))); + assertThat(jsonPath.<String>read(FIRST_MESSAGE + ".textBody")).isEqualTo(StringEscapeUtils.unescapeJava(textBody)); } @Then("^the htmlBody of the message is \"([^\"]*)\"$") public void assertHtmlBodyOfTheFirstMessage(String htmlBody) throws Throwable { - response.body(FIRST_MESSAGE + ".htmlBody", equalTo(StringEscapeUtils.unescapeJava(htmlBody))); + assertThat(jsonPath.<String>read(FIRST_MESSAGE + ".htmlBody")).isEqualTo(StringEscapeUtils.unescapeJava(htmlBody)); } @Then("^the isUnread of the message is \"([^\"]*)\"$") public void assertIsUnreadOfTheFirstMessage(String isUnread) throws Throwable { - response.body(FIRST_MESSAGE + ".isUnread", equalTo(Boolean.valueOf(isUnread))); + assertThat(jsonPath.<Boolean>read(FIRST_MESSAGE + ".isUnread")).isEqualTo(Boolean.valueOf(isUnread)); } @Then("^the preview of the message is \"([^\"]*)\"$") public void assertPreviewOfTheFirstMessage(String preview) throws Throwable { - response.body(FIRST_MESSAGE + ".preview", equalTo(StringEscapeUtils.unescapeJava(preview))); + assertThat(jsonPath.<String>read(FIRST_MESSAGE + ".preview")).isEqualTo(StringEscapeUtils.unescapeJava(preview)); } @Then("^the headers of the message contains:$") public void assertHeadersOfTheFirstMessage(DataTable headers) throws Throwable { - response.body(FIRST_MESSAGE + ".headers", equalTo(headers.asMap(String.class, String.class))); + assertThat(jsonPath.<Map<String, String>>read(FIRST_MESSAGE + ".headers")).isEqualTo(headers.asMap(String.class, String.class)); } @Then("^the date of the message is \"([^\"]*)\"$") public void assertDateOfTheFirstMessage(String date) throws Throwable { - response.body(FIRST_MESSAGE + ".date", equalTo(date)); + assertThat(jsonPath.<String>read(FIRST_MESSAGE + ".date")).isEqualTo(date); } @Then("^the hasAttachment of the message is \"([^\"]*)\"$") public void assertHasAttachmentOfTheFirstMessage(String hasAttachment) throws Throwable { - response.body(FIRST_MESSAGE + ".hasAttachment", equalTo(Boolean.valueOf(hasAttachment))); + assertThat(jsonPath.<Boolean>read(FIRST_MESSAGE + ".hasAttachment")).isEqualTo(Boolean.valueOf(hasAttachment)); } @Then("^the list of attachments of the message is empty$") public void assertAttachmentsOfTheFirstMessageIsEmpty() throws Throwable { - response.body(ATTACHMENTS, empty()); + assertThat(jsonPath.<List<Object>>read(ATTACHMENTS)).isEmpty(); } @Then("^the property \"([^\"]*)\" of the message is null$") public void assertPropertyIsNull(String property) throws Throwable { - response.body(FIRST_MESSAGE + "." + property, nullValue()); + assertThat(jsonPath.<String>read(FIRST_MESSAGE + "." + property + ".date")).isNull(); } @Then("^the list of attachments of the message contains (\\d+) attachments?$") public void assertAttachmentsHasSize(int numberOfAttachments) throws Throwable { - response.body(ATTACHMENTS, hasSize(numberOfAttachments)); + assertThat(jsonPath.<List<Object>>read(ATTACHMENTS)).hasSize(numberOfAttachments); } @Then("^the first attachment is:$") @@ -320,6 +321,6 @@ public class GetMessagesMethodStepdefs { private void assertAttachment(String attachment, DataTable attachmentProperties) { attachmentProperties.asList(TableRow.class) .stream() - .forEach(row -> response.body(attachment + "." + row.getKey(), equalTo(row.getValue()))); + .forEach(entry -> assertThat(jsonPath.<Object>read(attachment + "." + entry.getKey())).isEqualTo(entry.getValue())); } } http://git-wip-us.apache.org/repos/asf/james-project/blob/88f1dbab/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MainStepdefs.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MainStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MainStepdefs.java index 91eba14..a5327ed 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MainStepdefs.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MainStepdefs.java @@ -19,15 +19,10 @@ package org.apache.james.jmap.methods.integration.cucumber; -import static com.jayway.restassured.config.EncoderConfig.encoderConfig; -import static com.jayway.restassured.config.RestAssuredConfig.newConfig; - +import org.apache.http.client.utils.URIBuilder; import org.apache.james.GuiceJamesServer; import com.google.common.base.Charsets; -import com.jayway.restassured.RestAssured; -import com.jayway.restassured.builder.RequestSpecBuilder; -import com.jayway.restassured.http.ContentType; import cucumber.runtime.java.guice.ScenarioScoped; @@ -39,14 +34,15 @@ public class MainStepdefs { public void init() throws Exception { jmapServer.start(); - RestAssured.requestSpecification = new RequestSpecBuilder() - .setContentType(ContentType.JSON) - .setAccept(ContentType.JSON) - .setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8))) - .setPort(jmapServer.getJmapPort()) - .build(); + } + - RestAssured.enableLoggingOfRequestAndResponseIfValidationFails(); + public URIBuilder baseUri() { + return new URIBuilder() + .setScheme("http") + .setHost("localhost") + .setPort(jmapServer.getJmapPort()) + .setCharset(Charsets.UTF_8); } public void tearDown() { http://git-wip-us.apache.org/repos/asf/james-project/blob/88f1dbab/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 85b643e..b2fed83 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 @@ -19,24 +19,27 @@ package org.apache.james.jmap.methods.integration.cucumber; -import static com.jayway.restassured.RestAssured.given; -import static com.jayway.restassured.RestAssured.with; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.hasSize; +import static org.assertj.core.api.Assertions.assertThat; import java.io.ByteArrayInputStream; import java.util.Date; +import java.util.List; import java.util.stream.IntStream; import javax.inject.Inject; import javax.mail.Flags; +import org.apache.http.HttpResponse; +import org.apache.http.client.fluent.Request; +import org.apache.http.entity.ContentType; import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.model.MailboxConstants; import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.store.mail.model.Mailbox; import com.github.fge.lambdas.Throwing; +import com.jayway.jsonpath.DocumentContext; +import com.jayway.jsonpath.JsonPath; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; @@ -93,11 +96,11 @@ public class SetMailboxesMethodStepdefs { " \"#0\"" + " ]" + "]"; - - with() - .header("Authorization", userStepdefs.tokenByUser.get(username).serialize()) - .body(requestBody) - .post("/jmap"); + Request.Post(mainStepdefs.baseUri().setPath("/jmap").build()) + .addHeader("Authorization", userStepdefs.tokenByUser.get(username).serialize()) + .bodyString(requestBody, ContentType.APPLICATION_JSON) + .execute() + .discardContent(); } @When("^moving mailbox \"([^\"]*)\" to \"([^\"]*)\"$") @@ -122,10 +125,11 @@ public class SetMailboxesMethodStepdefs { " ]" + "]"; - with() - .header("Authorization", userStepdefs.tokenByUser.get(username).serialize()) - .body(requestBody) - .post("/jmap"); + Request.Post(mainStepdefs.baseUri().setPath("/jmap").build()) + .addHeader("Authorization", userStepdefs.tokenByUser.get(username).serialize()) + .bodyString(requestBody, ContentType.APPLICATION_JSON) + .execute() + .discardContent(); } @Then("^mailbox \"([^\"]*)\" contains (\\d+) messages$") @@ -133,14 +137,14 @@ public class SetMailboxesMethodStepdefs { String username = userStepdefs.lastConnectedUser; Mailbox mailbox = mainStepdefs.jmapServer.serverProbe().getMailbox("#private", username, mailboxName); String mailboxId = mailbox.getMailboxId().serialize(); - given() - .header("Authorization", userStepdefs.tokenByUser.get(username).serialize()) - .body("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"" + mailboxId + "\"]}}, \"#0\"]]") - .when() - .post("/jmap") - .then() - .statusCode(200) - .body(NAME, equalTo("messageList")) - .body(ARGUMENTS + ".messageIds", hasSize(messageCount)); + HttpResponse response = Request.Post(mainStepdefs.baseUri().setPath("/jmap").build()) + .addHeader("Authorization", userStepdefs.tokenByUser.get(username).serialize()) + .bodyString("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"" + mailboxId + "\"]}}, \"#0\"]]", ContentType.APPLICATION_JSON) + .execute().returnResponse(); + + assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200); + DocumentContext jsonPath = JsonPath.parse(response.getEntity().getContent()); + assertThat(jsonPath.<String>read(NAME)).isEqualTo("messageList"); + assertThat(jsonPath.<List<String>>read(ARGUMENTS + ".messageIds")).hasSize(messageCount); } } http://git-wip-us.apache.org/repos/asf/james-project/blob/88f1dbab/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 4d97af4..74dbcc0 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 @@ -19,23 +19,25 @@ package org.apache.james.jmap.methods.integration.cucumber; -import static com.jayway.restassured.RestAssured.with; -import static com.jayway.restassured.config.RestAssuredConfig.newConfig; -import static org.hamcrest.Matchers.equalTo; - import java.io.BufferedInputStream; import java.io.InputStream; +import java.net.URI; +import java.net.URISyntaxException; import javax.inject.Inject; +import org.apache.http.Header; +import org.apache.http.HttpResponse; +import org.apache.http.client.fluent.Executor; +import org.apache.http.client.fluent.Request; +import org.apache.http.impl.client.HttpClientBuilder; import org.apache.james.jmap.api.access.AccessToken; import com.google.common.base.Charsets; -import com.jayway.restassured.config.EncoderConfig; -import com.jayway.restassured.config.RestAssuredConfig; -import com.jayway.restassured.http.ContentType; -import com.jayway.restassured.response.Response; -import com.jayway.restassured.specification.RequestSpecification; +import com.jayway.jsonpath.DocumentContext; +import com.jayway.jsonpath.JsonPath; + +import static org.assertj.core.api.Assertions.assertThat; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; @@ -43,121 +45,108 @@ import cucumber.runtime.java.guice.ScenarioScoped; @ScenarioScoped public class UploadStepdefs { - private static final RestAssuredConfig NO_CHARSET = newConfig().encoderConfig(EncoderConfig.encoderConfig().appendDefaultContentCharsetToContentTypeIfUndefined(false)); private static final String _1M_ZEROED_FILE_BLOB_ID = "3b71f43ff30f4b15b5cd85dd9e95ebc7e84eb5a3"; private static final int _1M = 1024 * 1024; private static final int _10M = 10 * _1M; private final UserStepdefs userStepdefs; - private Response response; + private final MainStepdefs mainStepdefs; + private final URI uploadUri; + private HttpResponse response; @Inject - private UploadStepdefs(UserStepdefs userStepdefs) { + private UploadStepdefs(UserStepdefs userStepdefs, MainStepdefs mainStepdefs) throws URISyntaxException { this.userStepdefs = userStepdefs; + this.mainStepdefs = mainStepdefs; + uploadUri = mainStepdefs.baseUri().setPath("/upload").build(); } @When("^\"([^\"]*)\" upload a content$") public void userUploadContent(String username) throws Throwable { AccessToken accessToken = userStepdefs.tokenByUser.get(username); - RequestSpecification with = with(); + Request request = Request.Post(uploadUri) + .bodyStream(new BufferedInputStream(new ZeroedInputStream(_1M), _1M), org.apache.http.entity.ContentType.DEFAULT_BINARY); if (accessToken != null) { - with.header("Authorization", accessToken.serialize()); + request.addHeader("Authorization", accessToken.serialize()); } - response = with - .config(NO_CHARSET) - .contentType(ContentType.BINARY) - .content(new BufferedInputStream(new ZeroedInputStream(_1M), _1M)) - .post("/upload"); + response = Executor.newInstance(HttpClientBuilder.create().disableAutomaticRetries().build()).execute(request).returnResponse(); } @When("^\"([^\"]*)\" upload a content without content type$") public void userUploadContentWithoutContentType(String username) throws Throwable { AccessToken accessToken = userStepdefs.tokenByUser.get(username); - RequestSpecification with = with(); + Request request = Request.Post(uploadUri) + .bodyByteArray("some text".getBytes(Charsets.UTF_8)); if (accessToken != null) { - with.header("Authorization", accessToken.serialize()); + request.addHeader("Authorization", accessToken.serialize()); } - response = with - .config(NO_CHARSET) - .contentType("") - .content("some text".getBytes(Charsets.UTF_8)) - .post("/upload"); + response = request.execute().returnResponse(); } @When("^\"([^\"]*)\" upload a too big content$") public void userUploadTooBigContent(String username) throws Throwable { AccessToken accessToken = userStepdefs.tokenByUser.get(username); - RequestSpecification with = with(); + Request request = Request.Post(uploadUri) + .bodyStream(new BufferedInputStream(new ZeroedInputStream(_10M), _10M), org.apache.http.entity.ContentType.DEFAULT_BINARY); if (accessToken != null) { - with.header("Authorization", accessToken.serialize()); + request.addHeader("Authorization", accessToken.serialize()); } - response = with - .contentType(ContentType.BINARY) - .content(new BufferedInputStream(new ZeroedInputStream(_10M), _10M)) - .post("/upload"); + response = request.execute().returnResponse(); } @When("^\"([^\"]*)\" checks for the availability of the upload endpoint$") public void optionUpload(String username) throws Throwable { AccessToken accessToken = userStepdefs.tokenByUser.get(username); - RequestSpecification with = with(); + Request request = Request.Options(uploadUri); if (accessToken != null) { - with.header("Authorization", accessToken.serialize()); + request.addHeader("Authorization", accessToken.serialize()); } - response = with - .options("/upload"); + response = request.execute().returnResponse(); } @Then("^the user should receive an authorized response$") public void httpAuthorizedStatus() throws Exception { - response.then() - .statusCode(200); + assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200); } @Then("^the user should receive a created response$") public void httpCreatedStatus() throws Exception { - response.then() - .statusCode(201); + assertThat(response.getStatusLine().getStatusCode()).isEqualTo(201); } @Then("^the user should receive bad request response$") public void httpBadRequestStatus() throws Throwable { - response.then() - .statusCode(400); + assertThat(response.getStatusLine().getStatusCode()).isEqualTo(400); } @Then("^the user should receive a not authorized response$") public void httpUnauthorizedStatus() throws Exception { - response.then() - .statusCode(401); + assertThat(response.getStatusLine().getStatusCode()).isEqualTo(401); } @Then("^the user should receive a request entity too large response$") public void httpRequestEntityTooBigStatus() throws Exception { - response.then() - .statusCode(413); + assertThat(response.getStatusLine().getStatusCode()).isEqualTo(413); } @Then("^the user should receive a specified JSON content$") public void jsonResponse() throws Exception { - response.then() - .contentType(ContentType.JSON) - .body("blobId", equalTo(_1M_ZEROED_FILE_BLOB_ID)) - .body("type", equalTo("application/octet-stream")) - .body("size", equalTo(_1M)); + assertThat(response.getHeaders("Content-Type")).extracting(Header::getValue).containsExactly(org.apache.http.entity.ContentType.APPLICATION_JSON.toString()); + DocumentContext jsonPath = JsonPath.parse(response.getEntity().getContent()); + assertThat(jsonPath.<String>read("blobId")).isEqualTo(_1M_ZEROED_FILE_BLOB_ID); + assertThat(jsonPath.<String>read("type")).isEqualTo("application/octet-stream"); + assertThat(jsonPath.<Integer>read("size")).isEqualTo(_1M); } @Then("^\"([^\"]*)\" should be able to retrieve the content$") public void contentShouldBeRetrievable(String username) throws Exception { AccessToken accessToken = userStepdefs.tokenByUser.get(username); - RequestSpecification with = with(); + Request request = Request.Get(mainStepdefs.baseUri().setPath("/download/" + _1M_ZEROED_FILE_BLOB_ID).build()); if (accessToken != null) { - with.header("Authorization", accessToken.serialize()); + request.addHeader("Authorization", accessToken.serialize()); } - with - .get("/download/" + _1M_ZEROED_FILE_BLOB_ID) - .then() - .statusCode(200); + response = request.execute().returnResponse(); + httpAuthorizedStatus(); } public static class ZeroedInputStream extends InputStream { http://git-wip-us.apache.org/repos/asf/james-project/blob/88f1dbab/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 503fdbf..c805105 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 @@ -27,7 +27,7 @@ import java.util.Set; import javax.inject.Inject; -import org.apache.james.jmap.JmapAuthentication; +import org.apache.james.jmap.HttpJmapAuthentication; import org.apache.james.jmap.api.access.AccessToken; import org.apache.james.mailbox.model.MailboxConstants; @@ -98,7 +98,7 @@ public class UserStepdefs { public void connectUser(String username) throws Throwable { String password = passwordByUser.get(username); Preconditions.checkState(password != null, "unknown user " + username); - AccessToken accessToken = JmapAuthentication.authenticateJamesUser(username, password); + AccessToken accessToken = HttpJmapAuthentication.authenticateJamesUser(mainStepdefs.baseUri(), username, password); tokenByUser.put(username, accessToken); lastConnectedUser = username; } http://git-wip-us.apache.org/repos/asf/james-project/blob/88f1dbab/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 ccd7eef..6772e4f 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 @@ -14,8 +14,8 @@ Feature: Download GET 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 - Then the user should not be authorized + When "[email protected]" downloads "2" with a valid authentication token but a bad blobId + Then the user 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" --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
