james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [19/24] james-project git commit: JAMES-2366 Factorize baseUri in JMAP integration tests
Date Fri, 06 Apr 2018 13:20:38 GMT
JAMES-2366 Factorize baseUri in JMAP integration tests


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

Branch: refs/heads/master
Commit: a2f301f454848285457a55bbed79dfef01f40522
Parents: fa564d2
Author: benwa <btellier@linagora.com>
Authored: Thu Apr 5 16:48:03 2018 +0700
Committer: Antoine Duprat <aduprat@linagora.com>
Committed: Fri Apr 6 15:04:49 2018 +0200

----------------------------------------------------------------------
 .../java/org/apache/james/ESReporterTest.java   | 14 ++------
 .../apache/james/FixingGhostMailboxTest.java    | 15 ++------
 .../org/apache/james/jmap/JmapURIBuilder.java   | 37 ++++++++++++++++++++
 .../org/apache/james/jmap/ProvisioningTest.java | 16 +++------
 .../james/jmap/VacationIntegrationTest.java     | 37 ++++++++------------
 .../integration/ForwardIntegrationTest.java     | 30 ++++++----------
 .../integration/GetMailboxesMethodTest.java     | 15 ++------
 .../integration/GetMessageListMethodTest.java   | 17 +++------
 .../integration/GetVacationResponseTest.java    | 16 ++-------
 .../methods/integration/SendMDNMethodTest.java  | 18 +++-------
 .../integration/SetMailboxesMethodTest.java     | 17 ++-------
 .../integration/SetVacationResponseTest.java    | 16 ++-------
 .../integration/SpamAssassinContract.java       | 15 ++------
 .../integration/cucumber/DownloadStepdefs.java  | 29 +++++++--------
 .../integration/cucumber/HttpClient.java        |  4 ++-
 .../integration/cucumber/MainStepdefs.java      | 12 -------
 .../integration/cucumber/UploadStepdefs.java    |  5 +--
 .../integration/cucumber/UserStepdefs.java      |  6 ++--
 18 files changed, 119 insertions(+), 200 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/a2f301f4/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java
index 03eb38b..a020a49 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java
@@ -22,6 +22,8 @@ import static com.jayway.awaitility.Awaitility.await;
 import static com.jayway.restassured.RestAssured.given;
 import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
 import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
+import static org.apache.james.jmap.HttpJmapAuthentication.authenticateJamesUser;
+import static org.apache.james.jmap.JmapURIBuilder.baseUri;
 
 import java.net.InetAddress;
 import java.nio.charset.StandardCharsets;
@@ -31,8 +33,6 @@ import java.util.TimerTask;
 import java.util.stream.Collectors;
 
 import org.apache.commons.net.imap.IMAPClient;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.james.jmap.HttpJmapAuthentication;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.modules.TestESMetricReporterModule;
 import org.apache.james.utils.DataProbeImpl;
@@ -87,19 +87,11 @@ public class ESReporterTest {
                 .setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(StandardCharsets.UTF_8)))
                 .setPort(server.getProbe(JmapGuiceProbe.class).getJmapPort())
                 .build();
-        accessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), USERNAME, PASSWORD);
+        accessToken = authenticateJamesUser(baseUri(server), USERNAME, PASSWORD);
 
         timer = new Timer();
     }
 
-    private URIBuilder baseUri() {
-        return new URIBuilder()
-            .setScheme("http")
-            .setHost("localhost")
-            .setPort(server.getProbe(JmapGuiceProbe.class).getJmapPort())
-            .setCharset(StandardCharsets.UTF_8);
-    }
-
     @After
     public void tearDown() throws Exception {
         timer.cancel();

http://git-wip-us.apache.org/repos/asf/james-project/blob/a2f301f4/server/container/guice/cassandra-guice/src/test/java/org/apache/james/FixingGhostMailboxTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/FixingGhostMailboxTest.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/FixingGhostMailboxTest.java
index 5de81da..f5d30e3 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/FixingGhostMailboxTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/FixingGhostMailboxTest.java
@@ -25,6 +25,8 @@ import static com.jayway.restassured.RestAssured.given;
 import static com.jayway.restassured.RestAssured.with;
 import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
 import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
+import static org.apache.james.jmap.HttpJmapAuthentication.authenticateJamesUser;
+import static org.apache.james.jmap.JmapURIBuilder.baseUri;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.hamcrest.Matchers.contains;
 import static org.hamcrest.Matchers.containsInAnyOrder;
@@ -41,10 +43,8 @@ import java.util.Date;
 
 import javax.mail.Flags;
 
-import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.backends.cassandra.ContainerLifecycleConfiguration;
 import org.apache.james.backends.cassandra.init.CassandraTypesProvider;
-import org.apache.james.jmap.HttpJmapAuthentication;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.mailbox.cassandra.mail.task.MailboxMergingTask;
 import org.apache.james.mailbox.cassandra.mail.utils.MailboxBaseTupleUtil;
@@ -151,7 +151,7 @@ public class FixingGhostMailboxTest {
         dataProbe.addDomain(domain);
         dataProbe.addUser(alice, alicePassword);
         dataProbe.addUser(bob, "bobSecret");
-        accessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), alice, alicePassword);
+        accessToken = authenticateJamesUser(baseUri(jmapServer), alice, alicePassword);
 
         session = Cluster.builder()
             .addContactPoint(cassandra.getIp())
@@ -198,15 +198,6 @@ public class FixingGhostMailboxTest {
         return new ByteArrayInputStream("Subject: toto\r\n\r\ncontent".getBytes(StandardCharsets.UTF_8));
     }
 
