diff options
author | Vitaly Takmazov | 2023-01-08 16:52:52 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-08 16:52:52 +0300 |
commit | 8abdac5ade33c71125eb3f7409cb6dafe8aff278 (patch) | |
tree | 0a3c758785cdfc1bac8ca57edec06a7a09506a77 /src/test/java | |
parent | 60bb2e97a7b9a883d40b1b48c280bfd48dd283e2 (diff) |
Fix ActivityPub redirects
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/com/juick/server/tests/ServerTests.java | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index eff78c1d..80627275 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -46,7 +46,6 @@ import com.juick.www.WebApp; import com.juick.www.ad.models.Site; import com.juick.www.api.SystemActivity; import com.juick.www.api.Users; -import com.juick.www.api.activity.Profile; import com.juick.www.api.activity.helpers.ProfileUriBuilder; import com.juick.www.api.activity.model.Context; import com.juick.www.api.activity.model.activities.*; @@ -64,7 +63,6 @@ import io.pebbletemplates.pebble.PebbleEngine; import io.pebbletemplates.pebble.error.PebbleException; import io.pebbletemplates.pebble.template.PebbleTemplate; import jakarta.servlet.http.Cookie; -import jakarta.servlet.http.HttpServletRequest; import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.JAXBException; import jakarta.xml.bind.Marshaller; @@ -92,8 +90,6 @@ import org.springframework.core.io.Resource; import org.springframework.http.*; import org.springframework.http.client.ClientHttpRequestFactory; import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.mock.http.client.MockClientHttpRequest; -import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpSession; import org.springframework.mock.web.MockMultipartFile; import org.springframework.test.context.TestPropertySource; @@ -1651,7 +1647,8 @@ public class ServerTests { @Test public void accountUrlShouldBeExposedOverWebfinger() throws Exception { - mockMvc.perform(get("/.well-known/webfinger?resource=acct:ugnich@localhost")).andExpect(status().isOk()) + mockMvc.perform(get("/.well-known/webfinger?resource=acct:ugnich@localhost") + .accept("application/jrd+json")).andExpect(status().isOk()) .andExpect(jsonPath("$.subject", is("acct:ugnich@localhost"))) .andExpect(jsonPath("$.links", hasSize(1))) .andExpect(jsonPath("$.links[0].href", is("http://localhost:8080/u/ugnich"))); @@ -2097,7 +2094,8 @@ public class ServerTests { String signatureString = signatureService.addSignature(ugnichPerson, testHost, "GET", meUri, requestDate, StringUtils.EMPTY); - MvcResult me = mockMvc.perform(get("/api/me").header("Host", testHost).header("Date", requestDate) + MvcResult me = mockMvc.perform(get("/api/me") + .header("Host", testHost).header("Date", requestDate) .header( "Signature", signatureString)).andExpect(status().isOk()).andReturn(); User meUser = jsonMapper.readValue(me.getResponse().getContentAsString(), User.class); assertThat(meUser, is(ugnich)); @@ -2651,7 +2649,7 @@ public class ServerTests { @Test public void invalidMediaTypeTest() throws Exception { - mockMvc.perform(get("/api/messages") + mockMvc.perform(get("/api/messages/discussions") .header("Accept", "application/xml")).andExpect(status().isBadRequest()) .andExpect(content().string("Invalid media type")); } @@ -2683,6 +2681,13 @@ public class ServerTests { .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 |