Search in sources :

Example 56 with UserDetails

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"));
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) ResultActions(org.springframework.test.web.servlet.ResultActions) Test(org.junit.Test) AbstractControllerIntegrationTest(org.entando.entando.web.AbstractControllerIntegrationTest)

Example 57 with UserDetails

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());
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) Test(org.junit.Test) AbstractControllerIntegrationTest(org.entando.entando.web.AbstractControllerIntegrationTest)

Example 58 with UserDetails

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);
    }
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) Category(com.agiletec.aps.system.services.category.Category) Test(org.junit.Test) AbstractControllerIntegrationTest(org.entando.entando.web.AbstractControllerIntegrationTest)

Example 59 with UserDetails

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());
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) ResultActions(org.springframework.test.web.servlet.ResultActions) AbstractControllerTest(org.entando.entando.web.AbstractControllerTest) Test(org.junit.Test)

Example 60 with UserDetails

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());
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) ResultActions(org.springframework.test.web.servlet.ResultActions) Test(org.junit.Test) AbstractControllerIntegrationTest(org.entando.entando.web.AbstractControllerIntegrationTest)

Aggregations

UserDetails (com.agiletec.aps.system.services.user.UserDetails)271 Test (org.junit.Test)150 ResultActions (org.springframework.test.web.servlet.ResultActions)142 AbstractControllerIntegrationTest (org.entando.entando.web.AbstractControllerIntegrationTest)77 AbstractControllerTest (org.entando.entando.web.AbstractControllerTest)71 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)25 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)22 Group (com.agiletec.aps.system.services.group.Group)15 ArrayList (java.util.ArrayList)15 IAuthorizationManager (com.agiletec.aps.system.services.authorization.IAuthorizationManager)14 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)13 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)12 HttpSession (javax.servlet.http.HttpSession)12 RestListRequest (org.entando.entando.web.common.model.RestListRequest)12 HashMap (java.util.HashMap)9 StringApiResponse (org.entando.entando.aps.system.services.api.model.StringApiResponse)9 DataObject (org.entando.entando.aps.system.services.dataobject.model.DataObject)9 IPage (com.agiletec.aps.system.services.page.IPage)8 JspException (javax.servlet.jsp.JspException)8 Page (com.agiletec.aps.system.services.page.Page)7