From 926bdf95c75ac8f4abbc403b0a2c24327e405903 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 27 Aug 2018 10:20:47 +0300 Subject: merge tests from www-2.x --- .../java/com/juick/server/tests/ServerTests.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'juick-server/src/test') 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 9f573e82..88cdd24c 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 @@ -1225,6 +1225,7 @@ public class ServerTests { assertThat(getStatus.get().getInbound().size(), is(0)); ConnectionIn test = new ConnectionIn(server, new Socket("localhost", server.getServerPort())); test.from.add(Jid.of("test")); + server.getInConnections().clear(); server.addConnectionIn(test); assertThat(getStatus.get().getInbound().size(), is(1)); } @@ -1255,4 +1256,30 @@ public class ServerTests { // uid, name, xmlns, xmlns:user assertThat(attrs.getLength(), is(4)); } + @Test + public void bannedUserBlogandPostShouldReturn404() throws Exception { + String userName = "isilmine"; + String userPassword = "secret"; + String msgText = "автор этого поста был забанен"; + + User isilmine = userService.getUserByUID(userService.createUser(userName, userPassword)).orElseThrow(IllegalStateException::new); + int mid = messagesService.createMessage(isilmine.getUid(), msgText, null, null); + mockMvc.perform(get(String.format("/thread?mid=%d", mid)).with(httpBasic(ugnichName, ugnichPassword))) + .andExpect(status().isOk()); + jdbcTemplate.update("UPDATE users SET banned=1 WHERE id=?", isilmine.getUid()); + mockMvc.perform(get(String.format("/thread?mid=%d", mid)).with(httpBasic(ugnichName, ugnichPassword))) + .andExpect(status().isNotFound()); + mockMvc.perform(get("/messages?uname=isilmine").with(httpBasic(ugnichName, ugnichPassword))) + .andExpect(status().isNotFound()); + } + + @Test + public void emptyPasswordMeansUserIsDisabled() throws Exception { + String userName = "oldschooluser"; + String userPassword = ""; + + userService.createUser(userName, userPassword); + + mockMvc.perform(get("/auth").with(httpBasic(userName, userPassword))).andExpect(status().isUnauthorized()); + } } -- cgit v1.2.3