Repository: james-project
Updated Branches:
  refs/heads/master 40cf3a96b -> eeb04abaa


JAMES-1896 Take care of unstable test in Cassandra JMAP integration tests using 
HttpJmapAuthentication instead of JmapAuthentication


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

Branch: refs/heads/master
Commit: 1d80aa6460fa1faf0db1146c18c0cde579775586
Parents: 1456d37
Author: Quynh Nguyen <[email protected]>
Authored: Fri Feb 3 09:38:21 2017 +0700
Committer: Quynh Nguyen <[email protected]>
Committed: Fri Feb 3 09:39:18 2017 +0700

----------------------------------------------------------------------
 .../apache/james/jmap/JmapAuthentication.java   | 53 --------------------
 .../james/jmap/VacationIntegrationTest.java     | 34 ++++++++-----
 .../integration/GetMailboxesMethodTest.java     | 14 +++++-
 .../integration/GetMessageListMethodTest.java   | 14 +++++-
 .../integration/GetVacationResponseTest.java    | 14 +++++-
 .../integration/SetMailboxesMethodTest.java     | 14 +++++-
 .../integration/SetMessagesMethodTest.java      | 28 +++++++----
 .../integration/SetVacationResponseTest.java    | 17 +++++--
 8 files changed, 102 insertions(+), 86 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/1d80aa64/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JmapAuthentication.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JmapAuthentication.java
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JmapAuthentication.java
deleted file mode 100644
index cd4ea9b..0000000
--- 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JmapAuthentication.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/****************************************************************
- * 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 static com.jayway.restassured.RestAssured.with;
-
-import org.apache.james.jmap.api.access.AccessToken;
-
-public class JmapAuthentication {
-
-    public static AccessToken authenticateJamesUser(String username, String 
password) {
-        String continuationToken = getContinuationToken(username);
-
-        return AccessToken.fromString(
-            with()
-                .body("{\"token\": \"" + continuationToken + "\", \"method\": 
\"password\", \"password\": \"" + password + "\"}")
-            .post("/authentication")
-            .then()
-                .statusCode(201)
-                .log().ifError()
-            .extract()
-                .body()
-                .jsonPath()
-                .getString("accessToken")
-        );
-    }
-
-    private static String getContinuationToken(String username) {
-        return with()
-            .body("{\"username\": \"" + username + "\", \"clientName\": 
\"Mozilla Thunderbird\", \"clientVersion\": \"42.0\", \"deviceName\": \"Joe 
Blogg’s iPhone\"}")
-        .post("/authentication")
-            .body()
-            .path("continuationToken")
-            .toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1d80aa64/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 00470b9..0ad710d 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
@@ -31,6 +31,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.JmapJamesServer;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.jmap.api.vacation.AccountId;
@@ -98,6 +99,15 @@ public abstract class VacationIntegrationTest {
         calmlyAwait = 
Awaitility.with().pollInterval(slowPacedPollInterval).and().with().pollDelay(slowPacedPollInterval).await();
     }
 
+    private URIBuilder baseUri() {
+        return new URIBuilder()
+            .setScheme("http")
+            .setHost("localhost")
+            .setPort(guiceJamesServer.getJmapProbe()
+                .getJmapPort())
+            .setCharset(Charsets.UTF_8);
+    }
+
     @After
     public void teardown() {
         guiceJamesServer.stop();
@@ -113,8 +123,8 @@ public abstract class VacationIntegrationTest {
         */
 
         // Given
-        AccessToken user1AccessToken = 
JmapAuthentication.authenticateJamesUser(USER_1, PASSWORD);
-        AccessToken user2AccessToken = 
JmapAuthentication.authenticateJamesUser(USER_2, PASSWORD);
+        AccessToken user1AccessToken = 
HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_1, PASSWORD);
+        AccessToken user2AccessToken = 
HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_2, PASSWORD);
         // User 1 [email protected] sets a Vacation on its account
         setVacationResponse(user1AccessToken);
 
