use of org.springframework.test.web.servlet.ResultActions in project entando-core by entando.
the class WidgetControllerIntegrationTest method testGetWidget_1.
@Test
public void testGetWidget_1() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").withAuthorization(Group.FREE_GROUP_NAME, "managePages", Permission.MANAGE_PAGES).build();
String accessToken = mockOAuthInterceptor(user);
// @formatter:off
ResultActions result = this.executeWidgetGet("1", accessToken, status().isNotFound());
String response = result.andReturn().getResponse().getContentAsString();
assertNotNull(response);
}
use of org.springframework.test.web.servlet.ResultActions in project entando-core by entando.
the class WidgetControllerIntegrationTest method testGetWidgetInfo.
@Test
public void testGetWidgetInfo() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
// @formatter:off
ResultActions result = mockMvc.perform(get("/widgets/login_form/info").header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken));
String response = result.andReturn().getResponse().getContentAsString();
assertNotNull(response);
result.andExpect(jsonPath("$.payload.publishedUtilizers", Matchers.hasSize(2)));
}
use of org.springframework.test.web.servlet.ResultActions in project entando-core by entando.
the class WidgetControllerIntegrationTest method testUpdateStockLocked.
@Test
public void testUpdateStockLocked() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
String code = "login_form";
WidgetType widgetType = this.widgetTypeManager.getWidgetType(code);
WidgetRequest request = new WidgetRequest();
request.setCode(code);
request.setGroup(Group.FREE_GROUP_NAME);
request.setTitles((Map) widgetType.getTitles());
ResultActions result = this.executeWidgetPut(request, code, accessToken, status().isOk());
result.andExpect(jsonPath("$.payload.code", is("login_form")));
}
use of org.springframework.test.web.servlet.ResultActions in project entando-core by entando.
the class WidgetControllerIntegrationTest method testDeleteWidgetLocked.
@Test
public void testDeleteWidgetLocked() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
String code = "login_form";
ResultActions result = this.executeWidgetDelete(code, accessToken, status().isBadRequest());
result.andExpect(jsonPath("$.errors[0].code", is(WidgetValidator.ERRCODE_OPERATION_FORBIDDEN_LOCKED)));
}
use of org.springframework.test.web.servlet.ResultActions in project entando-core by entando.
the class WidgetControllerIntegrationTest method testGetWidgetsWithAdminPermission.
@Test
public void testGetWidgetsWithAdminPermission() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
ResultActions result = mockMvc.perform(get("/widgets").header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken));
result.andExpect(status().isOk());
}
Aggregations