@ -45,12 +45,11 @@ public class ConfigControllerTest extends AbstractControllerTest {
|
||||
@Test
|
||||
public void shouldReturnOKAuthorized() throws Exception {
|
||||
final String mail = "shouldReturnOKAuthorized@ConfigController.test";
|
||||
final User usr = new User(null, null, mail, UserRoles.ADMIN);
|
||||
this.service.save(usr);
|
||||
final User usr = this.service.save(new User(null, null, mail, UserRoles.ADMIN));
|
||||
|
||||
final InputStream inputStream = getClass().getClassLoader().getResourceAsStream(FILE_NAME);
|
||||
final MockMultipartFile file = new MockMultipartFile("file", inputStream);
|
||||
final String token = this.service.login(mail);
|
||||
final String token = this.service.login(usr);
|
||||
|
||||
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build();
|
||||
mockMvc.perform(multipart(CONFIG_ENDPOINT).file(file).header("Authorization", "Bearer " + token))
|
||||
@ -61,12 +60,11 @@ public class ConfigControllerTest extends AbstractControllerTest {
|
||||
@Test
|
||||
public void shouldReturnDenyNoAdminAuthorized() throws Exception {
|
||||
final String mail = "shouldReturnDenyNoAdminAuthorized@ConfigController.test";
|
||||
final User usr = new User(null, null, mail, UserRoles.TEST_USER);
|
||||
this.service.save(usr);
|
||||
final User usr = this.service.save(new User(null, null, mail, UserRoles.TEST_USER));
|
||||
|
||||
final InputStream inputStream = getClass().getClassLoader().getResourceAsStream(FILE_NAME);
|
||||
final MockMultipartFile file = new MockMultipartFile("file", inputStream);
|
||||
final String token = this.service.login(mail);
|
||||
final String token = this.service.login(usr);
|
||||
|
||||
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build();
|
||||
mockMvc.perform(multipart(CONFIG_ENDPOINT).file(file).header("Authorization", "Bearer " + token))
|
||||
|
Reference in New Issue
Block a user