use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class GroupControllerIntegrationTest method testGetGroupDetails.
@Test
public void testGetGroupDetails() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
ResultActions result = mockMvc.perform(get("/groups/{code}", Group.FREE_GROUP_NAME).contentType(MediaType.APPLICATION_JSON_VALUE).header("Authorization", "Bearer " + accessToken));
System.out.println(result.andReturn().getResponse().getContentAsString());
result.andExpect(status().isOk());
result.andExpect(jsonPath("$.payload.references.length()", is(6)));
String[] managers = "PageManager,DataObjectManager,WidgetTypeManager,jacmsResourceManager,AuthorizationManager,jacmsContentManager".split(",");
for (String managerName : managers) {
result = mockMvc.perform(get("/groups/{code}/references/{manager}", Group.FREE_GROUP_NAME, managerName).param("page", "1").param("pageSize", "3").contentType(MediaType.APPLICATION_JSON_VALUE).header("Authorization", "Bearer " + accessToken));
}
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class GroupControllerUnitTest method testSeachGroups.
@Test
public void testSeachGroups() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
when(groupService.getGroups(any(RestListRequest.class))).thenReturn(new PagedMetadata<GroupDto>());
ResultActions result = mockMvc.perform(get("/groups").param("page", "1").param("pageSize", "4").header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isOk());
RestListRequest restListReq = new RestListRequest();
restListReq.setPage(1);
restListReq.setPageSize(4);
Mockito.verify(groupService, Mockito.times(1)).getGroups(restListReq);
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class GroupControllerUnitTest method testSearchGroupsWithFilters.
@Test
public void testSearchGroupsWithFilters() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
when(groupService.getGroups(any(RestListRequest.class))).thenReturn(new PagedMetadata<GroupDto>());
ResultActions result = mockMvc.perform(get("/groups").param("page", "1").param("pageSize", "4").param("filter[0].attribute", "code").param("filter[0].value", "free").header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isOk());
RestListRequest restListReq = new RestListRequest();
restListReq.setPage(1);
restListReq.setPageSize(4);
restListReq.addFilter(new Filter("code", "free"));
Mockito.verify(groupService, Mockito.times(1)).getGroups(restListReq);
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class GroupControllerUnitTest method testParamSize.
@Test
public void testParamSize() throws ApsSystemException, Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
GroupRequest groupRequest = new GroupRequest();
groupRequest.setCode(StringUtils.repeat("a", 21));
groupRequest.setName(StringUtils.repeat("a", 51));
ObjectMapper mapper = new ObjectMapper();
String payload = mapper.writeValueAsString(groupRequest);
this.controller.setGroupValidator(new GroupValidator());
ResultActions result = mockMvc.perform(post("/groups").content(payload).contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + accessToken));
// System.out.println(result.andReturn().getResponse().getContentAsString());
result.andExpect(status().isBadRequest());
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class GuiFragmentControllerTest method should_be_unauthorized.
@Test
public void should_be_unauthorized() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").withGroup(Group.FREE_GROUP_NAME).build();
String accessToken = mockOAuthInterceptor(user);
ResultActions result = mockMvc.perform(get("/fragments").header("Authorization", "Bearer " + accessToken));
String response = result.andReturn().getResponse().getContentAsString();
System.out.println(response);
result.andExpect(status().isUnauthorized());
}
Aggregations