-    private URIBuilder baseUri() {
-        return new URIBuilder()
-            .setScheme("http")
-            .setHost("localhost")
-            .setPort(jmapServer.getProbe(JmapGuiceProbe.class)
-                .getJmapPort())
-            .setCharset(Charsets.UTF_8);
-    }
-
     @After
     public void teardown() {
         jmapServer.stop();

http://git-wip-us.apache.org/repos/asf/james-project/blob/a2f301f4/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JmapURIBuilder.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JmapURIBuilder.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JmapURIBuilder.java
new file mode 100644
index 0000000..a966ac4
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JmapURIBuilder.java
@@ -0,0 +1,37 @@
+/****************************************************************
+ * 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.nio.charset.StandardCharsets;
+
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.utils.JmapGuiceProbe;
+
+public class JmapURIBuilder {
+
+    public static URIBuilder baseUri(GuiceJamesServer jamesServer) {
+        return new URIBuilder()
+            .setScheme("http")
+            .setHost("localhost")
+            .setPort(jamesServer.getProbe(JmapGuiceProbe.class)
+                .getJmapPort())
+            .setCharset(StandardCharsets.UTF_8);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/a2f301f4/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ProvisioningTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ProvisioningTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ProvisioningTest.java
index fdce82a..d3bc3c9 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ProvisioningTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ProvisioningTest.java
@@ -21,16 +21,16 @@ package org.apache.james.jmap;
 
 import static com.jayway.restassured.RestAssured.given;
 import static com.jayway.restassured.RestAssured.with;
+import static org.apache.james.jmap.HttpJmapAuthentication.authenticateJamesUser;
+import static org.apache.james.jmap.JmapURIBuilder.baseUri;
 import static org.apache.james.jmap.TestingConstants.jmapRequestSpecBuilder;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.hasItems;
 import static org.hamcrest.Matchers.hasSize;
 
-import java.nio.charset.StandardCharsets;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.GuiceJamesServer;
 import org.apache.james.mailbox.DefaultMailboxes;
 import org.apache.james.modules.MailboxProbeImpl;
@@ -74,7 +74,7 @@ public abstract class ProvisioningTest {
 
     @Test
     public void provisionMailboxesShouldNotDuplicateMailboxByName() throws Exception {
-        String token = HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER, PASSWORD).serialize();
+        String token = authenticateJamesUser(baseUri(jmapServer), USER, PASSWORD).serialize();
 
         boolean termination = new ConcurrentTestRunner(10, 1,
             (a, b) -> with()
@@ -100,7 +100,7 @@ public abstract class ProvisioningTest {
 
     @Test
     public void provisionMailboxesShouldSubscribeToThem() throws Exception {
-        String token = HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER, PASSWORD).serialize();
+        String token = authenticateJamesUser(baseUri(jmapServer), USER, PASSWORD).serialize();
 
         with()
             .header("Authorization", token)
@@ -111,12 +111,4 @@ public abstract class ProvisioningTest {
             .listSubscriptions(USER))
             .containsAll(DefaultMailboxes.DEFAULT_MAILBOXES);
     }
-
-    private URIBuilder baseUri() {
-        return new URIBuilder()
-            .setScheme("http")
-            .setHost("localhost")
-            .setPort(jmapServer.getProbe(JmapGuiceProbe.class).getJmapPort())
-            .setCharset(StandardCharsets.UTF_8);
-    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a2f301f4/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java
index fd02e35..ffed249 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java
@@ -21,18 +21,18 @@ package org.apache.james.jmap;
 
 import static com.jayway.restassured.RestAssured.given;
 import static com.jayway.restassured.RestAssured.with;
+import static org.apache.james.jmap.HttpJmapAuthentication.authenticateJamesUser;
+import static org.apache.james.jmap.JmapURIBuilder.baseUri;
 import static org.apache.james.jmap.TestingConstants.calmlyAwait;
 import static org.apache.james.jmap.TestingConstants.jmapRequestSpecBuilder;
 import static org.hamcrest.Matchers.empty;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.hasSize;
 
-import java.nio.charset.StandardCharsets;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.GuiceJamesServer;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.jmap.api.vacation.AccountId;
@@ -93,15 +93,6 @@ public abstract class VacationIntegrationTest {
             .build();
     }
 
-    private URIBuilder baseUri() {
-        return new URIBuilder()
-            .setScheme("http")
-            .setHost("localhost")
-            .setPort(guiceJamesServer.getProbe(JmapGuiceProbe.class)
-                .getJmapPort())
-            .setCharset(StandardCharsets.UTF_8);
-    }
-
     @After
     public void teardown() {
         guiceJamesServer.stop();
@@ -117,8 +108,8 @@ public abstract class VacationIntegrationTest {
         */
 
         // Given
-        AccessToken user1AccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_1, PASSWORD);
-        AccessToken user2AccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_2, PASSWORD);
+        AccessToken user1AccessToken = authenticateJamesUser(baseUri(guiceJamesServer), USER_1, PASSWORD);
+        AccessToken user2AccessToken = authenticateJamesUser(baseUri(guiceJamesServer), USER_2, PASSWORD);
         // User 1 benw@mydomain.tld sets a Vacation on its account
         setVacationResponse(user1AccessToken);
 
