Search in sources :

Example 1 with OwnerRegistrationControlEntry

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

the class GlobalDomainAccessControlListEditorBean method updateOwnerRegistrationControlEntry.

@Override
public Boolean updateOwnerRegistrationControlEntry(OwnerRegistrationControlEntry updatedOwnerRce) {
    CreateOrUpdateResult<OwnerRegistrationControlEntry> result = ownerRegistrationControlEntryManager.createOrUpdate(updatedOwnerRce);
    if (result != null) {
        OwnerRegistrationControlEntry entry = result.getEntry();
        globalDomainAccessControllerBean.doFireOwnerRegistrationControlEntryChanged(result.getChangeType(), entry);
        return true;
    }
    return false;
}
Also used : OwnerRegistrationControlEntry(joynr.infrastructure.DacTypes.OwnerRegistrationControlEntry)

Example 2 with OwnerRegistrationControlEntry

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

the class OwnerRegistrationControlEntryManagerTest method testRemove.

@Test
public void testRemove() {
    String userId = "user";
    String domain = "domain";
    String interfaceName = "interfaceName";
    OwnerRegistrationControlEntryEntity entity = create(userId, domain, interfaceName, TrustLevel.MID, TrustLevel.HIGH, Permission.ASK);
    flushAndClear();
    OwnerRegistrationControlEntry removedEntry = subject.removeByUserIdDomainAndInterfaceName(userId, domain, interfaceName);
    assertNotNull(removedEntry);
    assertEquals(userId, removedEntry.getUid());
    flushAndClear();
    OwnerRegistrationControlEntryEntity persisted = entityManager.find(OwnerRegistrationControlEntryEntity.class, entity.getId());
    assertNull(persisted);
}
Also used : OwnerRegistrationControlEntryEntity(io.joynr.accesscontrol.global.jee.persistence.OwnerRegistrationControlEntryEntity) OwnerRegistrationControlEntry(joynr.infrastructure.DacTypes.OwnerRegistrationControlEntry) Test(org.junit.Test)

Example 3 with OwnerRegistrationControlEntry

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

the class OwnerRegistrationControlEntryManagerTest method testCreateNotAllowedWithoutOwnerRole.

@Test
public void testCreateNotAllowedWithoutOwnerRole() {
    String userId = "user";
    String domain = "domain";
    String interfaceName = "interfaceName";
    OwnerRegistrationControlEntry data = new OwnerRegistrationControlEntry(userId, domain, interfaceName, TrustLevel.MID, TrustLevel.HIGH, Permission.ASK);
    DomainRoleEntryEntity domainRoleEntryEntity = new DomainRoleEntryEntity();
    domainRoleEntryEntity.setUserId(userId);
    domainRoleEntryEntity.setRole(Role.MASTER);
    domainRoleEntryEntity.setDomains(Sets.newHashSet(domain));
    entityManager.persist(domainRoleEntryEntity);
    flushAndClear();
    CreateOrUpdateResult<OwnerRegistrationControlEntry> result = null;
    JoynrJeeMessageContext.getInstance().activate();
    try {
        joynrCallingPrincipal.setUsername(userId);
        result = subject.createOrUpdate(data);
    } finally {
        JoynrJeeMessageContext.getInstance().deactivate();
    }
    assertNull(result);
    flushAndClear();
    OwnerRegistrationControlEntry[] persisted = subject.findByUserId(userId);
    assertNotNull(persisted);
    assertEquals(0, persisted.length);
}
Also used : DomainRoleEntryEntity(io.joynr.accesscontrol.global.jee.persistence.DomainRoleEntryEntity) OwnerRegistrationControlEntry(joynr.infrastructure.DacTypes.OwnerRegistrationControlEntry) Test(org.junit.Test)

Example 4 with OwnerRegistrationControlEntry

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

the class OwnerRegistrationControlEntryManagerTest method testUpdate.

@Test
public void testUpdate() {
    String userId = "user";
    String domain = "domain";
    String interfaceName = "interfaceName";
    OwnerRegistrationControlEntryEntity entity = create(userId, domain, interfaceName, TrustLevel.MID, TrustLevel.HIGH, Permission.ASK);
    flushAndClear();
    OwnerRegistrationControlEntry updatedData = new OwnerRegistrationControlEntry(userId, domain, interfaceName, TrustLevel.HIGH, TrustLevel.LOW, Permission.NO);
    CreateOrUpdateResult<OwnerRegistrationControlEntry> result = subject.createOrUpdate(updatedData);
    assertNotNull(result);
    assertEquals(ChangeType.UPDATE, result.getChangeType());
    assertNotNull(result.getEntry());
    assertEquals(userId, result.getEntry().getUid());
    flushAndClear();
    OwnerRegistrationControlEntryEntity persisted = entityManager.find(OwnerRegistrationControlEntryEntity.class, entity.getId());
    assertNotNull(persisted);
    assertEquals(TrustLevel.HIGH, persisted.getRequiredTrustLevel());
    assertEquals(TrustLevel.LOW, persisted.getRequiredAceChangeTrustLevel());
    assertEquals(Permission.NO, persisted.getProviderPermission());
}
Also used : OwnerRegistrationControlEntryEntity(io.joynr.accesscontrol.global.jee.persistence.OwnerRegistrationControlEntryEntity) OwnerRegistrationControlEntry(joynr.infrastructure.DacTypes.OwnerRegistrationControlEntry) Test(org.junit.Test)

Example 5 with OwnerRegistrationControlEntry

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

the class GlobalDomainAccessControlListEditorBeanTest method testCreateAndUpdateOwnerRegistrationControlEntry.

@Test
public void testCreateAndUpdateOwnerRegistrationControlEntry() {
    for (ChangeType changeType : new ChangeType[] { ChangeType.ADD, ChangeType.UPDATE }) {
        reset(ownerRegistrationControlEntryManagerMock);
        OwnerRegistrationControlEntry orce = new OwnerRegistrationControlEntry(USER_ID, DOMAIN, INTERFACE_NAME, TrustLevel.HIGH, TrustLevel.LOW, Permission.ASK);
        when(ownerRegistrationControlEntryManagerMock.createOrUpdate(orce)).thenReturn(new CreateOrUpdateResult<OwnerRegistrationControlEntry>(orce, changeType));
        assertTrue(globalDomainAccessControlListEditorSubject.updateOwnerRegistrationControlEntry(orce));
        verify(ownerRegistrationControlEntryManagerMock).createOrUpdate(eq(orce));
        verify(globalDomainAccessControllerBeanMock).doFireOwnerRegistrationControlEntryChanged(eq(changeType), eq(orce));
    }
}
Also used : ChangeType(joynr.infrastructure.DacTypes.ChangeType) OwnerRegistrationControlEntry(joynr.infrastructure.DacTypes.OwnerRegistrationControlEntry) Test(org.junit.Test)

Aggregations

OwnerRegistrationControlEntry (joynr.infrastructure.DacTypes.OwnerRegistrationControlEntry)8 Test (org.junit.Test)7 DomainRoleEntryEntity (io.joynr.accesscontrol.global.jee.persistence.DomainRoleEntryEntity)2 OwnerRegistrationControlEntryEntity (io.joynr.accesscontrol.global.jee.persistence.OwnerRegistrationControlEntryEntity)2 ChangeType (joynr.infrastructure.DacTypes.ChangeType)1