From ca94f0b8951a3520f219dceb68e67fe8e9886c07 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 8 Dec 2022 15:57:30 +0300 Subject: Redirect thread URL to ActivityPub version if Accept header matches --- .../java/com/juick/server/tests/ServerTests.java | 35 ++++++++++++++-------- 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'src/test') diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index 1e956855..d80c9251 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -2331,18 +2331,19 @@ public class ServerTests { } @Test - public void verifiedUsersTest() { - assertThat(userService.getUserByName("ugnich").isVerified(), is(false)); - jdbcTemplate.update("INSERT INTO telegram(user_id, tg_id) VALUES(?, ?)", ugnich.getUid(), "100001866137681"); - assertThat(userService.canDeleteTelegramUser(userService.getUserByName("ugnich")), is(false)); - userService.addFacebookState("12345", "http://localhost"); - userService.createFacebookUser(12345, "12345", "5678", "ugnich"); - userService.setFacebookUser("12345", ugnich.getUid()); - assertThat(userService.getUserByName("ugnich").isVerified(), is(true)); - assertThat(userService.canDeleteTelegramUser(userService.getUserByName("ugnich")), is(true)); - jdbcTemplate.update("DELETE FROM facebook"); - assertThat(userService.canDeleteTelegramUser(userService.getUserByName("ugnich")), is(false)); - } + public void verifiedUsersTest() { + assertThat(userService.getUserByName("ugnich").isVerified(), is(false)); + jdbcTemplate.update("INSERT INTO telegram(user_id, tg_id) VALUES(?, ?)", ugnich.getUid(), + "100001866137681"); + assertThat(userService.canDeleteTelegramUser(userService.getUserByName("ugnich")), is(false)); + userService.addFacebookState("12345", "http://localhost"); + userService.createFacebookUser(12345, "12345", "5678", "ugnich"); + userService.setFacebookUser("12345", ugnich.getUid()); + assertThat(userService.getUserByName("ugnich").isVerified(), is(true)); + assertThat(userService.canDeleteTelegramUser(userService.getUserByName("ugnich")), is(true)); + jdbcTemplate.update("DELETE FROM facebook"); + assertThat(userService.canDeleteTelegramUser(userService.getUserByName("ugnich")), is(false)); + } @Test @Disabled("FIXME: profile changed as expected, but cache is not refreshed or something") @@ -2733,4 +2734,14 @@ public class ServerTests { .andExpect(jsonPath("$.pms", empty())); } + + @Test + public void ldRequestToThreadShouldRedirect() throws Exception { + var result = commandsManager.processCommand(ugnich, "test", emptyUri); + var mid = result.getNewMessage().get().getMid(); + var htmlUri = String.format("/ugnich/%d", mid); + var ldUri = String.format("/n/%d-0", mid); + mockMvc.perform(get(htmlUri).accept(Context.LD_JSON_MEDIA_TYPE)).andExpect(status().is3xxRedirection()) + .andExpect(redirectedUrl(ldUri)); + } } -- cgit v1.2.3