@@ -139,8 +130,8 @@ public abstract class VacationIntegrationTest {
     @Test
     public void jmapVacationShouldGenerateAReplyEvenWhenNoText() throws Exception {
         // Given
-        AccessToken user1AccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_1, PASSWORD);
-        AccessToken user2AccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_2, PASSWORD);
+        AccessToken user1AccessToken = authenticateJamesUser(baseUri(guiceJamesServer), USER_1, PASSWORD);
+        AccessToken user2AccessToken = authenticateJamesUser(baseUri(guiceJamesServer), USER_2, PASSWORD);
         jmapGuiceProbe.modifyVacation(
             AccountId.fromString(USER_1),
             VacationPatch.builder()
@@ -163,8 +154,8 @@ public abstract class VacationIntegrationTest {
     @Test
     public void jmapVacationShouldHaveSupportForHtmlMail() throws Exception {
         // Given
-        AccessToken user1AccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_1, PASSWORD);
-        AccessToken user2AccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_2, PASSWORD);
+        AccessToken user1AccessToken = authenticateJamesUser(baseUri(guiceJamesServer), USER_1, PASSWORD);
+        AccessToken user2AccessToken = authenticateJamesUser(baseUri(guiceJamesServer), USER_2, PASSWORD);
         setHtmlVacationResponse(user1AccessToken);
 
         // When
@@ -187,8 +178,8 @@ public abstract class VacationIntegrationTest {
         */
 
         // Given
-        AccessToken user1AccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_1, PASSWORD);
-        AccessToken user2AccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_2, PASSWORD);
+        AccessToken user1AccessToken = authenticateJamesUser(baseUri(guiceJamesServer), USER_1, PASSWORD);
+        AccessToken user2AccessToken = authenticateJamesUser(baseUri(guiceJamesServer), USER_2, PASSWORD);
 
         // When
         // User 2 matthieu@mydomain.tld sends User 1 a mail
@@ -228,8 +219,8 @@ public abstract class VacationIntegrationTest {
         */
 
         // Given
-        AccessToken user1AccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_1, PASSWORD);
-        AccessToken user2AccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_2, PASSWORD);
+        AccessToken user1AccessToken = authenticateJamesUser(baseUri(guiceJamesServer), USER_1, PASSWORD);
+        AccessToken user2AccessToken = authenticateJamesUser(baseUri(guiceJamesServer), USER_2, PASSWORD);
         // User 1 benw@mydomain.tld sets a Vacation on its account
         setVacationResponse(user1AccessToken);
 
@@ -259,8 +250,8 @@ public abstract class VacationIntegrationTest {
         */
 
         // Given
-        AccessToken user1AccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_1, PASSWORD);
-        AccessToken user2AccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_2, PASSWORD);
+        AccessToken user1AccessToken = authenticateJamesUser(baseUri(guiceJamesServer), USER_1, PASSWORD);
+        AccessToken user2AccessToken = authenticateJamesUser(baseUri(guiceJamesServer), USER_2, PASSWORD);
         // User 1 benw@mydomain.tld sets a Vacation on its account
         setVacationResponse(user1AccessToken);
         // User 2 matthieu@mydomain.tld sends User 1 a mail

http://git-wip-us.apache.org/repos/asf/james-project/blob/a2f301f4/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/ForwardIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/ForwardIntegrationTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/ForwardIntegrationTest.java
index 7f8f047..92d02b6 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/ForwardIntegrationTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/ForwardIntegrationTest.java
@@ -21,19 +21,18 @@ package org.apache.james.jmap.methods.integration;
 
 import static com.jayway.restassured.RestAssured.given;
 import static com.jayway.restassured.RestAssured.with;
+import static org.apache.james.jmap.HttpJmapAuthentication.authenticateJamesUser;
+import static org.apache.james.jmap.JmapURIBuilder.baseUri;
 import static org.apache.james.jmap.TestingConstants.calmlyAwait;
 import static org.apache.james.jmap.TestingConstants.jmapRequestSpecBuilder;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.hasSize;
 
-import java.nio.charset.StandardCharsets;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.GuiceJamesServer;
-import org.apache.james.jmap.HttpJmapAuthentication;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.mailbox.Role;
 import org.apache.james.probe.DataProbe;
@@ -96,7 +95,7 @@ public abstract class ForwardIntegrationTest {
     public void messageShouldBeForwardedWhenDefinedInRESTAPI() {
         webAdminApi.put(String.format("/address/forwards/%s/targets/%s", ALICE, BOB));
 
-        AccessToken cedricAccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), CEDRIC, CEDRIC_PASSWORD);
+        AccessToken cedricAccessToken = authenticateJamesUser(baseUri(jmapServer), CEDRIC, CEDRIC_PASSWORD);
         String messageCreationId = "creationId1337";
         String requestBody = "[" +
             "  [" +
@@ -123,7 +122,7 @@ public abstract class ForwardIntegrationTest {
             .body(requestBody)
         .post("/jmap");
 
-        AccessToken bobAccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), BOB, BOB_PASSWORD);
+        AccessToken bobAccessToken = authenticateJamesUser(baseUri(jmapServer), BOB, BOB_PASSWORD);
         calmlyAwait.atMost(30, TimeUnit.SECONDS).until(() -> isAnyMessageFoundInRecipientsMailboxes(bobAccessToken));
         given()
             .header("Authorization", bobAccessToken.serialize())
@@ -142,8 +141,8 @@ public abstract class ForwardIntegrationTest {
         webAdminApi.put(String.format("/address/forwards/%s/targets/%s", ALICE, BOB));
         webAdminApi.put(String.format("/address/forwards/%s/targets/%s", ALICE, ALICE));
 
-        AccessToken cedricAccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), CEDRIC, CEDRIC_PASSWORD);
-        AccessToken aliceAccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), ALICE, ALICE_PASSWORD);
+        AccessToken cedricAccessToken = authenticateJamesUser(baseUri(jmapServer), CEDRIC, CEDRIC_PASSWORD);
+        AccessToken aliceAccessToken = authenticateJamesUser(baseUri(jmapServer), ALICE, ALICE_PASSWORD);
         String messageCreationId = "creationId1337";
         String requestBody = "[" +
             "  [" +
