From 4f94886884b47e19f16da5b987ef1a740b29456e Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 31 Aug 2018 11:12:30 +0300 Subject: banned user messages are not visible to others --- .../test/java/com/juick/server/tests/ServerTests.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'juick-server/src/test/java/com/juick') 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)); + } } -- cgit v1.2.3