From 9b09eee990e1e0e7fe99be27f7cd893b3b78c473 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 9 Aug 2019 12:28:00 +0300 Subject: Add test for email replies --- .../java/com/juick/server/tests/ServerTests.java | 35 ++++++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'src/test') diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index de742447..688e6148 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -891,15 +891,17 @@ public class ServerTests { } @Test public void mailParserTest() throws Exception { - String mail = "MIME-Version: 1.0\n" + + emailService.addEmail(ugnich.getUid(), "ugnich@example.com"); + int mid = messagesService.createMessage(ugnich.getUid(), "text", StringUtils.EMPTY, Collections.emptyList()); + String mail = String.format("MIME-Version: 1.0\n" + "Received: by 10.176.0.242 with HTTP; Fri, 16 Mar 2018 05:31:50 -0700 (PDT)\n" + - "In-Reply-To: <2891710.100@juick.com>\n" + - "References: <2891710.0@juick.com> <2891710.100@juick.com>\n" + + "In-Reply-To: <%d.0@juick.com>\n" + + "References: <%d.0@juick.com>\n" + "Date: Fri, 16 Mar 2018 15:31:50 +0300\n" + - "Delivered-To: vitalyster@gmail.com\n" + + "Delivered-To: ugnich@example.com\n" + "Message-ID: \n" + "Subject: Re: New reply to TJ\n" + - "From: Vitaly Takmazov \n" + + "From: Ugnich \n" + "To: Juick \n" + "Content-Type: multipart/alternative; boundary=\"001a11454886e42be5056786ca70\"\n" + "\n" + @@ -913,9 +915,30 @@ public class ServerTests { "\n" + "
s2313334
\n" + "\n" + - "--001a11454886e42be5056786ca70--"; + "--001a11454886e42be5056786ca70--", mid, mid); mockMvc.perform(post("/api/mail").with(httpBasic(juickName, juickPassword)).content(mail)) .andExpect(status().isOk()); + String reply = "Return-Path: \n" + + "Received: from [192.168.88.140] ([91.244.168.38])\n" + + " by smtp.gmail.com with ESMTPSA id r84sm3970197lja.54.2019.06.20.08.39.54\n" + + " for \n" + + " (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n" + + " Thu, 20 Jun 2019 08:39:54 -0700 (PDT)\n" + + "From: Ugnich \n" + + "Content-Type: text/plain; charset=utf-8\n" + + "Content-Transfer-Encoding: base64\n" + + "Mime-Version: 1.0 (1.0)\n" + + "Date: Thu, 20 Jun 2019 18:39:54 +0300\n" + + "Subject: Re: New reply to vt\n" + + "Message-Id: <40BC3538-0A0C-4BD0-8F11-5408A85CC6EF@gmail.com>\n" + + "References: <2945559.7@juick.com>\n" + + "In-Reply-To: \n" + + "To: juick@juick.com\n" + + "X-Mailer: iPhone Mail (16F203)\n" + + "\n" + + "0J3RgyDRjdGC0L4g0L/QvtC60LAhINCU0L7Qu9Cz0L4g0LvQuCwg0YPQvNC10Y7Rh9C4IQ=="; + mockMvc.perform(post("/api/mail").with(httpBasic(juickName, juickPassword)).content(reply)) + .andExpect(status().isOk()); } @Test -- cgit v1.2.3