Search in sources :

Example 1 with MasterRegistrationControlEntry

use of joynr.infrastructure.DacTypes.MasterRegistrationControlEntry in project joynr by bmwcarit.

the class GlobalDomainAccessControlListEditorBean method updateMediatorRegistrationControlEntry.

@Override
public Boolean updateMediatorRegistrationControlEntry(MasterRegistrationControlEntry updatedMediatorRce) {
    CreateOrUpdateResult<MasterRegistrationControlEntry> result = masterRegistrationControlEntryManager.createOrUpdate(updatedMediatorRce, ControlEntryType.MEDIATOR);
    if (result != null) {
        MasterRegistrationControlEntry entry = result.getEntry();
        globalDomainAccessControllerBean.doFireMediatorRegistrationControlEntryChanged(result.getChangeType(), entry);
        return true;
    }
    return false;
}
Also used : MasterRegistrationControlEntry(joynr.infrastructure.DacTypes.MasterRegistrationControlEntry)

Example 2 with MasterRegistrationControlEntry

use of joynr.infrastructure.DacTypes.MasterRegistrationControlEntry 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));
    }
}
Also used : Function(java.util.function.Function) ControlEntryType(io.joynr.accesscontrol.global.jee.persistence.ControlEntryType) HashMap(java.util.HashMap) MasterRegistrationControlEntry(joynr.infrastructure.DacTypes.MasterRegistrationControlEntry) Test(org.junit.Test)

Example 3 with MasterRegistrationControlEntry

use of joynr.infrastructure.DacTypes.MasterRegistrationControlEntry in project joynr by bmwcarit.

the class MasterRegistrationControlEntryManagerTest method testUpdate.

@Test
public void testUpdate() {
    String userId = "user";
    String domain = "domain1";
    String interfaceName = "interfaceName1";
    MasterRegistrationControlEntryEntity entity = create(userId, domain, interfaceName, TrustLevel.HIGH, new TrustLevel[0], TrustLevel.LOW, new TrustLevel[0], Permission.YES, new Permission[0], ControlEntryType.MASTER);
    flushAndClear();
    MasterRegistrationControlEntry updatedData = new MasterRegistrationControlEntry(userId, domain, interfaceName, TrustLevel.LOW, new TrustLevel[] { TrustLevel.MID, TrustLevel.HIGH }, TrustLevel.HIGH, new TrustLevel[0], Permission.ASK, new Permission[] { Permission.NO });
    CreateOrUpdateResult<MasterRegistrationControlEntry> result = subject.createOrUpdate(updatedData, ControlEntryType.MASTER);
    assertNotNull(result);
    assertEquals(ChangeType.UPDATE, result.getChangeType());
    assertNotNull(result.getEntry());
    assertEquals(userId, result.getEntry().getUid());
    flushAndClear();
    MasterRegistrationControlEntryEntity persisted = entityManager.find(MasterRegistrationControlEntryEntity.class, entity.getId());
    assertNotNull(persisted);
    assertEquals(TrustLevel.LOW, persisted.getDefaultRequiredTrustLevel());
    assertEquals(2, persisted.getPossibleRequiredTrustLevels().size());
    assertEquals(TrustLevel.HIGH, persisted.getDefaultRequiredControlEntryChangeTrustLevel());
    assertEquals(Permission.ASK, persisted.getDefaultProviderPermission());
}
Also used : MasterRegistrationControlEntryEntity(io.joynr.accesscontrol.global.jee.persistence.MasterRegistrationControlEntryEntity) MasterRegistrationControlEntry(joynr.infrastructure.DacTypes.MasterRegistrationControlEntry) Test(org.junit.Test)

Example 4 with MasterRegistrationControlEntry

use of joynr.infrastructure.DacTypes.MasterRegistrationControlEntry 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));
    }
}
Also used : Function(java.util.function.Function) ControlEntryType(io.joynr.accesscontrol.global.jee.persistence.ControlEntryType) HashMap(java.util.HashMap) MasterRegistrationControlEntry(joynr.infrastructure.DacTypes.MasterRegistrationControlEntry) Test(org.junit.Test)

Example 5 with MasterRegistrationControlEntry

use of joynr.infrastructure.DacTypes.MasterRegistrationControlEntry 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);
    }
}
Also used : ControlEntryType(io.joynr.accesscontrol.global.jee.persistence.ControlEntryType) Consumer(java.util.function.Consumer) HashMap(java.util.HashMap) Supplier(java.util.function.Supplier) MasterRegistrationControlEntry(joynr.infrastructure.DacTypes.MasterRegistrationControlEntry) Test(org.junit.Test)

Aggregations

MasterRegistrationControlEntry (joynr.infrastructure.DacTypes.MasterRegistrationControlEntry)11 Test (org.junit.Test)8 ControlEntryType (io.joynr.accesscontrol.global.jee.persistence.ControlEntryType)4 HashMap (java.util.HashMap)4 Function (java.util.function.Function)3 DomainRoleEntryEntity (io.joynr.accesscontrol.global.jee.persistence.DomainRoleEntryEntity)2 Consumer (java.util.function.Consumer)2 MasterRegistrationControlEntryEntity (io.joynr.accesscontrol.global.jee.persistence.MasterRegistrationControlEntryEntity)1 Supplier (java.util.function.Supplier)1 ChangeType (joynr.infrastructure.DacTypes.ChangeType)1 Permission (joynr.infrastructure.DacTypes.Permission)1 TrustLevel (joynr.infrastructure.DacTypes.TrustLevel)1