Search in sources :

Example 1 with IDataObjectManager

use of org.entando.entando.aps.system.services.dataobject.IDataObjectManager in project entando-core by entando.

the class TestDataObjectAuthorization method testCheckCustomerUser.

public void testCheckCustomerUser() throws Throwable {
    UserDetails extractedUser = this.getUser("pageManagerCustomers");
    assertNotNull(extractedUser);
    assertEquals("pageManagerCustomers", extractedUser.getUsername());
    assertEquals(1, extractedUser.getAuthorizations().size());
    IDataObjectManager contentManager = (IDataObjectManager) this.getService("DataObjectManager");
    DataObject content = contentManager.loadDataObject("ART111", true);
    boolean checkContent = this._authorizationManager.isAuth(extractedUser, content);
    assertTrue(checkContent);
    content = contentManager.loadDataObject("EVN25", true);
    checkContent = this._authorizationManager.isAuth(extractedUser, content);
    assertTrue(checkContent);
    content = contentManager.loadDataObject("EVN41", true);
    checkContent = this._authorizationManager.isAuth(extractedUser, content);
    assertFalse(checkContent);
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) IDataObjectManager(org.entando.entando.aps.system.services.dataobject.IDataObjectManager)

Example 2 with IDataObjectManager

use of org.entando.entando.aps.system.services.dataobject.IDataObjectManager in project entando-core by entando.

the class TestDataObjectAuthorization method testCheckAdminUser.

public void testCheckAdminUser() throws Throwable {
    UserDetails adminUser = this.getUser("admin");
    assertNotNull(adminUser);
    assertEquals("admin", adminUser.getUsername());
    assertEquals(1, adminUser.getAuthorizations().size());
    IDataObjectManager contentManager = (IDataObjectManager) this.getService("DataObjectManager");
    DataObject content = contentManager.loadDataObject("ART111", true);
    boolean check = this._authorizationManager.isAuth(adminUser, content);
    assertTrue(check);
    content = contentManager.loadDataObject("EVN25", true);
    check = this._authorizationManager.isAuth(adminUser, content);
    assertTrue(check);
    content = contentManager.loadDataObject("EVN41", true);
    check = this._authorizationManager.isAuth(adminUser, content);
    assertTrue(check);
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) IDataObjectManager(org.entando.entando.aps.system.services.dataobject.IDataObjectManager)

Example 3 with IDataObjectManager

use of org.entando.entando.aps.system.services.dataobject.IDataObjectManager in project entando-core by entando.

the class TestDataObjectAuthorization method testCheckNewUser.

/*
     * This test is fully inherited from the original TestAuthorizationManager in jAPS2 (2.0.6)
     */
public void testCheckNewUser() throws Throwable {
    String username = "UserForTest";
    String password = "PasswordForTest";
    this.addUserForTest(username, password);
    UserDetails extractedUser = null;
    try {
        extractedUser = this.getUser(username, password);
        assertEquals(username, extractedUser.getUsername());
        assertNotNull(extractedUser);
        assertEquals(1, extractedUser.getAuthorizations().size());
        Group group = this._groupManager.getGroup("coach");
        boolean checkGroup = this._authorizationManager.isAuth(extractedUser, group);
        assertFalse(checkGroup);
        group = this._groupManager.getGroup(Group.FREE_GROUP_NAME);
        checkGroup = this._authorizationManager.isAuth(extractedUser, group);
        assertTrue(checkGroup);
        boolean checkPermission = this._authorizationManager.isAuthOnPermission(extractedUser, Permission.SUPERVISOR);
        assertFalse(checkPermission);
        checkPermission = this._authorizationManager.isAuthOnPermission(extractedUser, Permission.SUPERUSER);
        assertFalse(checkPermission);
        checkPermission = this._authorizationManager.isAuthOnPermission(extractedUser, Permission.BACKOFFICE);
        assertTrue(checkPermission);
        checkPermission = this._authorizationManager.isAuthOnPermission(extractedUser, "editContents");
        assertTrue(checkPermission);
        IDataObjectManager contentManager = (IDataObjectManager) this.getService("DataObjectManager");
        DataObject content = contentManager.loadDataObject("ART111", true);
        boolean checkContent = this._authorizationManager.isAuth(extractedUser, content);
        assertFalse(checkContent);
        content = contentManager.loadDataObject("EVN25", true);
        checkContent = this._authorizationManager.isAuth(extractedUser, content);
        assertTrue(checkContent);
        content = contentManager.loadDataObject("EVN41", true);
        checkContent = this._authorizationManager.isAuth(extractedUser, content);
        assertFalse(checkContent);
    } catch (Throwable t) {
        throw t;
    } finally {
        if (null != extractedUser) {
            this._userManager.removeUser(extractedUser);
        }
        extractedUser = this._userManager.getUser(username);
        assertNull(extractedUser);
    }
}
Also used : Group(com.agiletec.aps.system.services.group.Group) UserDetails(com.agiletec.aps.system.services.user.UserDetails) DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject) IDataObjectManager(org.entando.entando.aps.system.services.dataobject.IDataObjectManager)

Aggregations

UserDetails (com.agiletec.aps.system.services.user.UserDetails)3 IDataObjectManager (org.entando.entando.aps.system.services.dataobject.IDataObjectManager)3 DataObject (org.entando.entando.aps.system.services.dataobject.model.DataObject)3 Group (com.agiletec.aps.system.services.group.Group)1