aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/com
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2024-02-09 17:29:29 +0300
committerGravatar Vitaly Takmazov2024-02-09 17:45:18 +0300
commite2674c3b27174e408264b84f50bf86a13e2d3824 (patch)
tree9f049f499d57780878034336ae7f2a19cd203b68 /src/test/java/com
parentab87188de28ae266aebf03fb429880cf293c6ee9 (diff)
Use fetch credentials instead of hash parameter for authenticated requests
Diffstat (limited to 'src/test/java/com')
-rw-r--r--src/test/java/com/juick/server/tests/ServerTests.java12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java
index e74e8c6f..0724eb4f 100644
--- a/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/src/test/java/com/juick/server/tests/ServerTests.java
@@ -1754,8 +1754,7 @@ public class ServerTests {
public void hashLoginShouldNotUseSession() throws Exception {
String hash = userService.getHashByUID(ugnich.getUid());
MvcResult hashLoginResult = mockMvc.perform(get("/?show=my&hash=" + hash)).andExpect(status().isOk())
- .andExpect(model().attribute("visitor", hasProperty("authHash", equalTo(hash))))
- .andExpect(content().string(containsString(hash))).andReturn();
+ .andExpect(model().attribute("visitor", hasProperty("authHash", equalTo(hash)))).andReturn();
Cookie rememberMeFromHash = hashLoginResult.getResponse().getCookie("juick-remember-me");
MvcResult formLoginResult = mockMvc
.perform(post("/login").with(csrf()).param("username", ugnichName).param("password",
@@ -1763,19 +1762,16 @@ public class ServerTests {
.andExpect(status().is3xxRedirection()).andReturn();
Cookie rememberMeFromForm = formLoginResult.getResponse().getCookie("juick-remember-me");
mockMvc.perform(get("/?show=my").cookie(rememberMeFromForm)).andExpect(status().isOk())
- .andExpect(model().attribute("visitor", hasProperty("authHash", equalTo(hash))))
- .andExpect(content().string(containsString(hash)));
+ .andExpect(model().attribute("visitor", hasProperty("authHash", equalTo(hash))));
mockMvc.perform(get("/?show=my").cookie(rememberMeFromHash)).andExpect(status().isOk())
- .andExpect(model().attribute("visitor", hasProperty("authHash", equalTo(hash))))
- .andExpect(content().string(containsString(hash)));
+ .andExpect(model().attribute("visitor", hasProperty("authHash", equalTo(hash))));
}
@Test
public void apiRequestsShouldAuthorizeWithCookie() throws Exception {
String hash = userService.getHashByUID(ugnich.getUid());
MvcResult hashLoginResult = mockMvc.perform(get("/?show=my&hash=" + hash)).andExpect(status().isOk())
- .andExpect(model().attribute("visitor", hasProperty("authHash", equalTo(hash))))
- .andExpect(content().string(containsString(hash))).andReturn();
+ .andExpect(model().attribute("visitor", hasProperty("authHash", equalTo(hash)))).andReturn();
Cookie rememberMeFromHash = hashLoginResult.getResponse().getCookie("juick-remember-me");
mockMvc.perform(get("/api/me").cookie(rememberMeFromHash))
.andExpect(status().isOk());