use of io.joynr.accesscontrol.global.jee.persistence.DomainRoleEntryEntity in project joynr by bmwcarit.
the class MasterRegistrationControlEntryManagerTest method testCreateNotAllowedWithoutMasterRole.
@Test
public void testCreateNotAllowedWithoutMasterRole() {
String userId = "userId";
String domain = "domain";
String interfaceName = "interfaceName";
MasterRegistrationControlEntry data = new MasterRegistrationControlEntry(userId, domain, interfaceName, TrustLevel.LOW, new TrustLevel[0], TrustLevel.LOW, new TrustLevel[0], Permission.ASK, new Permission[0]);
DomainRoleEntryEntity domainRoleEntryEntity = new DomainRoleEntryEntity();
domainRoleEntryEntity.setUserId(userId);
domainRoleEntryEntity.setRole(Role.OWNER);
domainRoleEntryEntity.setDomains(Sets.newHashSet(domain));
entityManager.persist(domainRoleEntryEntity);
flushAndClear();
JoynrJeeMessageContext.getInstance().activate();
CreateOrUpdateResult<MasterRegistrationControlEntry> result = null;
try {
joynrCallingPrincipal.setUsername(userId);
result = subject.createOrUpdate(data, ControlEntryType.MASTER);
} finally {
JoynrJeeMessageContext.getInstance().deactivate();
}
assertNull(result);
flushAndClear();
MasterRegistrationControlEntry[] persisted = subject.findByUserIdAndType(userId, ControlEntryType.MASTER);
assertNotNull(persisted);
assertEquals(0, persisted.length);
}
use of io.joynr.accesscontrol.global.jee.persistence.DomainRoleEntryEntity in project joynr by bmwcarit.
the class MasterAccessControlEntryManagerTest method testUserNotAllowedToCreateOrUpdate.
@Test
public void testUserNotAllowedToCreateOrUpdate() {
String userId = "user";
String domain = "domain";
DomainRoleEntryEntity domainRoleEntryEntity = new DomainRoleEntryEntity();
domainRoleEntryEntity.setUserId(userId);
domainRoleEntryEntity.setRole(Role.OWNER);
domainRoleEntryEntity.setDomains(Sets.newHashSet(domain));
entityManager.persist(domainRoleEntryEntity);
create(userId, domain, "interfaceName", TrustLevel.HIGH, new TrustLevel[0], TrustLevel.LOW, new TrustLevel[0], "operation", Permission.YES, new Permission[0]);
flushAndClear();
MasterAccessControlEntry updatedData = new MasterAccessControlEntry(userId, domain, "interfaceName", TrustLevel.LOW, new TrustLevel[] { TrustLevel.HIGH }, TrustLevel.HIGH, new TrustLevel[0], "operation", Permission.ASK, new Permission[] { Permission.NO });
CreateOrUpdateResult<MasterAccessControlEntry> result = null;
JoynrJeeMessageContext.getInstance().activate();
try {
joynrCallingPrincipal.setUsername(userId);
result = subject.createOrUpdate(updatedData, ControlEntryType.MASTER);
} finally {
JoynrJeeMessageContext.getInstance().deactivate();
}
assertNull(result);
}
use of io.joynr.accesscontrol.global.jee.persistence.DomainRoleEntryEntity in project joynr by bmwcarit.
the class OwnerAccessControlEntryManagerTest method testFindByUserIdAndAreEditable.
@Test
public void testFindByUserIdAndAreEditable() {
String userId = "user1";
String domain = "domain1";
String interfaceName = "interfaceName1";
String operation = "operation1";
create(userId, domain, interfaceName, TrustLevel.HIGH, TrustLevel.HIGH, operation, Permission.ASK);
create(userId, "otherdomain", "interfaceName", TrustLevel.LOW, TrustLevel.HIGH, "operation2", Permission.NO);
DomainRoleEntryEntity domainRoleEntryEntity = new DomainRoleEntryEntity();
domainRoleEntryEntity.setUserId(userId);
domainRoleEntryEntity.setRole(Role.OWNER);
domainRoleEntryEntity.setDomains(Sets.newHashSet(domain));
entityManager.persist(domainRoleEntryEntity);
flushAndClear();
OwnerAccessControlEntry[] result = subject.findByUserIdThatAreEditable(userId);
assertNotNull(result);
assertEquals(1, result.length);
assertEquals(interfaceName, result[0].getInterfaceName());
assertEquals(operation, result[0].getOperation());
}
use of io.joynr.accesscontrol.global.jee.persistence.DomainRoleEntryEntity in project joynr by bmwcarit.
the class OwnerAccessControlEntryManagerTest method testCreateNotAllowedWithoutOwnerRole.
@Test
public void testCreateNotAllowedWithoutOwnerRole() {
String userId = "user";
String domain = "domain";
String interfaceName = "interfaceName";
String operation = "operation";
DomainRoleEntryEntity domainRoleEntryEntity = new DomainRoleEntryEntity();
domainRoleEntryEntity.setUserId(userId);
domainRoleEntryEntity.setRole(Role.MASTER);
domainRoleEntryEntity.setDomains(Sets.newHashSet(domain));
entityManager.persist(domainRoleEntryEntity);
flushAndClear();
OwnerAccessControlEntry data = new OwnerAccessControlEntry(userId, domain, interfaceName, TrustLevel.HIGH, TrustLevel.LOW, operation, Permission.ASK);
CreateOrUpdateResult<OwnerAccessControlEntry> result = null;
JoynrJeeMessageContext.getInstance().activate();
try {
joynrCallingPrincipal.setUsername(userId);
result = subject.createOrUpdate(data);
} finally {
JoynrJeeMessageContext.getInstance().deactivate();
}
assertNull(result);
flushAndClear();
assertEquals(0, subject.findByUserId(userId).length);
}
use of io.joynr.accesscontrol.global.jee.persistence.DomainRoleEntryEntity in project joynr by bmwcarit.
the class OwnerRegistrationControlEntryManagerTest method testFindByUserIdAndThatAreEditable.
@Test
public void testFindByUserIdAndThatAreEditable() {
String userId = "userId";
String domain = "domain1";
create(userId, domain, "interfaceName", TrustLevel.MID, TrustLevel.HIGH, Permission.ASK);
create(userId, "domain2", "interfaceName", TrustLevel.MID, TrustLevel.HIGH, Permission.ASK);
DomainRoleEntryEntity domainRoleEntryEntity = new DomainRoleEntryEntity();
domainRoleEntryEntity.setUserId(userId);
domainRoleEntryEntity.setRole(Role.OWNER);
domainRoleEntryEntity.setDomains(Sets.newHashSet(domain));
entityManager.persist(domainRoleEntryEntity);
flushAndClear();
OwnerRegistrationControlEntry[] result = subject.findByUserIdAndThatIsEditable(userId);
assertNotNull(result);
assertEquals(1, result.length);
}
Aggregations