use of joynr.infrastructure.DacTypes.MasterAccessControlEntry in project joynr by bmwcarit.
the class GlobalDomainAccessControlListEditorBeanTest method testRemoveMasterAccessControlEntry.
@Test
public void testRemoveMasterAccessControlEntry() {
MasterAccessControlEntry mace = new MasterAccessControlEntry(USER_ID, DOMAIN, INTERFACE_NAME, TrustLevel.LOW, new TrustLevel[0], TrustLevel.HIGH, new TrustLevel[0], OPERATION, Permission.ASK, new Permission[0]);
when(masterAccessControlEntryManagerMock.removeByUserIdDomainInterfaceNameAndOperation(USER_ID, DOMAIN, INTERFACE_NAME, OPERATION, ControlEntryType.MASTER)).thenReturn(mace);
Boolean result = globalDomainAccessControlListEditorSubject.removeMasterAccessControlEntry(USER_ID, DOMAIN, INTERFACE_NAME, OPERATION);
assertEquals(Boolean.TRUE, result);
verify(masterAccessControlEntryManagerMock).removeByUserIdDomainInterfaceNameAndOperation(eq(USER_ID), eq(DOMAIN), eq(INTERFACE_NAME), eq(OPERATION), eq(ControlEntryType.MASTER));
verify(globalDomainAccessControllerBeanMock).doFireMasterAccessControlEntryChanged(eq(ChangeType.REMOVE), eq(mace));
}
use of joynr.infrastructure.DacTypes.MasterAccessControlEntry in project joynr by bmwcarit.
the class MasterAccessControlEntryManagerTest method testUpdate.
@Test
public void testUpdate() {
create("user", "domain", "interfaceName", TrustLevel.HIGH, new TrustLevel[0], TrustLevel.LOW, new TrustLevel[0], "operation", Permission.YES, new Permission[0]);
MasterAccessControlEntry entry = subject.findByUserId("user", MASTER)[0];
flushAndClear();
entry.setDefaultRequiredTrustLevel(TrustLevel.LOW);
entry.setPossibleRequiredTrustLevels(new TrustLevel[] { TrustLevel.HIGH, TrustLevel.MID });
entry.setDefaultConsumerPermission(Permission.ASK);
CreateOrUpdateResult<MasterAccessControlEntry> result = subject.createOrUpdate(entry, MASTER);
assertNotNull(result);
assertEquals(ChangeType.UPDATE, result.getChangeType());
assertNotNull(result.getEntry());
assertEquals("user", result.getEntry().getUid());
flushAndClear();
entry = subject.findByUserId("user", MASTER)[0];
assertEquals(TrustLevel.LOW, entry.getDefaultRequiredTrustLevel());
assertEquals(2, entry.getPossibleRequiredTrustLevels().length);
assertEquals(Permission.ASK, entry.getDefaultConsumerPermission());
}
use of joynr.infrastructure.DacTypes.MasterAccessControlEntry in project joynr by bmwcarit.
the class MasterAccessControlEntryManagerTest method testRemoveNotAllowed.
@Test
public void testRemoveNotAllowed() {
String userId = "user";
MasterAccessControlEntryEntity entity = create(userId, "domain", "interfaceName", TrustLevel.HIGH, new TrustLevel[0], TrustLevel.LOW, new TrustLevel[0], "operation", Permission.YES, new Permission[0]);
flushAndClear();
MasterAccessControlEntry result = null;
JoynrJeeMessageContext.getInstance().activate();
try {
joynrCallingPrincipal.setUsername(userId);
subject.removeByUserIdDomainInterfaceNameAndOperation(entity.getUserId(), entity.getDomain(), entity.getInterfaceName(), entity.getOperation(), MASTER);
} finally {
JoynrJeeMessageContext.getInstance().deactivate();
}
assertNull(result);
flushAndClear();
MasterAccessControlEntryEntity persisted = entityManager.find(MasterAccessControlEntryEntity.class, entity.getId());
assertNotNull(persisted);
}
use of joynr.infrastructure.DacTypes.MasterAccessControlEntry in project joynr by bmwcarit.
the class MasterAccessControlEntryManagerTest method testCorrectTypeFound.
@Test
public void testCorrectTypeFound() {
create("user", "domain", "interfaceName", TrustLevel.HIGH, new TrustLevel[0], TrustLevel.LOW, new TrustLevel[0], "operation", Permission.YES, new Permission[0], MASTER);
create("user", "domain", "interfaceName", TrustLevel.HIGH, new TrustLevel[0], TrustLevel.LOW, new TrustLevel[0], "operation", Permission.YES, new Permission[0], MEDIATOR);
flushAndClear();
for (ControlEntryType type : new ControlEntryType[] { MASTER, MEDIATOR }) {
MasterAccessControlEntry[] persisted = subject.findByUserId("user", type);
assertNotNull("Not found for user and " + type, persisted);
assertEquals("Not found for user and " + type, 1, persisted.length);
}
}
use of joynr.infrastructure.DacTypes.MasterAccessControlEntry in project joynr by bmwcarit.
the class MasterAccessControlEntryManagerTest method testCreate.
@Test
public void testCreate() {
MasterAccessControlEntry newEntry = new MasterAccessControlEntry("user", "domain", "interfaceName", TrustLevel.HIGH, new TrustLevel[0], TrustLevel.LOW, new TrustLevel[0], "operation", Permission.ASK, new Permission[0]);
CreateOrUpdateResult<MasterAccessControlEntry> result = subject.createOrUpdate(newEntry, MASTER);
assertNotNull(result);
assertEquals(ChangeType.ADD, result.getChangeType());
assertNotNull(result.getEntry());
assertEquals("user", result.getEntry().getUid());
flushAndClear();
MasterAccessControlEntry[] persisted = subject.findByUserId("user", MASTER);
assertNotNull(persisted);
assertEquals(1, persisted.length);
MasterAccessControlEntry entry = persisted[0];
assertEquals("user", entry.getUid());
assertEquals("domain", entry.getDomain());
assertEquals("interfaceName", entry.getInterfaceName());
assertEquals("operation", entry.getOperation());
assertEquals(TrustLevel.HIGH, entry.getDefaultRequiredTrustLevel());
assertEquals(TrustLevel.LOW, entry.getDefaultRequiredControlEntryChangeTrustLevel());
assertEquals(Permission.ASK, entry.getDefaultConsumerPermission());
assertNotNull(entry.getPossibleRequiredTrustLevels());
assertEquals(0, entry.getPossibleRequiredTrustLevels().length);
assertNotNull(entry.getPossibleRequiredControlEntryChangeTrustLevels());
assertEquals(0, entry.getPossibleRequiredControlEntryChangeTrustLevels().length);
assertNotNull(entry.getPossibleConsumerPermissions());
assertEquals(0, entry.getPossibleConsumerPermissions().length);
}
Aggregations