Search in sources :

Example 1 with UserRoleSecurityInfo

use of org.pentaho.platform.security.userroledao.ws.UserRoleSecurityInfo in project pentaho-kettle by pentaho.

the class UserRoleDelegateTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    when(roleWebService.getUserRoleSecurityInfo()).thenReturn(new UserRoleSecurityInfo());
    delegate = new UserRoleDelegate(log, roleListWebService, roleWebService);
    delegate.managed = true;
    delegate.updateUserRoleInfo();
}
Also used : UserRoleSecurityInfo(org.pentaho.platform.security.userroledao.ws.UserRoleSecurityInfo) Before(org.junit.Before)

Example 2 with UserRoleSecurityInfo

use of org.pentaho.platform.security.userroledao.ws.UserRoleSecurityInfo in project pentaho-kettle by pentaho.

the class UserRoleHelperTest method convertFromProxyPentahoUsers_ReturnsEmptyList_WhenUsersAreAbsent.

@Test
public void convertFromProxyPentahoUsers_ReturnsEmptyList_WhenUsersAreAbsent() throws Exception {
    UserRoleSecurityInfo info = new UserRoleSecurityInfo();
    info.setUsers(null);
    IRoleSupportSecurityManager manager = mockSecurityManager(false);
    List<IUser> users = convertFromProxyPentahoUsers(info, manager);
    assertNotNull(users);
    assertTrue(users.isEmpty());
}
Also used : IRoleSupportSecurityManager(org.pentaho.di.ui.repository.pur.services.IRoleSupportSecurityManager) UserRoleSecurityInfo(org.pentaho.platform.security.userroledao.ws.UserRoleSecurityInfo) IUser(org.pentaho.di.repository.IUser) Test(org.junit.Test)

Example 3 with UserRoleSecurityInfo

use of org.pentaho.platform.security.userroledao.ws.UserRoleSecurityInfo in project pentaho-platform by pentaho.

the class UserRoleWebServiceBase method testGetUserRoleSecurityInfo.

@Test
public void testGetUserRoleSecurityInfo() throws Exception {
    IUserRoleWebService service = getUserRoleWebService();
    mockUserAsAdmin(false);
    try {
        service.getUserRoleSecurityInfo();
        Assert.fail();
    } catch (UserRoleException e) {
        // should this be 0001, not admin?
        Assert.assertTrue(e.getMessage().indexOf("ERROR_0001") >= 0);
    }
    mockUserAsAdmin(true);
    UserRoleSecurityInfo info = service.getUserRoleSecurityInfo();
    Assert.assertNotNull(info);
    Assert.assertEquals(2, info.getRoles().size());
    Assert.assertEquals(2, info.getUsers().size());
    Assert.assertEquals(2, info.getAssignments().size());
}
Also used : UserRoleSecurityInfo(org.pentaho.platform.security.userroledao.ws.UserRoleSecurityInfo) IUserRoleWebService(org.pentaho.platform.security.userroledao.ws.IUserRoleWebService) UserRoleException(org.pentaho.platform.security.userroledao.ws.UserRoleException) Test(org.junit.Test)

Example 4 with UserRoleSecurityInfo

use of org.pentaho.platform.security.userroledao.ws.UserRoleSecurityInfo in project pentaho-kettle by pentaho.

the class UserRoleHelperTest method convertFromProxyPentahoUsers_CopiesEachUser.

@Test
public void convertFromProxyPentahoUsers_CopiesEachUser() throws Exception {
    UserRoleSecurityInfo info = new UserRoleSecurityInfo();
    info.setUsers(Arrays.asList(pentahoUser("user1"), pentahoUser("user2")));
    IRoleSupportSecurityManager manager = mockSecurityManager(false);
    List<IUser> users = convertFromProxyPentahoUsers(info, manager);
    assertNotNull(users);
    assertEquals(2, users.size());
    assertEquals("user1", users.get(0).getName());
    assertEquals("user2", users.get(1).getName());
}
Also used : IRoleSupportSecurityManager(org.pentaho.di.ui.repository.pur.services.IRoleSupportSecurityManager) UserRoleSecurityInfo(org.pentaho.platform.security.userroledao.ws.UserRoleSecurityInfo) IUser(org.pentaho.di.repository.IUser) Test(org.junit.Test)

Example 5 with UserRoleSecurityInfo

use of org.pentaho.platform.security.userroledao.ws.UserRoleSecurityInfo in project pentaho-platform by pentaho.

the class UserRoleEndpointIT method main.

public static void main(String[] args) throws Exception {
    // test against a live server, dev use only
    System.setProperty("com.sun.xml.ws.monitoring.endpoint", "true");
    System.setProperty("com.sun.xml.ws.monitoring.client", "true");
    System.setProperty("com.sun.xml.ws.monitoring.registrationDebug", "FINE");
    System.setProperty("com.sun.xml.ws.monitoring.runtimeDebug", "true");
    Service service = Service.create(new URL("http://localhost:8080/pentaho/webservices/userRoleService?wsdl"), new QName("http://www.pentaho.org/ws/1.0", "userRoleService"));
    IUserRoleWebService userRoleWebService = service.getPort(IUserRoleWebService.class);
    ((BindingProvider) userRoleWebService).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "admin");
    ((BindingProvider) userRoleWebService).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "password");
    // accept cookies to maintain session on server
    ((BindingProvider) userRoleWebService).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
    UserRoleSecurityInfo info = userRoleWebService.getUserRoleSecurityInfo();
    // should be Authenticated
    System.out.println(info.getDefaultRoles().get(0));
}
Also used : UserRoleSecurityInfo(org.pentaho.platform.security.userroledao.ws.UserRoleSecurityInfo) QName(javax.xml.namespace.QName) UserRoleWebService(org.pentaho.platform.security.userroledao.ws.UserRoleWebService) Service(javax.xml.ws.Service) IUserRoleWebService(org.pentaho.platform.security.userroledao.ws.IUserRoleWebService) IUserRoleWebService(org.pentaho.platform.security.userroledao.ws.IUserRoleWebService) URL(java.net.URL)

Aggregations

UserRoleSecurityInfo (org.pentaho.platform.security.userroledao.ws.UserRoleSecurityInfo)5 Test (org.junit.Test)3 IUser (org.pentaho.di.repository.IUser)2 IRoleSupportSecurityManager (org.pentaho.di.ui.repository.pur.services.IRoleSupportSecurityManager)2 IUserRoleWebService (org.pentaho.platform.security.userroledao.ws.IUserRoleWebService)2 URL (java.net.URL)1 QName (javax.xml.namespace.QName)1 Service (javax.xml.ws.Service)1 Before (org.junit.Before)1 UserRoleException (org.pentaho.platform.security.userroledao.ws.UserRoleException)1 UserRoleWebService (org.pentaho.platform.security.userroledao.ws.UserRoleWebService)1