use of org.pentaho.di.repository.UserInfo in project pentaho-kettle by pentaho.
the class UISecurityRoleTest method testEditRole.
@Test
public void testEditRole() throws Exception {
try {
UISecurityRole role = new UISecurityRole();
List<IUIUser> rusers = new ArrayList<IUIUser>();
for (UserInfo userInfo : users) {
rusers.add(new UIEERepositoryUser(userInfo));
}
role.setRole(new UIRepositoryRole(adminRole), rusers);
role.setMode(Mode.EDIT);
role.setDescription("new description");
List<Object> usersToAssign = new ArrayList<Object>();
usersToAssign.add(new UIRepositoryUser(suzyUser));
usersToAssign.add(new UIRepositoryUser(tiffanyUser));
List<Object> usersToUnAssign = new ArrayList<Object>();
usersToUnAssign.add(new UIRepositoryUser(patUser));
usersToUnAssign.add(new UIRepositoryUser(joeUser));
role.assignUsers(usersToAssign);
role.unassignUsers(usersToUnAssign);
// Should have exactly 7 roles
assertEquals(role.getMode(), Mode.EDIT);
// $NON-NLS-1$
assertEquals(role.getDescription(), "new description");
Assert.assertFalse(contains(role.getAssignedUsers(), new UIRepositoryUser(joeUser)));
Assert.assertFalse(contains(role.getAssignedUsers(), new UIRepositoryUser(patUser)));
Assert.assertTrue(contains(role.getAssignedUsers(), new UIRepositoryUser(tiffanyUser)));
Assert.assertTrue(contains(role.getAssignedUsers(), new UIRepositoryUser(suzyUser)));
} catch (Exception e) {
Assert.fail();
}
}
use of org.pentaho.di.repository.UserInfo in project pentaho-kettle by pentaho.
the class AbsSecurityProviderTest method setUp.
@Before
public void setUp() {
provider = new AbsSecurityProvider(new PurRepository(), new PurRepositoryMeta(), new UserInfo(), mock(ServiceManager.class));
provider = spy(provider);
}
use of org.pentaho.di.repository.UserInfo in project pentaho-kettle by pentaho.
the class PurRepositorySecurityManagerTest method saveUserInfo_NormalizesInfo_FailsIfStillBreaches.
@Test(expected = KettleException.class)
public void saveUserInfo_NormalizesInfo_FailsIfStillBreaches() throws Exception {
UserInfo info = new UserInfo(" ");
manager.saveUserInfo(info);
}
use of org.pentaho.di.repository.UserInfo in project pentaho-kettle by pentaho.
the class PurRepositorySecurityManagerTest method saveUserInfo_NormalizesInfo_PassesIfNoViolations.
@Test
public void saveUserInfo_NormalizesInfo_PassesIfNoViolations() throws Exception {
IUser info = new UserInfo("login ");
ArgumentCaptor<IUser> captor = ArgumentCaptor.forClass(IUser.class);
manager.saveUserInfo(info);
verify(roleDelegate).createUser(captor.capture());
info = captor.getValue();
assertEquals("Spaces should be trimmed", "login", info.getLogin());
}
use of org.pentaho.di.repository.UserInfo in project pentaho-kettle by pentaho.
the class ExplorerHarness method main.
/**
* @param args
*/
@SuppressWarnings("nls")
public static void main(String[] args) {
KettleDatabaseRepositoryMeta repositoryMeta;
KettleDatabaseRepository repository;
@SuppressWarnings("unused") UserInfo userInfo;
repositoryMeta = new KettleDatabaseRepositoryMeta();
repositoryMeta.setName("Kettle Database Repository");
repositoryMeta.setDescription("Kettle database test repository");
DatabaseMeta connection = new DatabaseMeta();
connection.setDatabaseType("Hypersonic");
connection.setHostname("localhost");
connection.setDBName("kettle_repository_4x");
connection.setDBPort("9002");
connection.setUsername("sa");
repositoryMeta.setConnection(connection);
userInfo = new UserInfo("admin", "admin", "Administrator", "The system administrator", true);
repository = new KettleDatabaseRepository();
repository.init(repositoryMeta);
@SuppressWarnings("unused") RepositoryExplorerCallback cb = new RepositoryExplorerCallback() {
public boolean open(UIRepositoryContent element, String revision) throws Exception {
System.out.println("Name: ".concat(element.getName()));
System.out.println("Type: ".concat(element.getRepositoryElementType().name()));
System.out.println("Directory: ".concat(element.getRepositoryDirectory().toString()));
System.out.println("Revision: ".concat(revision == null ? "null" : revision));
// do not close explorer
return false;
}
@Override
public boolean error(String message) throws Exception {
System.out.println("Error message: ".concat(message));
return true;
}
};
/*
* try { repository.connect(userInfo.getLogin(), userInfo.getPassword()); //RepositoryExplorer explorer = new
* RepositoryExplorer(new Shell(), repository, cb, null); //explorer.show(); } catch (XulException e) {
* e.printStackTrace(); } catch (KettleSecurityException e) { e.printStackTrace(); } catch (KettleException e) {
* e.printStackTrace(); }
*/
}
Aggregations