diff options
author | Vitaly Takmazov | 2018-02-09 14:55:23 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-02-09 14:55:23 +0300 |
commit | c04eb6d3769f5a52372b560160147f7acc7079e8 (patch) | |
tree | a420e3b834f9e7d4fa2e404894bcba3b67e1f40a | |
parent | eb8c9d95bfbd7e664c9de2767850ec4c465b520b (diff) |
server: add some tests
-rw-r--r-- | juick-server/src/main/java/com/juick/server/VKWallManager.java | 2 | ||||
-rw-r--r-- | juick-server/src/test/java/com/juick/server/tests/MessagesTests.java | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/juick-server/src/main/java/com/juick/server/VKWallManager.java b/juick-server/src/main/java/com/juick/server/VKWallManager.java index 364087eb..5c0fee81 100644 --- a/juick-server/src/main/java/com/juick/server/VKWallManager.java +++ b/juick-server/src/main/java/com/juick/server/VKWallManager.java @@ -43,7 +43,7 @@ public class VKWallManager { serviceUser = userService.getUserByName(serviceUsername); TransportClient transportClient = HttpTransportClient.getInstance(); vk = new VkApiClient(transportClient); - Pair<String, String> tokens = crosspostService.getVkTokens(serviceUser.getUid()).get(); + Pair<String, String> tokens = crosspostService.getVkTokens(serviceUser.getUid()).orElse(Pair.of("0", "0")); actor = new UserActor(Integer.valueOf(tokens.getLeft()), tokens.getRight()); } public void post(String status, String link) throws ClientException, ApiException { diff --git a/juick-server/src/test/java/com/juick/server/tests/MessagesTests.java b/juick-server/src/test/java/com/juick/server/tests/MessagesTests.java index 53267a0f..37973bf5 100644 --- a/juick-server/src/test/java/com/juick/server/tests/MessagesTests.java +++ b/juick-server/src/test/java/com/juick/server/tests/MessagesTests.java @@ -295,6 +295,13 @@ public class MessagesTests extends AbstractJUnit4SpringContextTests { .content(jsonMapper.writeValueAsBytes(tokens))).andExpect(status().isOk()); } @Test + public void notificationsSettingsAllowedOnlyForServiceUser() throws Exception { + mockMvc.perform(get("/notifications").with(httpBasic(juickName, juickPassword)) + .param("mid", "1").param("uid", String.valueOf(ugnich.getUid()))).andExpect(status().isOk()); + mockMvc.perform(get("/notifications") + .param("mid", "1").param("uid", String.valueOf(ugnich.getUid()))).andExpect(status().isUnauthorized()); + } + @Test public void topTest() throws Exception { int topmid = messagesService.createMessage(ugnich.getUid(), "top message", null, null); IntStream.rangeClosed(6, 12).forEach(i -> { |