use of org.pentaho.platform.api.engine.IUserRoleListService in project pentaho-platform by pentaho.
the class HttpWebService method getUsers.
/**
* Returns XML for list of users.
*/
protected Document getUsers() throws ServletException, IOException {
IUserRoleListService service = PentahoSystem.get(IUserRoleListService.class);
Element rootElement = new DefaultElement("users");
Document doc = DocumentHelper.createDocument(rootElement);
if (service != null) {
List users = service.getAllUsers();
for (Iterator usersIterator = users.iterator(); usersIterator.hasNext(); ) {
String username = usersIterator.next().toString();
if ((null != username) && (username.length() > 0)) {
rootElement.addElement("user").addCDATA(username);
}
}
}
return doc;
}
use of org.pentaho.platform.api.engine.IUserRoleListService in project pentaho-platform by pentaho.
the class SystemServiceTest method testGetUsers.
@Test
public void testGetUsers() throws Exception {
IUserRoleListService service = mock(IUserRoleListService.class);
PentahoSystem.registerObject(service);
doReturn(true).when(systemService).canAdminister();
assertNotNull(systemService.getUsers());
PentahoSystem.clearObjectFactory();
}
use of org.pentaho.platform.api.engine.IUserRoleListService in project pentaho-platform by pentaho.
the class UserRoleListServiceTest method testDoGetRoles.
@Test
public void testDoGetRoles() {
List<String> roles = new ArrayList<String>();
roles.add("ROLE1");
roles.add("ROLE2");
IUserRoleListService userRoleListService1 = mock(IUserRoleListService.class);
doReturn(userRoleListService1).when(userRoleListService).getUserRoleListService();
doReturn(roles).when(userRoleListService1).getAllRoles();
RoleListWrapper roleListWrapper = userRoleListService.getRoles();
verify(userRoleListService).getUserRoleListService();
verify(userRoleListService1).getAllRoles();
assertEquals(roles, roleListWrapper.getRoles());
}
use of org.pentaho.platform.api.engine.IUserRoleListService in project pentaho-platform by pentaho.
the class UserRoleListServiceTest method testGetPermissionRoles.
@Test
public void testGetPermissionRoles() {
List<String> roles = new ArrayList<String>();
roles.add("ROLE1");
roles.add("ROLE2");
roles.add("ADMIN_ROLE");
IUserRoleListService userRoleListService1 = mock(IUserRoleListService.class);
doReturn(userRoleListService1).when(userRoleListService).getUserRoleListService();
doReturn(roles).when(userRoleListService1).getAllRoles();
ArrayList<String> extraRoles = new ArrayList<String>();
extraRoles.add("EXTRA_ROLE1");
extraRoles.add("EXTRA_ROLE2");
userRoleListService.setExtraRoles(extraRoles);
RoleListWrapper roleWrapper = userRoleListService.getPermissionRoles("ADMIN_ROLE");
assertTrue(!roleWrapper.getRoles().contains("ADMIN_ROLE"));
assertTrue(roleWrapper.getRoles().size() == 4);
}
use of org.pentaho.platform.api.engine.IUserRoleListService in project data-access by pentaho.
the class DatasourceResourceIT method setUp.
@BeforeClass
public static void setUp() throws Exception {
// $NON-NLS-1$ //$NON-NLS-2$
System.setProperty("org.osjava.sj.root", "target/test-classes/solution1/system/simple-jndi");
mp = new MicroPlatform("target/test-classes/solution1");
IAuthorizationPolicy mockAuthorizationPolicy = mock(IAuthorizationPolicy.class);
when(mockAuthorizationPolicy.isAllowed(anyString())).thenReturn(true);
IUserRoleListService mockUserRoleListService = mock(IUserRoleListService.class);
IDataAccessPermissionHandler mockDataAccessPermHandler = mock(IDataAccessPermissionHandler.class);
when(mockDataAccessPermHandler.hasDataAccessPermission(any(IPentahoSession.class))).thenReturn(true);
mp.define(ISolutionEngine.class, SolutionEngine.class, IPentahoDefinableObjectFactory.Scope.GLOBAL);
mp.define(IUnifiedRepository.class, TestFileSystemBackedUnifiedRepository.class, IPentahoDefinableObjectFactory.Scope.GLOBAL);
mp.define(IMondrianCatalogService.class, MondrianCatalogHelper.class, IPentahoDefinableObjectFactory.Scope.GLOBAL);
mp.define("connection-SQL", SQLConnection.class);
mp.define("connection-MDX", MDXConnection.class);
mp.define("connection-MDXOlap4j", MDXOlap4jConnection.class);
mp.define(IDBDatasourceService.class, JndiDatasourceService.class, IPentahoDefinableObjectFactory.Scope.GLOBAL);
mp.define(MDXConnection.MDX_CONNECTION_MAPPER_KEY, MondrianOneToOneUserRoleListMapper.class, IPentahoDefinableObjectFactory.Scope.GLOBAL);
mp.define(IDatasourceMgmtService.class, MockDatasourceMgmtService.class);
mp.define(IClientRepositoryPathsStrategy.class, MockClientRepositoryPathsStrategy.class);
mp.define(ISecurityHelper.class, MockSecurityHelper.class);
mp.define(UserDetailsService.class, MockUserDetailService.class);
mp.define("singleTenantAdminUserName", "admin");
mp.defineInstance(IMetadataDomainRepository.class, createMetadataDomainRepository());
mp.defineInstance(IAuthorizationPolicy.class, mockAuthorizationPolicy);
mp.defineInstance(IPluginResourceLoader.class, new PluginResourceLoader() {
protected PluginClassLoader getOverrideClassloader() {
return new PluginClassLoader(new File(".", "target/test-classes/solution1/system/simple-jndi"), this);
}
});
mp.defineInstance(IUserRoleListService.class, mockUserRoleListService);
mp.defineInstance(IDataAccessPermissionHandler.class, mockDataAccessPermHandler);
mp.setSettingsProvider(new SystemSettings());
mp.start();
PentahoSessionHolder.setStrategyName(PentahoSessionHolder.MODE_GLOBAL);
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_GLOBAL);
}
Aggregations