use of io.joynr.accesscontrol.global.jee.persistence.ControlEntryType in project joynr by bmwcarit.
the class GlobalDomainAccessControlListEditorBeanTest method testFindEditableMasterAndMediatorRegistrationControlEntryByUserId.
@Test
public void testFindEditableMasterAndMediatorRegistrationControlEntryByUserId() {
Map<ControlEntryType, Function<String, MasterRegistrationControlEntry[]>> getters = new HashMap<>();
getters.put(ControlEntryType.MASTER, (String userId) -> {
return globalDomainAccessControlListEditorSubject.getEditableMasterRegistrationControlEntries(userId);
});
getters.put(ControlEntryType.MEDIATOR, (String userId) -> {
return globalDomainAccessControlListEditorSubject.getEditableMediatorRegistrationControlEntries(userId);
});
for (ControlEntryType type : new ControlEntryType[] { ControlEntryType.MASTER, ControlEntryType.MEDIATOR }) {
when(masterRegistrationControlEntryManagerMock.findByUserIdAndThatAreEditable(USER_ID, type)).thenReturn(new MasterRegistrationControlEntry[0]);
MasterRegistrationControlEntry[] result = getters.get(type).apply(USER_ID);
assertNotNull(result);
assertEquals(0, result.length);
verify(masterRegistrationControlEntryManagerMock).findByUserIdAndThatAreEditable(eq(USER_ID), eq(type));
}
}
use of io.joynr.accesscontrol.global.jee.persistence.ControlEntryType in project joynr by bmwcarit.
the class GlobalDomainAccessControllerBeanTest method testFindMasterAndMediatorRegistrationControlEntryByUserId.
@Test
public void testFindMasterAndMediatorRegistrationControlEntryByUserId() {
Map<ControlEntryType, Function<String, MasterRegistrationControlEntry[]>> getters = new HashMap<>();
getters.put(ControlEntryType.MASTER, (String userId) -> {
return globalDomainAccessControllerSubject.getMasterRegistrationControlEntries(userId);
});
getters.put(ControlEntryType.MEDIATOR, (String userId) -> {
return globalDomainAccessControllerSubject.getMediatorRegistrationControlEntries(userId);
});
for (ControlEntryType type : new ControlEntryType[] { ControlEntryType.MASTER, ControlEntryType.MEDIATOR }) {
when(masterRegistrationControlEntryManagerMock.findByUserIdAndType(USER_ID, type)).thenReturn(new MasterRegistrationControlEntry[0]);
MasterRegistrationControlEntry[] result = getters.get(type).apply(USER_ID);
assertNotNull(result);
assertEquals(0, result.length);
verify(masterRegistrationControlEntryManagerMock).findByUserIdAndType(eq(USER_ID), eq(type));
}
}
use of io.joynr.accesscontrol.global.jee.persistence.ControlEntryType in project joynr by bmwcarit.
the class GlobalDomainAccessControlListEditorBeanTest method testRemoveMasterAndMediatorRegistrationControlEntry.
@Test
public void testRemoveMasterAndMediatorRegistrationControlEntry() {
Map<ControlEntryType, Supplier<Boolean>> globalDomainAccessControllerSubjectCalls = new HashMap<>();
globalDomainAccessControllerSubjectCalls.put(ControlEntryType.MASTER, () -> {
return globalDomainAccessControlListEditorSubject.removeMasterRegistrationControlEntry(USER_ID, DOMAIN, INTERFACE_NAME);
});
globalDomainAccessControllerSubjectCalls.put(ControlEntryType.MEDIATOR, () -> {
return globalDomainAccessControlListEditorSubject.removeMediatorRegistrationControlEntry(USER_ID, DOMAIN, INTERFACE_NAME);
});
Map<ControlEntryType, Consumer<MasterRegistrationControlEntry>> multicastVerifiers = new HashMap<>();
multicastVerifiers.put(ControlEntryType.MASTER, (mrce) -> {
verify(globalDomainAccessControllerBeanMock).doFireMasterRegistrationControlEntryChanged(eq(ChangeType.REMOVE), eq(mrce));
});
multicastVerifiers.put(ControlEntryType.MEDIATOR, (mrce) -> {
verify(globalDomainAccessControllerBeanMock).doFireMediatorRegistrationControlEntryChanged(eq(ChangeType.REMOVE), eq(mrce));
});
for (ControlEntryType type : new ControlEntryType[] { ControlEntryType.MASTER, ControlEntryType.MEDIATOR }) {
MasterRegistrationControlEntry mrce = new MasterRegistrationControlEntry(USER_ID, DOMAIN, INTERFACE_NAME, TrustLevel.LOW, new TrustLevel[0], TrustLevel.HIGH, new TrustLevel[0], Permission.ASK, new Permission[0]);
when(masterRegistrationControlEntryManagerMock.removeByUserIdDomainInterfaceNameAndType(USER_ID, DOMAIN, INTERFACE_NAME, type)).thenReturn(mrce);
assertTrue(globalDomainAccessControllerSubjectCalls.get(type).get());
verify(masterRegistrationControlEntryManagerMock).removeByUserIdDomainInterfaceNameAndType(eq(USER_ID), eq(DOMAIN), eq(INTERFACE_NAME), eq(type));
multicastVerifiers.get(type).accept(mrce);
}
}
use of io.joynr.accesscontrol.global.jee.persistence.ControlEntryType in project joynr by bmwcarit.
the class GlobalDomainAccessControlListEditorBeanTest method testCreateAndUpdateMasterAndMediatorRegistrationControlEntry.
@Test
public void testCreateAndUpdateMasterAndMediatorRegistrationControlEntry() {
for (ChangeType changeType : new ChangeType[] { ChangeType.ADD, ChangeType.UPDATE }) {
Map<ControlEntryType, Function<MasterRegistrationControlEntry, Boolean>> globalDomainAccessControllerSubjectCalls = new HashMap<>();
globalDomainAccessControllerSubjectCalls.put(ControlEntryType.MASTER, (updatedEntry) -> {
return globalDomainAccessControlListEditorSubject.updateMasterRegistrationControlEntry(updatedEntry);
});
globalDomainAccessControllerSubjectCalls.put(ControlEntryType.MEDIATOR, (updatedEntry) -> {
return globalDomainAccessControlListEditorSubject.updateMediatorRegistrationControlEntry(updatedEntry);
});
Map<ControlEntryType, Consumer<MasterRegistrationControlEntry>> multicastVerifiers = new HashMap<>();
multicastVerifiers.put(ControlEntryType.MASTER, (mrce) -> {
verify(globalDomainAccessControllerBeanMock).doFireMasterRegistrationControlEntryChanged(eq(changeType), eq(mrce));
});
multicastVerifiers.put(ControlEntryType.MEDIATOR, (mrce) -> {
verify(globalDomainAccessControllerBeanMock).doFireMediatorRegistrationControlEntryChanged(eq(changeType), eq(mrce));
});
for (ControlEntryType type : new ControlEntryType[] { ControlEntryType.MASTER, ControlEntryType.MEDIATOR }) {
reset(masterRegistrationControlEntryManagerMock);
// reset(globalDomainAccessControllerSubscriptionPublisherMock);
MasterRegistrationControlEntry mrce = new MasterRegistrationControlEntry(USER_ID, DOMAIN, INTERFACE_NAME, TrustLevel.LOW, new TrustLevel[0], TrustLevel.HIGH, new TrustLevel[0], Permission.ASK, new Permission[0]);
when(masterRegistrationControlEntryManagerMock.createOrUpdate(mrce, type)).thenReturn(new CreateOrUpdateResult<MasterRegistrationControlEntry>(mrce, changeType));
assertTrue(globalDomainAccessControllerSubjectCalls.get(type).apply(mrce));
verify(masterRegistrationControlEntryManagerMock).createOrUpdate(mrce, type);
multicastVerifiers.get(type).accept(mrce);
}
}
}
use of io.joynr.accesscontrol.global.jee.persistence.ControlEntryType 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);
}
}
Aggregations