@@ -170,7 +169,7 @@ public abstract class ForwardIntegrationTest {
             .body(requestBody)
         .post("/jmap");
 
-        AccessToken bobAccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), BOB, BOB_PASSWORD);
+        AccessToken bobAccessToken = authenticateJamesUser(baseUri(jmapServer), BOB, BOB_PASSWORD);
         calmlyAwait.atMost(30, TimeUnit.SECONDS).until(() -> isAnyMessageFoundInRecipientsMailboxes(bobAccessToken));
         given()
             .header("Authorization", bobAccessToken.serialize())
@@ -199,8 +198,8 @@ public abstract class ForwardIntegrationTest {
     public void baseRecipientShouldNotReceiveEmailOnDefaultForward() {
         webAdminApi.put(String.format("/address/forwards/%s/targets/%s", ALICE, BOB));
 
-        AccessToken cedricAccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), CEDRIC, CEDRIC_PASSWORD);
-        AccessToken aliceAccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), ALICE, ALICE_PASSWORD);
+        AccessToken cedricAccessToken = authenticateJamesUser(baseUri(jmapServer), CEDRIC, CEDRIC_PASSWORD);
+        AccessToken aliceAccessToken = authenticateJamesUser(baseUri(jmapServer), ALICE, ALICE_PASSWORD);
         String messageCreationId = "creationId1337";
         String requestBody = "[" +
             "  [" +
@@ -227,7 +226,7 @@ public abstract class ForwardIntegrationTest {
             .body(requestBody)
         .post("/jmap");
 
-        AccessToken bobAccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), BOB, BOB_PASSWORD);
+        AccessToken bobAccessToken = authenticateJamesUser(baseUri(jmapServer), BOB, BOB_PASSWORD);
         calmlyAwait.atMost(30, TimeUnit.SECONDS).until(() -> isAnyMessageFoundInRecipientsMailboxes(bobAccessToken));
 
         given()
@@ -242,15 +241,6 @@ public abstract class ForwardIntegrationTest {
             .body(ARGUMENTS + ".messageIds", hasSize(0));
     }
 
-    private URIBuilder baseUri() {
-        return new URIBuilder()
-            .setScheme("http")
-            .setHost("localhost")
-            .setPort(jmapServer.getProbe(JmapGuiceProbe.class)
-                .getJmapPort())
-            .setCharset(StandardCharsets.UTF_8);
-    }
-
     private String getOutboxId(AccessToken accessToken) {
         return getMailboxId(accessToken, Role.OUTBOX);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a2f301f4/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
index e9506cf..74a8f53 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java
@@ -20,6 +20,8 @@
 package org.apache.james.jmap.methods.integration;
 
 import static com.jayway.restassured.RestAssured.given;
+import static org.apache.james.jmap.HttpJmapAuthentication.authenticateJamesUser;
+import static org.apache.james.jmap.JmapURIBuilder.baseUri;
 import static org.apache.james.jmap.TestingConstants.jmapRequestSpecBuilder;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.hamcrest.Matchers.empty;
@@ -44,9 +46,7 @@ import java.util.Optional;
 
 import javax.mail.Flags;
 
-import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.GuiceJamesServer;
-import org.apache.james.jmap.HttpJmapAuthentication;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.jmap.model.mailbox.MailboxNamespace;
 import org.apache.james.mailbox.DefaultMailboxes;
@@ -121,16 +121,7 @@ public abstract class GetMailboxesMethodTest {
         dataProbe.addDomain(domain);
         dataProbe.addUser(alice, alicePassword);
         dataProbe.addUser(bob, "bobSecret");
-        accessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), alice, alicePassword);
-    }
-
-    private URIBuilder baseUri() {
-        return new URIBuilder()
-            .setScheme("http")
-            .setHost("localhost")
-            .setPort(jmapServer.getProbe(JmapGuiceProbe.class)
-                .getJmapPort())
-            .setCharset(StandardCharsets.UTF_8);
+        accessToken = authenticateJamesUser(baseUri(jmapServer), alice, alicePassword);
     }
 
     @After

http://git-wip-us.apache.org/repos/asf/james-project/blob/a2f301f4/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
index f33ca0d..5eff994 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
@@ -20,6 +20,8 @@
 package org.apache.james.jmap.methods.integration;
 
 import static com.jayway.restassured.RestAssured.given;
+import static org.apache.james.jmap.HttpJmapAuthentication.authenticateJamesUser;
+import static org.apache.james.jmap.JmapURIBuilder.baseUri;
 import static org.apache.james.jmap.TestingConstants.jmapRequestSpecBuilder;
 import static org.hamcrest.Matchers.allOf;
 import static org.hamcrest.Matchers.contains;
@@ -38,9 +40,7 @@ import java.util.Date;
 
 import javax.mail.Flags;
 
-import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.GuiceJamesServer;
-import org.apache.james.jmap.HttpJmapAuthentication;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.jmap.model.Number;
 import org.apache.james.mailbox.FlagsBuilder;
@@ -108,21 +108,12 @@ public abstract class GetMessageListMethodTest {
         dataProbe.addDomain(domain);
         String alicePassword = "alicePassword";
         dataProbe.addUser(alice, alicePassword);
-        this.aliceAccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), alice, alicePassword);
+        this.aliceAccessToken = authenticateJamesUser(baseUri(jmapServer), alice, alicePassword);
 
         this.bob = "bob@" + domain;
         String bobPassword = "bobPassword";
         dataProbe.addUser(bob, bobPassword);
-        this.bobAccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), bob, bobPassword);
-    }
-
-    private URIBuilder baseUri() {
-        return new URIBuilder()
-            .setScheme("http")
-            .setHost("localhost")
-            .setPort(jmapServer.getProbe(JmapGuiceProbe.class)
-                .getJmapPort())
-            .setCharset(StandardCharsets.UTF_8);
+        this.bobAccessToken = authenticateJamesUser(baseUri(jmapServer), bob, bobPassword);
     }
 
     @After

