aboutsummaryrefslogtreecommitdiff
path: root/juick-api/src/test/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'juick-api/src/test/java/com')
-rw-r--r--juick-api/src/test/java/com/juick/api/tests/MessagesTests.java30
1 files changed, 15 insertions, 15 deletions
diff --git a/juick-api/src/test/java/com/juick/api/tests/MessagesTests.java b/juick-api/src/test/java/com/juick/api/tests/MessagesTests.java
index e0f9b840..9f74c00d 100644
--- a/juick-api/src/test/java/com/juick/api/tests/MessagesTests.java
+++ b/juick-api/src/test/java/com/juick/api/tests/MessagesTests.java
@@ -38,6 +38,7 @@ import static org.mockito.Mockito.when;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.options;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
/**
@@ -173,12 +174,10 @@ public class MessagesTests {
@Test
public void homeTestWithMessagesAndRememberMe() throws Exception {
- String ugnichName = "ugnich";
- String uginchPassword = "MyPassw0rd!";
String msgText = "Привет, я - Угнич";
String hash = "12345678";
- User user = getUser(1, ugnichName, uginchPassword);
+ User user = getUser(1, ugnichName, ugnichPassword);
Message msg = getMessage(user, msgText);
when(userService.getUIDbyName(ugnichName))
@@ -198,7 +197,7 @@ public class MessagesTests {
mockMvc.perform(
get("/home")
- .with(httpBasic(ugnichName, uginchPassword)))
+ .with(httpBasic(ugnichName, ugnichPassword)))
.andExpect(status().isOk())
.andReturn();
@@ -211,11 +210,8 @@ public class MessagesTests {
}
@Test
- public void homeTestWithMEssagesAndSimpleCors() throws Exception {
- String ugnichName = "ugnich";
- String uginchPassword = "MyPassw0rd!";
-
- User user = getUser(1, ugnichName, uginchPassword);
+ public void homeTestWithMessagesAndSimpleCors() throws Exception {
+ User user = getUser(1, ugnichName, ugnichPassword);
Message msg = getMessage(user, null);
when(userService.getFullyUserByName(ugnichName))
@@ -229,7 +225,7 @@ public class MessagesTests {
mockMvc.perform(
get("/home")
- .with(httpBasic(ugnichName, uginchPassword))
+ .with(httpBasic(ugnichName, ugnichPassword))
.header("Origin", "http://api.example.net"))
.andExpect(status().isOk())
.andExpect(header().string("Access-Control-Allow-Origin", "*"));
@@ -237,16 +233,13 @@ public class MessagesTests {
@Test
public void homeTestWithPreflightCors() throws Exception {
- String ugnichName = "ugnich";
- String uginchPassword = "MyPassw0rd!";
-
- User user = getUser(1, ugnichName, uginchPassword);
+ User user = getUser(1, ugnichName, ugnichPassword);
when(userService.getFullyUserByName(ugnichName))
.thenReturn(user);
mockMvc.perform(
options("/home")
- .with(httpBasic(ugnichName, uginchPassword))
+ .with(httpBasic(ugnichName, ugnichPassword))
.header("Origin", "http://api.example.net")
.header("Access-Control-Request-Method", "POST")
.header("Access-Control-Request-Headers", "X-PINGOTHER, Content-Type"))
@@ -291,4 +284,11 @@ public class MessagesTests {
.andExpect(jsonPath("$", hasSize(1)))
.andExpect(jsonPath("$[0].messages", is(5)));
}
+ @Test
+ public void postWithReferer() throws Exception {
+ mockMvc.perform(post("/post")
+ .param("body", "yo")
+ .with(httpBasic(ugnichName, ugnichPassword)))
+ .andExpect(status().isOk());
+ }
}