Search in sources :

Example 1 with DataPointPermissionDefinition

use of com.serotonin.m2m2.module.definitions.permissions.DataPointPermissionDefinition in project ma-core-public by infiniteautomation.

the class ViewDataPointsPermissionTest method init.

@Before
public void init() {
    this.runAs = Common.getBean(RunAs.class);
    this.service = Common.getBean(DataPointService.class);
    // create Role for this test
    this.viewDataPointsRole = this.createRole("viewDataPointsRole", DataPointPermissionDefinition.PERMISSION);
    this.userAllowed = this.createUser("Jane Doe", "Jane001", "14mJ4n3D03!", "jane.doe@unknown.com", viewDataPointsRole.getRole());
    this.userWithoutPermission = this.createUser("John Doe", "John001", "14mJ0hnD03!", "john.doe@unknown.com");
    // get the permission def
    DataPointPermissionDefinition dpPermDef = Common.getBean(DataPointPermissionDefinition.class);
    SystemPermissionService sysPermServ = Common.getBean(SystemPermissionService.class);
    this.runAs.runAs(this.runAs.systemSuperadmin(), () -> {
        sysPermServ.update(MangoPermission.requireAnyRole(viewDataPointsRole.getRole()), dpPermDef);
    });
    // create a data point that only superadmin can view
    point = (DataPointVO) this.createMockDataPoints(1).get(0);
}
Also used : DataPointService(com.infiniteautomation.mango.spring.service.DataPointService) SystemPermissionService(com.infiniteautomation.mango.spring.service.SystemPermissionService) RunAs(com.infiniteautomation.mango.spring.components.RunAs) DataPointPermissionDefinition(com.serotonin.m2m2.module.definitions.permissions.DataPointPermissionDefinition) Before(org.junit.Before)

Aggregations

RunAs (com.infiniteautomation.mango.spring.components.RunAs)1 DataPointService (com.infiniteautomation.mango.spring.service.DataPointService)1 SystemPermissionService (com.infiniteautomation.mango.spring.service.SystemPermissionService)1 DataPointPermissionDefinition (com.serotonin.m2m2.module.definitions.permissions.DataPointPermissionDefinition)1 Before (org.junit.Before)1