http://git-wip-us.apache.org/repos/asf/james-project/blob/a2f301f4/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetVacationResponseTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetVacationResponseTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetVacationResponseTest.java
index df02cac..a4c5b6a 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetVacationResponseTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetVacationResponseTest.java
@@ -20,18 +20,17 @@
 package org.apache.james.jmap.methods.integration;
 
 import static com.jayway.restassured.RestAssured.given;
+import static org.apache.james.jmap.HttpJmapAuthentication.authenticateJamesUser;
+import static org.apache.james.jmap.JmapURIBuilder.baseUri;
 import static org.apache.james.jmap.TestingConstants.jmapRequestSpecBuilder;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.hasSize;
 import static org.hamcrest.core.IsNull.nullValue;
 
-import java.nio.charset.StandardCharsets;
 import java.time.ZonedDateTime;
 
-import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.GuiceJamesServer;
 import org.apache.james.jmap.FixedDateZonedDateTimeProvider;
-import org.apache.james.jmap.HttpJmapAuthentication;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.jmap.api.vacation.AccountId;
 import org.apache.james.jmap.api.vacation.VacationPatch;
@@ -83,20 +82,11 @@ public abstract class GetVacationResponseTest {
         DataProbe dataProbe = jmapServer.getProbe(DataProbeImpl.class);
         dataProbe.addDomain(USERS_DOMAIN);
         dataProbe.addUser(USER, PASSWORD);
-        accessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER, PASSWORD);
+        accessToken = authenticateJamesUser(baseUri(jmapServer), USER, PASSWORD);
 
         await();
     }
 
-    private URIBuilder baseUri() {
-        return new URIBuilder()
-            .setScheme("http")
-            .setHost("localhost")
-            .setPort(jmapServer.getProbe(JmapGuiceProbe.class)
-                .getJmapPort())
-            .setCharset(StandardCharsets.UTF_8);
-    }
-
     @After
     public void teardown() {
         jmapServer.stop();

http://git-wip-us.apache.org/repos/asf/james-project/blob/a2f301f4/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
index 23b0b90..cc3d9c9 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SendMDNMethodTest.java
@@ -21,6 +21,8 @@ package org.apache.james.jmap.methods.integration;
 
 import static com.jayway.restassured.RestAssured.given;
 import static com.jayway.restassured.RestAssured.with;
+import static org.apache.james.jmap.HttpJmapAuthentication.authenticateJamesUser;
+import static org.apache.james.jmap.JmapURIBuilder.baseUri;
 import static org.apache.james.jmap.TestingConstants.calmlyAwait;
 import static org.apache.james.jmap.TestingConstants.jmapRequestSpecBuilder;
 import static org.hamcrest.Matchers.contains;
@@ -31,14 +33,11 @@ import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.notNullValue;
 import static org.hamcrest.Matchers.startsWith;
 
-import java.nio.charset.StandardCharsets;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
 
-import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.GuiceJamesServer;
-import org.apache.james.jmap.HttpJmapAuthentication;
 import org.apache.james.jmap.MessageAppender;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.mailbox.DefaultMailboxes;
@@ -95,8 +94,8 @@ public abstract class SendMDNMethodTest {
         dataProbe.addUser(HOMER, PASSWORD);
         dataProbe.addUser(BART, BOB_PASSWORD);
         mailboxProbe.createMailbox("#private", HOMER, DefaultMailboxes.INBOX);
-        homerAccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), HOMER, PASSWORD);
-        bartAccessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), BART, BOB_PASSWORD);
+        homerAccessToken = authenticateJamesUser(baseUri(jmapServer), HOMER, PASSWORD);
+        bartAccessToken = authenticateJamesUser(baseUri(jmapServer), BART, BOB_PASSWORD);
     }
 
     private void bartSendMessageToHomer() {
@@ -164,15 +163,6 @@ public abstract class SendMDNMethodTest {
         calmlyAwait.until(() -> !listMessageIdsForAccount(homerAccessToken).isEmpty());
     }
 
-    private URIBuilder baseUri() {
-        return new URIBuilder()
-            .setScheme("http")
-            .setHost("localhost")
-            .setPort(jmapServer.getProbe(JmapGuiceProbe.class)
-                .getJmapPort())
-            .setCharset(StandardCharsets.UTF_8);
-    }
-
     @After
     public void teardown() {
         jmapServer.stop();

http://git-wip-us.apache.org/repos/asf/james-project/blob/a2f301f4/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java
index a7b5b75..839491d 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java
@@ -21,6 +21,8 @@ package org.apache.james.jmap.methods.integration;
 
 import static com.jayway.restassured.RestAssured.given;
 import static com.jayway.restassured.RestAssured.with;
+import static org.apache.james.jmap.HttpJmapAuthentication.authenticateJamesUser;
+import static org.apache.james.jmap.JmapURIBuilder.baseUri;
 import static org.apache.james.jmap.TestingConstants.jmapRequestSpecBuilder;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.hamcrest.Matchers.contains;
@@ -37,12 +39,8 @@ import static org.hamcrest.Matchers.not;
 import static org.hamcrest.Matchers.nullValue;
 import static org.hamcrest.collection.IsMapWithSize.aMapWithSize;
 
-import java.nio.charset.StandardCharsets;
-
 import org.apache.commons.lang3.StringUtils;
-import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.GuiceJamesServer;
-import org.apache.james.jmap.HttpJmapAuthentication;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.mailbox.DefaultMailboxes;
 import org.apache.james.mailbox.model.MailboxACL;
@@ -106,20 +104,11 @@ public abstract class SetMailboxesMethodTest {
         dataProbe.addDomain(USERS_DOMAIN);
         dataProbe.addUser(username, password);
         inboxId = mailboxProbe.createMailbox("#private", username, DefaultMailboxes.INBOX);
-        accessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), username, password);
+        accessToken = authenticateJamesUser(baseUri(jmapServer), username, password);
 
         await();
     }
 