@@ -135,8 +145,8 @@ public abstract class VacationIntegrationTest {
     @Test
     public void jmapVacationShouldGenerateAReplyEvenWhenNoText() throws 
Exception {
         // Given
-        AccessToken user1AccessToken = 
JmapAuthentication.authenticateJamesUser(USER_1, PASSWORD);
-        AccessToken user2AccessToken = 
JmapAuthentication.authenticateJamesUser(USER_2, PASSWORD);
+        AccessToken user1AccessToken = 
HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_1, PASSWORD);
+        AccessToken user2AccessToken = 
HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_2, PASSWORD);
         jmapGuiceProbe.modifyVacation(
             AccountId.fromString(USER_1),
             VacationPatch.builder()
@@ -159,8 +169,8 @@ public abstract class VacationIntegrationTest {
     @Test
     public void jmapVacationShouldHaveSupportForHtmlMail() throws Exception {
         // Given
-        AccessToken user1AccessToken = 
JmapAuthentication.authenticateJamesUser(USER_1, PASSWORD);
-        AccessToken user2AccessToken = 
JmapAuthentication.authenticateJamesUser(USER_2, PASSWORD);
+        AccessToken user1AccessToken = 
HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_1, PASSWORD);
+        AccessToken user2AccessToken = 
HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_2, PASSWORD);
         setHtmlVacationResponse(user1AccessToken);
 
         // When
@@ -183,8 +193,8 @@ public abstract class VacationIntegrationTest {
         */
 
         // Given
-        AccessToken user1AccessToken = 
JmapAuthentication.authenticateJamesUser(USER_1, PASSWORD);
-        AccessToken user2AccessToken = 
JmapAuthentication.authenticateJamesUser(USER_2, PASSWORD);
+        AccessToken user1AccessToken = 
HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_1, PASSWORD);
+        AccessToken user2AccessToken = 
HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_2, PASSWORD);
 
         // When
         // User 2 [email protected] sends User 1 a mail
@@ -224,8 +234,8 @@ public abstract class VacationIntegrationTest {
         */
 
         // Given
-        AccessToken user1AccessToken = 
JmapAuthentication.authenticateJamesUser(USER_1, PASSWORD);
-        AccessToken user2AccessToken = 
JmapAuthentication.authenticateJamesUser(USER_2, PASSWORD);
+        AccessToken user1AccessToken = 
HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_1, PASSWORD);
+        AccessToken user2AccessToken = 
HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_2, PASSWORD);
         // User 1 [email protected] sets a Vacation on its account
         setVacationResponse(user1AccessToken);
 
@@ -255,8 +265,8 @@ public abstract class VacationIntegrationTest {
         */
 
         // Given
-        AccessToken user1AccessToken = 
JmapAuthentication.authenticateJamesUser(USER_1, PASSWORD);
-        AccessToken user2AccessToken = 
JmapAuthentication.authenticateJamesUser(USER_2, PASSWORD);
+        AccessToken user1AccessToken = 
HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_1, PASSWORD);
+        AccessToken user2AccessToken = 
HttpJmapAuthentication.authenticateJamesUser(baseUri(), USER_2, PASSWORD);
         // User 1 [email protected] sets a Vacation on its account
         setVacationResponse(user1AccessToken);
         // User 2 [email protected] sends User 1 a mail

http://git-wip-us.apache.org/repos/asf/james-project/blob/1d80aa64/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 33f2666..e75167d 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
@@ -35,8 +35,9 @@ import java.util.Date;
 
 import javax.mail.Flags;
 
+import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.JmapJamesServer;
-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;
 import org.apache.james.mailbox.model.MailboxPath;
@@ -78,7 +79,16 @@ public abstract class GetMailboxesMethodTest {
         String password = "password";
         jmapServer.serverProbe().addDomain(domain);
         jmapServer.serverProbe().addUser(username, password);
-        accessToken = JmapAuthentication.authenticateJamesUser(username, 
password);
+        accessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), 
username, password);
+    }
+
+    private URIBuilder baseUri() {
+        return new URIBuilder()
+            .setScheme("http")
+            .setHost("localhost")
+            .setPort(jmapServer.getJmapProbe()
+                .getJmapPort())
+            .setCharset(Charsets.UTF_8);
     }
 
     @After

http://git-wip-us.apache.org/repos/asf/james-project/blob/1d80aa64/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 65b9dee..ff7d30a 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
@@ -37,8 +37,9 @@ import java.util.List;
 
 import javax.mail.Flags;
 
+import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.JmapJamesServer;
-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.ComposedMessageId;
 import org.apache.james.mailbox.model.MailboxConstants;
@@ -84,7 +85,16 @@ public abstract class GetMessageListMethodTest {
         String password = "password";
         jmapServer.serverProbe().addDomain(domain);
         jmapServer.serverProbe().addUser(username, password);
-        this.accessToken = JmapAuthentication.authenticateJamesUser(username, 
password);
+        this.accessToken = 
HttpJmapAuthentication.authenticateJamesUser(baseUri(), username, password);
+    }
+
+    private URIBuilder baseUri() {
+        return new URIBuilder()
+            .setScheme("http")
+            .setHost("localhost")
+            .setPort(jmapServer.getJmapProbe()
+                .getJmapPort())
+            .setCharset(Charsets.UTF_8);
     }
 
     @After

