use of org.osgi.service.useradmin.User in project felix by apache.
the class CustomRoleImplTest method testAddUserCredentialsYieldsEvent.
/**
* Tests that changing the credentials of a user-role yields an event.
*/
public void testAddUserCredentialsYieldsEvent() throws Exception {
final User role = (User) m_repository.addRole("testUser", Role.USER);
assertNotNull(role);
m_latch = new CountDownLatch(1);
new Thread(new Runnable() {
public void run() {
role.getCredentials().put("key", "value");
}
}).start();
assertTrue(m_latch.await(1, TimeUnit.SECONDS));
}
use of org.osgi.service.useradmin.User in project felix by apache.
the class CustomRoleImplTest method testRemoveUserCredentialsYieldsEvent.
/**
* Tests that changing the credentials of a user-role yields an event.
*/
public void testRemoveUserCredentialsYieldsEvent() throws Exception {
final User role = (User) m_repository.addRole("testUser", Role.USER);
role.getCredentials().put("key", "value");
assertNotNull(role);
m_latch = new CountDownLatch(1);
new Thread(new Runnable() {
public void run() {
role.getCredentials().remove("key");
}
}).start();
assertTrue(m_latch.await(1, TimeUnit.SECONDS));
}
use of org.osgi.service.useradmin.User in project felix by apache.
the class RoleCheckerTest method testGroupDoesNotImplyNotImpliedUser.
/**
* Test that a user does never imply a group to which it is not a member.
*/
public void testGroupDoesNotImplyNotImpliedUser() {
User user = RoleFactory.createUser("foo");
Group group = RoleFactory.createGroup("bar");
group.addMember(user);
assertFalse(m_roleChecker.isImpliedBy(user, group));
}
use of org.osgi.service.useradmin.User in project felix by apache.
the class RoleCheckerTest method testUserDoesNotImplyNotImpliedGroup.
/**
* Test that a user does never imply a group to which it is not a member.
*/
public void testUserDoesNotImplyNotImpliedGroup() {
User user = RoleFactory.createUser("foo");
Group group = RoleFactory.createGroup("bar");
assertFalse(m_roleChecker.isImpliedBy(user, group));
}
use of org.osgi.service.useradmin.User in project felix by apache.
the class RoleCheckerTest method testRequiredRolesMultipleRequiredGroupsOk.
/**
* Test that a membership can be implied for users belonging to multiple required groups.
*/
public void testRequiredRolesMultipleRequiredGroupsOk() {
User elmer = RoleFactory.createUser("elmer");
User pepe = RoleFactory.createUser("pepe");
User bugs = RoleFactory.createUser("bugs");
User daffy = RoleFactory.createUser("daffy");
Group administrators = RoleFactory.createGroup("administrators");
administrators.addRequiredMember(m_anyone);
administrators.addMember(elmer);
administrators.addMember(pepe);
administrators.addMember(bugs);
Group family = RoleFactory.createGroup("family");
family.addRequiredMember(m_anyone);
family.addMember(elmer);
family.addMember(pepe);
family.addMember(daffy);
Group alarmSystemActivation = RoleFactory.createGroup("alarmSystemActivation");
alarmSystemActivation.addMember(m_anyone);
alarmSystemActivation.addRequiredMember(administrators);
alarmSystemActivation.addRequiredMember(family);
assertTrue(m_roleChecker.isImpliedBy(alarmSystemActivation, elmer));
assertTrue(m_roleChecker.isImpliedBy(alarmSystemActivation, pepe));
assertFalse(m_roleChecker.isImpliedBy(alarmSystemActivation, bugs));
assertFalse(m_roleChecker.isImpliedBy(alarmSystemActivation, daffy));
}
Aggregations