diff options
author | Vitaly Takmazov | 2018-08-27 10:20:47 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-08-27 10:45:58 +0300 |
commit | 926bdf95c75ac8f4abbc403b0a2c24327e405903 (patch) | |
tree | 23f5ac38873c912bcd4d793916fea8e921915123 /juick-server/src/test/java/com/juick | |
parent | b8f55bc41ddbeb9e274436534fd4eb58706f73a9 (diff) |
merge tests from www-2.x
Diffstat (limited to 'juick-server/src/test/java/com/juick')
-rw-r--r-- | juick-server/src/test/java/com/juick/server/tests/ServerTests.java | 27 |
1 files changed, 27 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 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()); + } } |