http://git-wip-us.apache.org/repos/asf/james-project/blob/1d80aa64/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 31f5ee1..a1ff796 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
@@ -28,9 +28,10 @@ import static org.hamcrest.core.IsNull.nullValue;
 
 import java.time.ZonedDateTime;
 
+import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.JmapJamesServer;
 import org.apache.james.jmap.FixedDateZonedDateTimeProvider;
-import org.apache.james.jmap.JmapAuthentication;
+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;
@@ -85,11 +86,20 @@ public abstract class GetVacationResponseTest {
 
         jmapServer.serverProbe().addDomain(USERS_DOMAIN);
         jmapServer.serverProbe().addUser(USER, PASSWORD);
-        accessToken = JmapAuthentication.authenticateJamesUser(USER, PASSWORD);
+        accessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), 
USER, PASSWORD);
 
         await();
     }
 
+    private URIBuilder baseUri() {
+        return new URIBuilder()
+            .setScheme("http")
+            .setHost("localhost")
+            .setPort(jmapServer.getJmapProbe()
+                .getJmapPort())
+            .setCharset(Charsets.UTF_8);
+    }
+
     @After
     public void teardown() {
         jmapServer.stop();

http://git-wip-us.apache.org/repos/asf/james-project/blob/1d80aa64/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 dc543f5..1e67427 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
@@ -38,8 +38,9 @@ import static org.hamcrest.Matchers.nullValue;
 import static org.hamcrest.collection.IsMapWithSize.aMapWithSize;
 
 import org.apache.commons.lang3.StringUtils;
+import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.JmapJamesServer;
-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;
 import org.apache.james.mailbox.model.MailboxId;
@@ -88,11 +89,20 @@ public abstract class SetMailboxesMethodTest {
         jmapServer.serverProbe().addDomain(USERS_DOMAIN);
         jmapServer.serverProbe().addUser(username, password);
         jmapServer.serverProbe().createMailbox("#private", username, "inbox");
-        accessToken = JmapAuthentication.authenticateJamesUser(username, 
password);
+        accessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), 
username, password);
 
         await();
     }
 
+    private URIBuilder baseUri() {
+        return new URIBuilder()
+            .setScheme("http")
+            .setHost("localhost")
+            .setPort(jmapServer.getJmapProbe()
+                .getJmapPort())
+            .setCharset(Charsets.UTF_8);
+    }
+
     @After
     public void teardown() {
         jmapServer.stop();

http://git-wip-us.apache.org/repos/asf/james-project/blob/1d80aa64/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
index c043865..d143f2b 100644
--- 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
@@ -50,8 +50,9 @@ import java.util.stream.Collectors;
 import javax.mail.Flags;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.JmapJamesServer;
-import org.apache.james.jmap.JmapAuthentication;
+import org.apache.james.jmap.HttpJmapAuthentication;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.jmap.model.mailbox.Role;
 import org.apache.james.mailbox.exception.MailboxException;
@@ -121,7 +122,7 @@ public abstract class SetMessagesMethodTest {
         jmapServer.serverProbe().addDomain(USERS_DOMAIN);
         jmapServer.serverProbe().addUser(USERNAME, password);
         jmapServer.serverProbe().createMailbox("#private", USERNAME, "inbox");
-        accessToken = JmapAuthentication.authenticateJamesUser(USERNAME, 
password);
+        accessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), 
USERNAME, password);
 
         
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
USERNAME, "outbox");
         
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
USERNAME, "trash");
@@ -132,6 +133,15 @@ public abstract class SetMessagesMethodTest {
         calmlyAwait = 
Awaitility.with().pollInterval(slowPacedPollInterval).and().with().pollDelay(slowPacedPollInterval).await();
     }
 