-    private URIBuilder baseUri() {
-        return new URIBuilder()
-            .setScheme("http")
-            .setHost("localhost")
-            .setPort(jmapServer.getProbe(JmapGuiceProbe.class)
-                .getJmapPort())
-            .setCharset(StandardCharsets.UTF_8);
-    }
-
     @After
     public void teardown() {
         jmapServer.stop();

http://git-wip-us.apache.org/repos/asf/james-project/blob/a2f301f4/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java
index 5644fc9..0724ced 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java
@@ -20,17 +20,16 @@
 package org.apache.james.jmap.methods.integration;
 
 import static com.jayway.restassured.RestAssured.given;
+import static org.apache.james.jmap.HttpJmapAuthentication.authenticateJamesUser;
+import static org.apache.james.jmap.JmapURIBuilder.baseUri;
 import static org.apache.james.jmap.TestingConstants.jmapRequestSpecBuilder;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.hamcrest.Matchers.equalTo;
 
-import java.nio.charset.StandardCharsets;
 import java.time.ZonedDateTime;
 import java.util.Optional;
 
-import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.GuiceJamesServer;
-import org.apache.james.jmap.HttpJmapAuthentication;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.jmap.api.vacation.AccountId;
 import org.apache.james.jmap.api.vacation.Vacation;
@@ -73,20 +72,11 @@ public abstract class SetVacationResponseTest {
 
         jmapServer.getProbe(DataProbeImpl.class).addDomain(USERS_DOMAIN);
         jmapServer.getProbe(DataProbeImpl.class).addUser(USER, PASSWORD);
-        accessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER, PASSWORD);
+        accessToken = authenticateJamesUser(baseUri(jmapServer), USER, PASSWORD);
 
         await();
     }
 
