use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class CategoryControllerIntegrationTest method testGetCategories.
@Test
public void testGetCategories() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
ResultActions result = mockMvc.perform(get("/categories").header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isOk());
System.out.println(result.andReturn().getResponse().getContentAsString());
result.andExpect(header().string("Access-Control-Allow-Origin", "*"));
result.andExpect(header().string("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS"));
result.andExpect(header().string("Access-Control-Allow-Headers", "Content-Type, Authorization"));
result.andExpect(header().string("Access-Control-Max-Age", "3600"));
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class CategoryControllerIntegrationTest method testGetValidCategory.
@Test
public void testGetValidCategory() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
this.executeGet("cat1", accessToken, status().isOk());
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class CategoryControllerIntegrationTest method testUpdateCategory.
@Test
public void testUpdateCategory() throws Exception {
String categoryCode = "test_cat2";
try {
Assert.assertNotNull(this.categoryManager.getCategory("cat1"));
Assert.assertNull(this.categoryManager.getCategory(categoryCode));
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
this.executePost("2_POST_valid.json", accessToken, status().isOk());
this.executePut("2_PUT_invalid_1.json", categoryCode, accessToken, status().isBadRequest());
this.executePut("2_PUT_invalid_2.json", categoryCode, accessToken, status().isBadRequest());
this.executePut("2_PUT_valid.json", "home", accessToken, status().isBadRequest());
this.executePut("2_PUT_valid.json", categoryCode, accessToken, status().isOk());
Category modified = this.categoryManager.getCategory(categoryCode);
Assert.assertNotNull(modified);
Assert.assertTrue(modified.getTitle("en").startsWith("New "));
Assert.assertTrue(modified.getTitle("it").startsWith("Nuovo "));
this.executeDelete(categoryCode, accessToken, status().isOk());
Assert.assertNull(this.categoryManager.getCategory(categoryCode));
} finally {
this.categoryManager.deleteCategory(categoryCode);
}
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class CategoryControllerTest method testGetTreeOk.
@Test
public void testGetTreeOk() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
ResultActions result = mockMvc.perform(get("/categories").param("parentCode", "home").header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isOk());
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class DatabaseControllerIntegrationTest method testReports_1.
@Test
public void testReports_1() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
ResultActions result = mockMvc.perform(get("/database").param("page", "1").header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isOk());
}
Aggregations