use of org.camunda.bpm.engine.authorization.Authorization in project camunda-bpm-platform by camunda.
the class AuthorizationRestServiceInteractionTest method testGetAuthorizationById.
@Test
public void testGetAuthorizationById() {
Authorization authorization = MockProvider.createMockGlobalAuthorization();
AuthorizationQuery authorizationQuery = mock(AuthorizationQuery.class);
when(authorizationServiceMock.createAuthorizationQuery()).thenReturn(authorizationQuery);
when(authorizationQuery.authorizationId(MockProvider.EXAMPLE_AUTHORIZATION_ID)).thenReturn(authorizationQuery);
when(authorizationQuery.singleResult()).thenReturn(authorization);
given().pathParam("id", MockProvider.EXAMPLE_AUTHORIZATION_ID).then().expect().statusCode(Status.OK.getStatusCode()).contentType(ContentType.JSON).body("id", equalTo(authorization.getId())).body("type", equalTo(authorization.getAuthorizationType())).body("permissions[0]", equalTo(Permissions.READ.getName())).body("permissions[1]", equalTo(Permissions.UPDATE.getName())).body("userId", equalTo(authorization.getUserId())).body("groupId", equalTo(authorization.getGroupId())).body("resourceType", equalTo(authorization.getResourceType())).body("resourceId", equalTo(authorization.getResourceId())).when().get(AUTH_RESOURCE_PATH);
}
use of org.camunda.bpm.engine.authorization.Authorization in project camunda-bpm-platform by camunda.
the class DeploymentAuthorizationTest method testCreateAuthorizationOnDeploy.
// should create authorization /////////////////////////////////////
public void testCreateAuthorizationOnDeploy() {
// given
createGrantAuthorization(DEPLOYMENT, ANY, userId, CREATE);
Deployment deployment = repositoryService.createDeployment().addClasspathResource(FIRST_RESOURCE).deploy();
// when
Authorization authorization = authorizationService.createAuthorizationQuery().userIdIn(userId).resourceId(deployment.getId()).singleResult();
// then
assertNotNull(authorization);
assertTrue(authorization.isPermissionGranted(READ));
assertTrue(authorization.isPermissionGranted(DELETE));
assertFalse(authorization.isPermissionGranted(UPDATE));
deleteDeployment(deployment.getId());
}
use of org.camunda.bpm.engine.authorization.Authorization in project camunda-bpm-platform by camunda.
the class GroupAuthorizationTest method createGroupGrantAuthorization.
protected void createGroupGrantAuthorization(Resource resource, String resourceId, String groupId, Permission... permissions) {
Authorization authorization = createGrantAuthorization(resource, resourceId);
authorization.setGroupId(groupId);
for (Permission permission : permissions) {
authorization.addPermission(permission);
}
saveAuthorization(authorization);
}
use of org.camunda.bpm.engine.authorization.Authorization in project camunda-bpm-platform by camunda.
the class AuthorizationTest method createRevokeAuthorization.
protected void createRevokeAuthorization(Resource resource, String resourceId, String userId, Permission... permissions) {
Authorization authorization = createRevokeAuthorization(resource, resourceId);
authorization.setUserId(userId);
for (Permission permission : permissions) {
authorization.removePermission(permission);
}
saveAuthorization(authorization);
}
use of org.camunda.bpm.engine.authorization.Authorization in project camunda-bpm-platform by camunda.
the class AuthorizationTest method createGrantAuthorizationGroup.
protected void createGrantAuthorizationGroup(Resource resource, String resourceId, String groupId, Permission... permissions) {
Authorization authorization = createGrantAuthorization(resource, resourceId);
authorization.setGroupId(groupId);
for (Permission permission : permissions) {
authorization.addPermission(permission);
}
saveAuthorization(authorization);
}
Aggregations