aboutsummaryrefslogtreecommitdiff
path: root/juick-api/src/test
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-12-09 16:14:27 +0300
committerGravatar Vitaly Takmazov2016-12-09 16:14:27 +0300
commit559ae343aa72db04e12b94acfa0bec30ed9a11f1 (patch)
tree5832b97c6a6a4b565de15a474bae86059763d6bb /juick-api/src/test
parent22d30c3b50fe0ea4c18c45a4450fb1a8b1f1b1b8 (diff)
juick-spring-www: merge some work from develop branch, port some templates to Thymeleaf
Diffstat (limited to 'juick-api/src/test')
-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());
+ }
}