-    private URIBuilder baseUri() {
-        return new URIBuilder()
-            .setScheme("http")
-            .setHost("localhost")
-            .setPort(jmapServer.getProbe(JmapGuiceProbe.class)
-                .getJmapPort())
-            .setCharset(StandardCharsets.UTF_8);
-    }
-
     @After
     public void teardown() {
         jmapServer.stop();

http://git-wip-us.apache.org/repos/asf/james-project/blob/a2f301f4/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinContract.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinContract.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinContract.java
index bf9793a..0599108 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinContract.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinContract.java
@@ -23,6 +23,8 @@ import static com.jayway.restassured.RestAssured.given;
 import static com.jayway.restassured.RestAssured.with;
 import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
 import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
+import static org.apache.james.jmap.HttpJmapAuthentication.authenticateJamesUser;
+import static org.apache.james.jmap.JmapURIBuilder.baseUri;
 import static org.apache.james.jmap.TestingConstants.calmlyAwait;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.hasSize;
@@ -31,9 +33,7 @@ import java.nio.charset.StandardCharsets;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.GuiceJamesServer;
-import org.apache.james.jmap.HttpJmapAuthentication;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.mailbox.Role;
 import org.apache.james.utils.DataProbeImpl;
@@ -81,16 +81,7 @@ public interface SpamAssassinContract {
     }
 
     default AccessToken accessTokenFor(GuiceJamesServer james, String user, String password) {
-        return HttpJmapAuthentication.authenticateJamesUser(baseUri(james), user, password);
-    }
-
-    default URIBuilder baseUri(GuiceJamesServer james) {
-        return new URIBuilder()
-            .setScheme("http")
-            .setHost("localhost")
-            .setPort(james.getProbe(JmapGuiceProbe.class)
-                .getJmapPort())
-            .setCharset(StandardCharsets.UTF_8);
+        return authenticateJamesUser(baseUri(james), user, password);
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/james-project/blob/a2f301f4/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 f6ece8d..a4365ac 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,6 +19,7 @@
 
 package org.apache.james.jmap.methods.integration.cucumber;
 
+import static org.apache.james.jmap.JmapURIBuilder.baseUri;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import java.io.IOException;
@@ -137,7 +138,7 @@ public class DownloadStepdefs {
     @When("^\"([^\"]*)\" checks for the availability of the attachment endpoint$")
     public void optionDownload(String username) throws Throwable {
         AccessToken accessToken = userStepdefs.authenticate(username);
-        URI target = mainStepdefs.baseUri().setPath("/download/" + ONE_ATTACHMENT_EML_ATTACHMENT_BLOB_ID).build();
+        URI target = baseUri(mainStepdefs.jmapServer).setPath("/download/" + ONE_ATTACHMENT_EML_ATTACHMENT_BLOB_ID).build();
         Request request = Request.Options(target);
         if (accessToken != null) {
             request.addHeader("Authorization", accessToken.serialize());
@@ -163,7 +164,7 @@ public class DownloadStepdefs {
                 .orElse(null));
 
         response = Request.Get(
-            mainStepdefs.baseUri()
+            baseUri(mainStepdefs.jmapServer)
                 .setPath("/download/" + attachmentIdOrMessageId)
                 .build())
             .execute()
@@ -176,7 +177,7 @@ public class DownloadStepdefs {
     }
 
     private void downLoad(String username, String blobId) throws IOException, URISyntaxException {
-        URIBuilder uriBuilder = mainStepdefs.baseUri().setPath("/download/" + blobId);
+        URIBuilder uriBuilder = baseUri(mainStepdefs.jmapServer).setPath("/download/" + blobId);
         response = authenticatedDownloadRequest(uriBuilder, blobId, username).execute().returnResponse();
     }
 
@@ -235,7 +236,7 @@ public class DownloadStepdefs {
     }
 
     private void trustForBlobId(String blobId, String username) throws Exception {
-        Response tokenGenerationResponse = Request.Post(mainStepdefs.baseUri().setPath("/download/" + blobId).build())
+        Response tokenGenerationResponse = Request.Post(baseUri(mainStepdefs.jmapServer).setPath("/download/" + blobId).build())
             .addHeader("Authorization", userStepdefs.authenticate(username).serialize())
             .execute();
         String serializedAttachmentAccessToken = tokenGenerationResponse.returnContent().asString();
@@ -249,7 +250,7 @@ public class DownloadStepdefs {
     @When("^\"([^\"]*)\" downloads \"(?:[^\"]*)\" with a valid authentication token but a bad blobId$")
     public void downloadsWithValidToken(String username) {
         userStepdefs.execWithUser(username, () -> {
-            URIBuilder uriBuilder = mainStepdefs.baseUri().setPath("/download/badblobId");
+            URIBuilder uriBuilder = baseUri(mainStepdefs.jmapServer).setPath("/download/badblobId");
             response = Request.Get(uriBuilder.build())
                 .addHeader("Authorization", userStepdefs.authenticate(username).serialize())
                 .execute()
@@ -261,7 +262,7 @@ public class DownloadStepdefs {
     @When("^\"(?:[^\"]*)\" downloads \"([^\"]*)\" without any authentication token$")
     public void getDownloadWithoutToken(String attachmentId) throws Exception {
         String blobId = blobIdByAttachmentId.get(attachmentId);
-        response = Request.Get(mainStepdefs.baseUri().setPath("/download/" + blobId).build())
+        response = Request.Get(baseUri(mainStepdefs.jmapServer).setPath("/download/" + blobId).build())
             .execute()
             .returnResponse();
     }
@@ -270,7 +271,7 @@ public class DownloadStepdefs {
     public void getDownloadWithEmptyToken(String attachmentId) throws Exception {
         String blobId = blobIdByAttachmentId.get(attachmentId);
         response = Request.Get(
-                mainStepdefs.baseUri()
+                baseUri(mainStepdefs.jmapServer)
                     .setPath("/download/" + blobId)
                     .addParameter("access_token", "")
                     .build())
@@ -282,7 +283,7 @@ public class DownloadStepdefs {
     public void getDownloadWithBadToken(String attachmentId) throws Exception {
         String blobId = blobIdByAttachmentId.get(attachmentId);
         response = Request.Get(
-                mainStepdefs.baseUri()
+                baseUri(mainStepdefs.jmapServer)
                     .setPath("/download/" + blobId)
                     .addParameter("access_token", "bad")
                     .build())
@@ -294,7 +295,7 @@ public class DownloadStepdefs {
     public void getDownloadWithUnknownToken(String attachmentId) throws Exception {
         String blobId = blobIdByAttachmentId.get(attachmentId);
         response = Request.Get(
-                mainStepdefs.baseUri()
+                baseUri(mainStepdefs.jmapServer)
                     .setPath("/download/" + blobId)
                     .addParameter("access_token", INVALID_ATTACHMENT_TOKEN)
                     .build())
@@ -306,7 +307,7 @@ public class DownloadStepdefs {
     public void getDownloadWithoutBlobId(String username, String attachmentId) throws Throwable {
         String blobId = blobIdByAttachmentId.get(attachmentId);
 
-        URIBuilder uriBuilder = mainStepdefs.baseUri().setPath("/download/");
+        URIBuilder uriBuilder = baseUri(mainStepdefs.jmapServer).setPath("/download/");
         trustForBlobId(blobId, username);
         AttachmentAccessTokenKey key = new AttachmentAccessTokenKey(username, blobId);
         uriBuilder.addParameter("access_token", attachmentAccessTokens.get(key).serialize());
@@ -319,7 +320,7 @@ public class DownloadStepdefs {
     public void getDownloadWithWrongBlobId(String username, String attachmentId) throws Throwable {
         String blobId = blobIdByAttachmentId.get(attachmentId);
 
-        URIBuilder uriBuilder = mainStepdefs.baseUri().setPath("/download/badbadbadbadbadbadbadbadbadbadbadbadbadb");
+        URIBuilder uriBuilder = baseUri(mainStepdefs.jmapServer).setPath("/download/badbadbadbadbadbadbadbadbadbadbadbadbadb");
         trustForBlobId(blobId, username);
         AttachmentAccessTokenKey key = new AttachmentAccessTokenKey(username, blobId);
         uriBuilder.addParameter("access_token", attachmentAccessTokens.get(key).serialize());
@@ -332,7 +333,7 @@ public class DownloadStepdefs {
     public void postDownload(String username, String attachmentId) throws Throwable {
         String blobId = blobIdByAttachmentId.get(attachmentId);
         AccessToken accessToken = userStepdefs.authenticate(username);
-        response = Request.Post(mainStepdefs.baseUri().setPath("/download/" + blobId).build())
+        response = Request.Post(baseUri(mainStepdefs.jmapServer).setPath("/download/" + blobId).build())
                 .addHeader("Authorization", accessToken.serialize())
                 .execute()
                 .returnResponse();
@@ -341,7 +342,7 @@ public class DownloadStepdefs {
     @When("^\"([^\"]*)\" downloads \"([^\"]*)\" with \"([^\"]*)\" name$")
     public void downloadsWithName(String username, String attachmentId, String name) throws Exception {
         String blobId = blobIdByAttachmentId.get(attachmentId);
-        URIBuilder uriBuilder = mainStepdefs.baseUri().setPath("/download/" + blobId + "/" + name);
+        URIBuilder uriBuilder = baseUri(mainStepdefs.jmapServer).setPath("/download/" + blobId + "/" + name);
         response = authenticatedDownloadRequest(uriBuilder, blobId, username)
                 .execute()
                 .returnResponse();
@@ -350,7 +351,7 @@ public class DownloadStepdefs {
     @When("^\"(?:[^\"]*)\" downloads \"([^\"]*)\" with an expired token$")
     public void getDownloadWithExpiredToken(String attachmentId) throws Exception {
         String blobId = blobIdByAttachmentId.get(attachmentId);
-        response = Request.Get(mainStepdefs.baseUri().setPath("/download/" + blobId)
+        response = Request.Get(baseUri(mainStepdefs.jmapServer).setPath("/download/" + blobId)
                 .addParameter("access_token", EXPIRED_ATTACHMENT_TOKEN)
                 .build())
             .execute()

http://git-wip-us.apache.org/repos/asf/james-project/blob/a2f301f4/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/HttpClient.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/HttpClient.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/HttpClient.java
index 70b8449..c9201a7 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/HttpClient.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/HttpClient.java
@@ -19,6 +19,8 @@
 
 package org.apache.james.jmap.methods.integration.cucumber;
 
+import static org.apache.james.jmap.JmapURIBuilder.baseUri;
+
 import javax.inject.Inject;
 
 import org.apache.http.HttpResponse;
@@ -43,7 +45,7 @@ public class HttpClient {
     }
 
     public void post(String requestBody) throws Exception {
-        response = Request.Post(mainStepdefs.baseUri().setPath("/jmap").build())
+        response = Request.Post(baseUri(mainStepdefs.jmapServer).setPath("/jmap").build())
             .addHeader("Authorization", userStepdefs.authenticate(userStepdefs.getConnectedUser()).serialize())
             .addHeader("Accept", org.apache.http.entity.ContentType.APPLICATION_JSON.getMimeType())
             .bodyString(requestBody, org.apache.http.entity.ContentType.APPLICATION_JSON)

http://git-wip-us.apache.org/repos/asf/james-project/blob/a2f301f4/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 f055598..3eefebb 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,12 +19,10 @@
 
 package org.apache.james.jmap.methods.integration.cucumber;
 
-import java.nio.charset.StandardCharsets;
 import java.util.Collection;
 import java.util.List;
 import java.util.stream.Stream;
 
-import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.GuiceJamesServer;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxId;
@@ -35,7 +33,6 @@ import org.apache.james.modules.ACLProbeImpl;
 import org.apache.james.modules.MailboxProbeImpl;
 import org.apache.james.probe.DataProbe;
 import org.apache.james.utils.DataProbeImpl;
-import org.apache.james.utils.JmapGuiceProbe;
 import org.apache.james.utils.MessageIdProbe;
 
 import com.github.steveash.guavate.Guavate;
@@ -62,16 +59,7 @@ public class MainStepdefs {
         aclProbe = jmapServer.getProbe(ACLProbeImpl.class);
         messageIdProbe = jmapServer.getProbe(MessageIdProbe.class);
     }
-    
 
-    public URIBuilder baseUri() {
-        return new URIBuilder()
-                .setScheme("http")
-                .setHost("localhost")
-                .setPort(jmapServer.getProbe(JmapGuiceProbe.class).getJmapPort())
-                .setCharset(StandardCharsets.UTF_8);
-    }
-    
     public void tearDown() {
         jmapServer.stop();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a2f301f4/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 59c6681..d4362cc 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,6 +19,7 @@
 
 package org.apache.james.jmap.methods.integration.cucumber;
 
+import static org.apache.james.jmap.JmapURIBuilder.baseUri;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import java.io.BufferedInputStream;
@@ -68,7 +69,7 @@ public class UploadStepdefs {
     private UploadStepdefs(UserStepdefs userStepdefs, MainStepdefs mainStepdefs) throws URISyntaxException {
         this.userStepdefs = userStepdefs;
         this.mainStepdefs = mainStepdefs;
-        uploadUri = mainStepdefs.baseUri().setPath("/upload").build();
+        uploadUri = baseUri(mainStepdefs.jmapServer).setPath("/upload").build();
     }
 
     @Given("^\"([^\"]*)\" is starting uploading a content$")
@@ -204,7 +205,7 @@ public class UploadStepdefs {
     @Then("^\"([^\"]*)\" should be able to retrieve the content$")
     public void contentShouldBeRetrievable(String username) throws Exception {
         AccessToken accessToken = userStepdefs.authenticate(username);
-        Request request = Request.Get(mainStepdefs.baseUri().setPath("/download/" + _1M_ZEROED_FILE_BLOB_ID).build());
+        Request request = Request.Get(baseUri(mainStepdefs.jmapServer).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/a2f301f4/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 d81f0be..c65efff 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
@@ -19,6 +19,9 @@
 
 package org.apache.james.jmap.methods.integration.cucumber;
 
+import static org.apache.james.jmap.HttpJmapAuthentication.authenticateJamesUser;
+import static org.apache.james.jmap.JmapURIBuilder.baseUri;
+
 import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -29,7 +32,6 @@ import java.util.Set;
 
 import javax.inject.Inject;
 
-import org.apache.james.jmap.HttpJmapAuthentication;
 import org.apache.james.jmap.api.access.AccessToken;
 
 import com.github.fge.lambdas.Throwing;
@@ -123,7 +125,7 @@ public class UserStepdefs {
             String password = passwordByUser.get(user);
             Preconditions.checkState(password != null, "unknown user " + user);
 
-            return HttpJmapAuthentication.authenticateJamesUser(mainStepdefs.baseUri(), user, password);
+            return authenticateJamesUser(baseUri(mainStepdefs.jmapServer), user, password);
         });
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message