+    private URIBuilder baseUri() {
+        return new URIBuilder()
+            .setScheme("http")
+            .setHost("localhost")
+            .setPort(jmapServer.getJmapProbe()
+                .getJmapPort())
+            .setCharset(Charsets.UTF_8);
+    }
+
     @After
     public void teardown() {
         jmapServer.stop();
@@ -1199,7 +1209,7 @@ public abstract class SetMessagesMethodTest {
         jmapServer.serverProbe().addUser(recipientAddress, password);
         
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
recipientAddress, "inbox");
         await();
-        AccessToken recipientToken = 
JmapAuthentication.authenticateJamesUser(recipientAddress, password);
+        AccessToken recipientToken = 
HttpJmapAuthentication.authenticateJamesUser(baseUri(), recipientAddress, 
password);
 
         String messageCreationId = "creationId1337";
         String fromAddress = USERNAME;
@@ -1244,7 +1254,7 @@ public abstract class SetMessagesMethodTest {
         jmapServer.serverProbe().addUser(bccRecipient, password);
         
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
recipientAddress, "inbox");
         await();
-        AccessToken recipientToken = 
JmapAuthentication.authenticateJamesUser(recipientAddress, password);
+        AccessToken recipientToken = 
HttpJmapAuthentication.authenticateJamesUser(baseUri(), recipientAddress, 
password);
 
         String messageCreationId = "creationId1337";
         String fromAddress = USERNAME;
@@ -1360,7 +1370,7 @@ public abstract class SetMessagesMethodTest {
         jmapServer.serverProbe().addUser(bccAddress, password);
         
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
bccAddress, "inbox");
         await();
-        AccessToken bccToken = 
JmapAuthentication.authenticateJamesUser(bccAddress, password);
+        AccessToken bccToken = 
HttpJmapAuthentication.authenticateJamesUser(baseUri(), bccAddress, password);
 
         String messageCreationId = "creationId1337";
         String fromAddress = USERNAME;
@@ -1434,7 +1444,7 @@ public abstract class SetMessagesMethodTest {
         jmapServer.serverProbe().addUser(recipientAddress, password);
         
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
recipientAddress, "inbox");
         await();
-        AccessToken recipientToken = 
JmapAuthentication.authenticateJamesUser(recipientAddress, password);
+        AccessToken recipientToken = 
HttpJmapAuthentication.authenticateJamesUser(baseUri(), recipientAddress, 
password);
 
         String messageCreationId = "creationId1337";
         String fromAddress = USERNAME;
@@ -1477,7 +1487,7 @@ public abstract class SetMessagesMethodTest {
         jmapServer.serverProbe().addUser(recipientAddress, recipientPassword);
         
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
recipientAddress, "inbox");
         await();
-        AccessToken recipientToken = 
JmapAuthentication.authenticateJamesUser(recipientAddress, recipientPassword);
+        AccessToken recipientToken = 
HttpJmapAuthentication.authenticateJamesUser(baseUri(), recipientAddress, 
recipientPassword);
 
         String senderDraftsMailboxId = getMailboxId(accessToken, Role.DRAFTS);
 
@@ -1589,7 +1599,7 @@ public abstract class SetMessagesMethodTest {
         jmapServer.serverProbe().addUser(recipientAddress, password);
         
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
recipientAddress, "inbox");
         await();
-        AccessToken recipientToken = 
JmapAuthentication.authenticateJamesUser(recipientAddress, password);
+        AccessToken recipientToken = 
HttpJmapAuthentication.authenticateJamesUser(baseUri(), recipientAddress, 
password);
 
         String messageCreationId = "creationId1337";
         String fromAddress = USERNAME;
@@ -2875,7 +2885,7 @@ public abstract class SetMessagesMethodTest {
             .body(requestBody)
         .post("/jmap");
 
-        accessToken = JmapAuthentication.authenticateJamesUser(toUsername, 
password);
+        accessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), 
toUsername, password);
         String inboxMailboxId = getMailboxId(accessToken, Role.INBOX);
 
         calmlyAwait.atMost(60, TimeUnit.SECONDS).until( () -> 
messageInMailboxHasHeaders(inboxMailboxId, buildExpectedHeaders()));

http://git-wip-us.apache.org/repos/asf/james-project/blob/1d80aa64/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 4b43223..457b46e 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
@@ -22,15 +22,15 @@ package org.apache.james.jmap.methods.integration;
 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.hamcrest.Matchers.equalTo;
-
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.hamcrest.Matchers.equalTo;
 
 import java.time.ZonedDateTime;
 import java.util.Optional;
 
+import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.JmapJamesServer;
-import org.apache.james.jmap.JmapAuthentication;
+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;
@@ -78,11 +78,20 @@ public abstract class SetVacationResponseTest {
 
         jmapServer.serverProbe().addDomain(USERS_DOMAIN);
         jmapServer.serverProbe().addUser(USER, PASSWORD);
-        accessToken = JmapAuthentication.authenticateJamesUser(USER, PASSWORD);
+        accessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), 
USER, PASSWORD);
 
         await();
     }
 
+    private URIBuilder baseUri() {
+        return new URIBuilder()
+            .setScheme("http")
+            .setHost("localhost")
+            .setPort(jmapServer.getJmapProbe()
+                .getJmapPort())
+            .setCharset(Charsets.UTF_8);
+    }
+
     @After
     public void teardown() {
         jmapServer.stop();


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

Reply via email to