aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/test/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'juick-www/src/test/java/com')
-rw-r--r--juick-www/src/test/java/com/juick/www/WebAppTests.java38
1 files changed, 33 insertions, 5 deletions
diff --git a/juick-www/src/test/java/com/juick/www/WebAppTests.java b/juick-www/src/test/java/com/juick/www/WebAppTests.java
index 32bad137..c663ff6d 100644
--- a/juick-www/src/test/java/com/juick/www/WebAppTests.java
+++ b/juick-www/src/test/java/com/juick/www/WebAppTests.java
@@ -17,6 +17,7 @@
package com.juick.www;
+import com.gargoylesoftware.htmlunit.CookieManager;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.css.StyleElement;
@@ -29,6 +30,7 @@ import com.juick.configuration.RepositoryConfiguration;
import com.juick.service.ImagesService;
import com.juick.service.MessagesService;
import com.juick.service.MockImagesService;
+import com.juick.service.PrivacyQueriesService;
import com.juick.service.UserService;
import com.juick.util.MessageUtils;
import com.juick.www.configuration.SapeConfiguration;
@@ -110,16 +112,18 @@ public class WebAppTests {
private static WebClient webClient;
@Inject
- UserService userService;
+ private UserService userService;
@Inject
- MessagesService messagesService;
+ private MessagesService messagesService;
@Inject
- JdbcTemplate jdbcTemplate;
+ private PrivacyQueriesService privacyQueriesService;
+ @Inject
+ private JdbcTemplate jdbcTemplate;
@Inject
- PebbleEngine pebbleEngine;
+ private PebbleEngine pebbleEngine;
@Value("${img_path:/tmp}")
- String imgPath;
+ private String imgPath;
private static User ugnich, freefd;
private static String ugnichName, ugnichPassword, freefdName, freefdPassword;
@@ -201,6 +205,30 @@ public class WebAppTests {
assertThat(visibleItems, equalTo(1L));
}
@Test
+ public void userShouldNotSeeReplyButtonToBannedUser() throws Exception {
+ int mid = messagesService.createMessage(ugnich.getUid(), "freefd bl me", null, null);
+ messagesService.createReply(mid, 0, ugnich.getUid(), "yo", null);
+ MvcResult loginResult = mockMvc.perform(post("/login")
+ .param("username", freefdName)
+ .param("password", freefdPassword)).andReturn();
+ Cookie loginCookie = loginResult.getResponse().getCookie("juick-remember-me");
+ webClient.setCookieManager(new CookieManager());
+ webClient.getCookieManager().addCookie(
+ new com.gargoylesoftware.htmlunit.util.Cookie(loginCookie.getDomain(),
+ loginCookie.getName(),
+ loginCookie.getValue()));
+ HtmlPage threadPage = webClient.getPage(String.format("http://localhost:8080/ugnich/%d", mid));
+ assertThat(threadPage.getWebResponse().getStatusCode(), equalTo(200));
+ assertThat(threadPage.querySelectorAll(".msg-comment-target").isEmpty(), equalTo(false));
+ assertThat(threadPage.querySelectorAll(".a-thread-comment").isEmpty(), equalTo(false));
+ privacyQueriesService.blacklistUser(freefd, ugnich);
+ assertThat(userService.isInBLAny(freefd.getUid(), ugnich.getUid()), equalTo(true));
+ threadPage = webClient.getPage(String.format("http://localhost:8080/ugnich/%d", mid));
+ assertThat(threadPage.getWebResponse().getStatusCode(), equalTo(200));
+ assertThat(threadPage.querySelectorAll(".msg-comment-target").isEmpty(), equalTo(true));
+ assertThat(threadPage.querySelectorAll(".a-thread-comment").isEmpty(), equalTo(true));
+ }
+ @Test
public void correctTagsEscaping() throws PebbleException, IOException {
PebbleTemplate template = pebbleEngine.getTemplate("views/test");
Writer writer = new StringWriter();