Added missing tests
This commit is contained in:
@ -6,6 +6,8 @@ import static org.springframework.security.test.web.servlet.setup.SecurityMockMv
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import com.plannaplan.services.UserService;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@ -29,6 +31,9 @@ public class ConfigControllerTest {
|
||||
@Autowired
|
||||
private WebApplicationContext webApplicationContext;
|
||||
|
||||
@Autowired
|
||||
private UserService service;
|
||||
|
||||
@Test
|
||||
public void shouldReturnOK() throws Exception {
|
||||
final InputStream inputStream = getClass().getClassLoader().getResourceAsStream(FILE_NAME);
|
||||
@ -48,4 +53,17 @@ public class ConfigControllerTest {
|
||||
mockMvc.perform(multipart(CONFIG_ENDPOINT).file(file)).andExpect(status().is4xxClientError());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturnOKAuthorized() throws Exception {
|
||||
final InputStream inputStream = getClass().getClassLoader().getResourceAsStream(FILE_NAME);
|
||||
final MockMultipartFile file = new MockMultipartFile("file", inputStream);
|
||||
final String token = this.service.login("notexisting@mail.comain");
|
||||
|
||||
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build();
|
||||
mockMvc.perform(multipart(CONFIG_ENDPOINT).file(file).header("Bearer ", token))
|
||||
.andExpect(status().is4xxClientError());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user