aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/test/java/com/juick/server
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-08-31 11:12:30 +0300
committerGravatar Vitaly Takmazov2018-08-31 11:21:33 +0300
commit4f94886884b47e19f16da5b987ef1a740b29456e (patch)
treeb9fdacd1b9376437384d143efe7dacd715b954e6 /juick-server/src/test/java/com/juick/server
parent19e259aebc19f29228982fd4f071a50509cb7d76 (diff)
banned user messages are not visible to others
Diffstat (limited to 'juick-server/src/test/java/com/juick/server')
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
index 70555fca..c6d1bc1a 100644
--- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
@@ -1303,4 +1303,20 @@ public class ServerTests {
assertThat(messagesService.getMessage(mid).getLikes(), is(3));
assertThat(CollectionUtils.isEqualCollection(messagesService.getMessageRecommendations(mid), Arrays.asList("fmap", "ermine")), is(true));
}
+ @Test
+ public void bannedUserShouldNotBeVisibleToOthers() {
+ jdbcTemplate.execute("DELETE FROM messages");
+ int casualUserId = userService.createUser("user", "secret");
+ int bannedUserId = userService.createUser("banned", "banned");
+ jdbcTemplate.update("UPDATE users SET banned=1 WHERE id=?", bannedUserId);
+ messagesService.createMessage(bannedUserId, "KURWA", null, Collections.emptyList());
+ assertThat(messagesService.getAll(casualUserId, 0).size(), is(0));
+ assertThat(messagesService.getAll(bannedUserId, 0).size(), is(1));
+ int mid = messagesService.createMessage(casualUserId, "PEACE", null, Collections.emptyList());
+ User banned = userService.getUserByName("banned");
+ int bannedRid = messagesService.createReply(mid, 0, banned, "KURWA", null);
+ int casualRid = messagesService.createReply(mid, 0, userService.getUserByName("user"), "DOOR", null);
+ assertThat(messagesService.getReplies(AnonymousUser.INSTANCE, mid).size(), is(1));
+ assertThat(messagesService.getReplies(banned, mid).size(), is(2));
+ }
}