From eb665ea6edc2aaff9f9a562c875b38b4878e2709 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 19 Jan 2023 21:57:50 +0300 Subject: ActivityPub: blog redirect --- src/test/java/com/juick/server/tests/ServerTests.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/test/java/com/juick/server/tests') diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index 5d149277..bb70e875 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -2527,6 +2527,23 @@ public class ServerTests { mockMvc.perform(get(ldUri)).andExpect(status().isOk()); } + @Test + public void ldRequestToBlogShouldRedirect() throws Exception { + var htmlUri = String.format("/ugnich/"); + var ldUri = String.format("/u/ugnich"); + mockMvc.perform(get(htmlUri).accept(Context.LD_JSON_MEDIA_TYPE)).andExpect(status().is3xxRedirection()) + .andExpect(redirectedUrl(ldUri)); + mockMvc.perform(get(htmlUri).accept(MediaType.APPLICATION_JSON)).andExpect(status().is3xxRedirection()) + .andExpect(redirectedUrl(ldUri)); + var mastodonAcceptHeader = "application/activity+json, application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\", text/html;q=0.1"; + mockMvc.perform(get(htmlUri).accept(mastodonAcceptHeader)).andExpect(status().is3xxRedirection()) + .andExpect(redirectedUrl(ldUri)); + var webclientHeader = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"; + mockMvc.perform(get(htmlUri).accept(webclientHeader)).andExpect(status().isOk()); + mockMvc.perform(get(htmlUri)).andExpect(status().isOk()); + mockMvc.perform(get(ldUri)).andExpect(status().isOk()); + } + @Test @Transactional public void unsignedOverlowTest() throws Exception { -- cgit v1.2.3