//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testGroupMembersResourceOptionsUnauthorized() public virtual void testGroupMembersResourceOptionsUnauthorized() { string fullMembersUrl = "http://localhost:" + PORT + TEST_RESOURCE_ROOT_PATH + "/group/" + MockProvider.EXAMPLE_GROUP_ID + "/members"; Authentication authentication = new Authentication(MockProvider.EXAMPLE_USER_ID, null); when(identityServiceMock.CurrentAuthentication).thenReturn(authentication); when(authorizationServiceMock.isUserAuthorized(MockProvider.EXAMPLE_USER_ID, null, DELETE, GROUP_MEMBERSHIP, MockProvider.EXAMPLE_GROUP_ID)).thenReturn(false); when(authorizationServiceMock.isUserAuthorized(MockProvider.EXAMPLE_USER_ID, null, CREATE, GROUP_MEMBERSHIP, MockProvider.EXAMPLE_GROUP_ID)).thenReturn(false); Group sampleGroup = MockProvider.createMockGroup(); GroupQuery sampleGroupQuery = mock(typeof(GroupQuery)); when(identityServiceMock.createGroupQuery()).thenReturn(sampleGroupQuery); when(sampleGroupQuery.groupId(MockProvider.EXAMPLE_GROUP_ID)).thenReturn(sampleGroupQuery); when(sampleGroupQuery.singleResult()).thenReturn(sampleGroup); when(processEngineConfigurationMock.AuthorizationEnabled).thenReturn(true); given().pathParam("id", MockProvider.EXAMPLE_GROUP_ID).then().expect().statusCode(Status.OK.StatusCode).body("links[0].href", equalTo(fullMembersUrl)).body("links[0].method", equalTo(HttpMethod.GET)).body("links[0].rel", equalTo("self")).body("links[1]", nullValue()).body("links[2]", nullValue()).when().options(GROUP_MEMBERS_URL); verify(identityServiceMock, times(2)).CurrentAuthentication; verify(authorizationServiceMock, times(1)).isUserAuthorized(MockProvider.EXAMPLE_USER_ID, null, DELETE, GROUP_MEMBERSHIP, MockProvider.EXAMPLE_GROUP_ID); verify(authorizationServiceMock, times(1)).isUserAuthorized(MockProvider.EXAMPLE_USER_ID, null, CREATE, GROUP_MEMBERSHIP, MockProvider.EXAMPLE_GROUP_ID); }
// group ////////////////////////////////////////////////////////////// protected internal virtual Group createGroup(IdentityService identityService, string groupId) { Group group = identityService.newGroup(groupId); identityService.saveGroup(group); return(group); }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET: //ORIGINAL LINE: @Override public boolean checkPassword(final String userId, final String password) public override bool checkPassword(string userId, string password) { // Create and Save a User //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.engine.identity.User user = super.createNewUser(userId); User user = base.createNewUser(userId); user.Password = password; base.saveUser(user); // Create and Save a Group //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String groupId = userId+"_group"; string groupId = userId + "_group"; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.engine.identity.Group group = super.createNewGroup(groupId); Group group = base.createNewGroup(groupId); group.Name = groupId; base.saveGroup(group); // Create the corresponding Membership base.createMembership(userId, groupId); return(base.checkPassword(userId, password)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") public org.camunda.bpm.engine.identity.Group build() public virtual Group build() { Group group = mock(typeof(Group)); when(group.Id).thenReturn(id_Renamed); when(group.Name).thenReturn(name_Renamed); when(group.Type).thenReturn(type_Renamed); return(group); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testGroupCreateThrowsAuthorizationException() public virtual void testGroupCreateThrowsAuthorizationException() { Group newGroup = MockProvider.createMockGroup(); string message = "exception expected"; when(identityServiceMock.newGroup(newGroup.Id)).thenThrow(new AuthorizationException(message)); given().body(GroupDto.fromGroup(newGroup)).contentType(ContentType.JSON).then().expect().statusCode(Status.FORBIDDEN.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(AuthorizationException).Name)).body("message", equalTo(message)).when().post(GROUP_CREATE_URL); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testReadOnlyGroupUpdateFails() public virtual void testReadOnlyGroupUpdateFails() { Group groupUdpdate = MockProvider.createMockGroup(); when(identityServiceMock.ReadOnly).thenReturn(true); given().pathParam("id", MockProvider.EXAMPLE_GROUP_ID).body(GroupDto.fromGroup(groupUdpdate)).contentType(ContentType.JSON).then().expect().statusCode(Status.FORBIDDEN.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(InvalidRequestException).Name)).body("message", equalTo("Identity service implementation is read-only.")).when().put(GROUP_URL); verify(identityServiceMock, never()).saveGroup(groupUdpdate); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testGetSingleGroup() public virtual void testGetSingleGroup() { Group sampleGroup = MockProvider.createMockGroup(); GroupQuery sampleGroupQuery = mock(typeof(GroupQuery)); when(identityServiceMock.createGroupQuery()).thenReturn(sampleGroupQuery); when(sampleGroupQuery.groupId(MockProvider.EXAMPLE_GROUP_ID)).thenReturn(sampleGroupQuery); when(sampleGroupQuery.singleResult()).thenReturn(sampleGroup); given().pathParam("id", MockProvider.EXAMPLE_GROUP_ID).then().expect().statusCode(Status.OK.StatusCode).body("id", equalTo(MockProvider.EXAMPLE_GROUP_ID)).body("name", equalTo(MockProvider.EXAMPLE_GROUP_NAME)).when().get(GROUP_URL); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testGroupCreate() public virtual void testGroupCreate() { Group newGroup = MockProvider.createMockGroup(); when(identityServiceMock.newGroup(MockProvider.EXAMPLE_GROUP_ID)).thenReturn(newGroup); given().body(GroupDto.fromGroup(newGroup)).contentType(ContentType.JSON).then().expect().statusCode(Status.NO_CONTENT.StatusCode).when().post(GROUP_CREATE_URL); verify(identityServiceMock).newGroup(MockProvider.EXAMPLE_GROUP_ID); verify(newGroup).Name = MockProvider.EXAMPLE_GROUP_NAME; verify(identityServiceMock).saveGroup(newGroup); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testGroupCreateExistingFails() public virtual void testGroupCreateExistingFails() { Group newGroup = MockProvider.createMockGroup(); when(identityServiceMock.newGroup(MockProvider.EXAMPLE_GROUP_ID)).thenReturn(newGroup); doThrow(new ProcessEngineException("")).when(identityServiceMock).saveGroup(newGroup); given().body(GroupDto.fromGroup(newGroup)).contentType(ContentType.JSON).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(ProcessEngineException).Name)).when().post(GROUP_CREATE_URL); verify(identityServiceMock).newGroup(MockProvider.EXAMPLE_GROUP_ID); verify(identityServiceMock).saveGroup(newGroup); }
public static HalGroup fromGroup(Group group) { HalGroup halGroup = new HalGroup(); halGroup.id = group.Id; halGroup.name = group.Name; halGroup.type = group.Type; halGroup.linker.createLink(REL_SELF, group.Id); return(halGroup); }
public virtual GroupDto getGroup(UriInfo context) { Group dbGroup = findGroupObject(); if (dbGroup == null) { throw new InvalidRequestException(Status.NOT_FOUND, "Group with id " + resourceId + " does not exist"); } GroupDto group = GroupDto.fromGroup(dbGroup); return(group); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testUpdateNonExistingGroup() public virtual void testUpdateNonExistingGroup() { Group groupUpdate = MockProvider.createMockGroupUpdate(); GroupQuery sampleGroupQuery = mock(typeof(GroupQuery)); when(identityServiceMock.createGroupQuery()).thenReturn(sampleGroupQuery); when(sampleGroupQuery.groupId("aNonExistingGroup")).thenReturn(sampleGroupQuery); // this time the query returns null when(sampleGroupQuery.singleResult()).thenReturn(null); given().pathParam("id", "aNonExistingGroup").body(GroupDto.fromGroup(groupUpdate)).contentType(ContentType.JSON).then().expect().statusCode(Status.NOT_FOUND.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(InvalidRequestException).Name)).body("message", equalTo("Group with id aNonExistingGroup does not exist")).when().put(GROUP_URL); verify(identityServiceMock, never()).saveGroup(any(typeof(Group))); }
public virtual void updateGroup(GroupDto group) { ensureNotReadOnly(); Group dbGroup = findGroupObject(); if (dbGroup == null) { throw new InvalidRequestException(Status.NOT_FOUND, "Group with id " + resourceId + " does not exist"); } group.update(dbGroup); identityService.saveGroup(dbGroup); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldLogGroupDeletion() public virtual void shouldLogGroupDeletion() { // given Group newGroup = identityService.newGroup(TEST_GROUP_ID); identityService.saveGroup(newGroup); assertEquals(0, query.count()); // when identityService.AuthenticatedUserId = "userId"; identityService.deleteGroup(newGroup.Id); identityService.clearAuthentication(); // then assertLog(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_DELETE, EntityTypes.GROUP, null, TEST_GROUP_ID); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void init() public virtual void init() { identityService = engineRule.IdentityService; authorizationService = engineRule.AuthorizationService; createTenant(TENANT_ONE); User user = identityService.newUser(USER_ID); identityService.saveUser(user); Group group = identityService.newGroup(GROUP_ID); identityService.saveGroup(group); engineRule.ProcessEngineConfiguration.AuthorizationEnabled = true; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testGroupOptimisticLockingException() public virtual void testGroupOptimisticLockingException() { Group group = identityService.newGroup("group"); identityService.saveGroup(group); Group group1 = identityService.createGroupQuery().singleResult(); Group group2 = identityService.createGroupQuery().singleResult(); group1.Name = "name one"; identityService.saveGroup(group1); thrown.expect(typeof(OptimisticLockingException)); group2.Name = "name two"; identityService.saveGroup(group2); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testGroupResourceOptionsUnauthenticated() public virtual void testGroupResourceOptionsUnauthenticated() { string fullGroupUrl = "http://localhost:" + PORT + TEST_RESOURCE_ROOT_PATH + "/group/" + MockProvider.EXAMPLE_GROUP_ID; Group sampleGroup = MockProvider.createMockGroup(); GroupQuery sampleGroupQuery = mock(typeof(GroupQuery)); when(identityServiceMock.createGroupQuery()).thenReturn(sampleGroupQuery); when(sampleGroupQuery.groupId(MockProvider.EXAMPLE_GROUP_ID)).thenReturn(sampleGroupQuery); when(sampleGroupQuery.singleResult()).thenReturn(sampleGroup); when(processEngineConfigurationMock.AuthorizationEnabled).thenReturn(true); given().pathParam("id", MockProvider.EXAMPLE_GROUP_ID).then().expect().statusCode(Status.OK.StatusCode).body("links[0].href", equalTo(fullGroupUrl)).body("links[0].method", equalTo(HttpMethod.GET)).body("links[0].rel", equalTo("self")).body("links[1].href", equalTo(fullGroupUrl)).body("links[1].method", equalTo(HttpMethod.DELETE)).body("links[1].rel", equalTo("delete")).body("links[2].href", equalTo(fullGroupUrl)).body("links[2].method", equalTo(HttpMethod.PUT)).body("links[2].rel", equalTo("update")).when().options(GROUP_URL); verify(identityServiceMock, times(2)).CurrentAuthentication; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testUpdateExistingGroup() public virtual void testUpdateExistingGroup() { Group initialGroup = MockProvider.createMockGroup(); Group groupUpdate = MockProvider.createMockGroupUpdate(); GroupQuery sampleGroupQuery = mock(typeof(GroupQuery)); when(identityServiceMock.createGroupQuery()).thenReturn(sampleGroupQuery); when(sampleGroupQuery.groupId(MockProvider.EXAMPLE_GROUP_ID)).thenReturn(sampleGroupQuery); when(sampleGroupQuery.singleResult()).thenReturn(initialGroup); given().pathParam("id", MockProvider.EXAMPLE_GROUP_ID).body(GroupDto.fromGroup(groupUpdate)).contentType(ContentType.JSON).then().expect().statusCode(Status.NO_CONTENT.StatusCode).when().put(GROUP_URL); // initial group was updated verify(initialGroup).Name = groupUpdate.Name; // and then saved verify(identityServiceMock).saveGroup(initialGroup); }
protected internal override void initializeProcessEngine() { base.initializeProcessEngine(); processEngineConfiguration = (ProcessEngineConfigurationImpl)processEngine.ProcessEngineConfiguration; processEngineConfiguration.ResourceAuthorizationProvider = new MyResourceAuthorizationProvider(); identityService = processEngineConfiguration.IdentityService; authorizationService = processEngineConfiguration.AuthorizationService; user = createUser(userId); group = createGroup(groupId); identityService.createMembership(userId, groupId); identityService.setAuthentication(userId, Arrays.asList(groupId)); processEngineConfiguration.AuthorizationEnabled = true; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testUpdateGroupThrowsAuthorizationException() public virtual void testUpdateGroupThrowsAuthorizationException() { Group initialGroup = MockProvider.createMockGroup(); Group groupUpdate = MockProvider.createMockGroupUpdate(); GroupQuery sampleGroupQuery = mock(typeof(GroupQuery)); when(identityServiceMock.createGroupQuery()).thenReturn(sampleGroupQuery); when(sampleGroupQuery.groupId(MockProvider.EXAMPLE_GROUP_ID)).thenReturn(sampleGroupQuery); when(sampleGroupQuery.singleResult()).thenReturn(initialGroup); string message = "exception expected"; doThrow(new AuthorizationException(message)).when(identityServiceMock).saveGroup(any(typeof(Group))); given().pathParam("id", MockProvider.EXAMPLE_GROUP_ID).body(GroupDto.fromGroup(groupUpdate)).contentType(ContentType.JSON).then().expect().statusCode(Status.FORBIDDEN.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(AuthorizationException).Name)).body("message", equalTo(message)).when().put(GROUP_URL); // initial group was updated verify(initialGroup).Name = groupUpdate.Name; }
public void execute(ProcessEngine engine, string scenarioName) { IdentityService identityService = engine.IdentityService; string userId = USER_ID + scenarioName; string groupid = GROUP_ID + scenarioName; // create an user User user = identityService.newUser(userId); identityService.saveUser(user); // create group Group group = identityService.newGroup(groupid); identityService.saveGroup(group); // create membership identityService.createMembership(userId, groupid); //create full authorization AuthorizationService authorizationService = engine.AuthorizationService; //authorization for process definition Authorization authProcDef = createAuthorization(authorizationService, Permissions.ALL, Resources.PROCESS_DEFINITION, userId); engine.AuthorizationService.saveAuthorization(authProcDef); //authorization for deployment Authorization authDeployment = createAuthorization(authorizationService, Permissions.ALL, Resources.DEPLOYMENT, userId); engine.AuthorizationService.saveAuthorization(authDeployment); //authorization for process instance create Authorization authProcessInstance = createAuthorization(authorizationService, Permissions.CREATE, Resources.PROCESS_INSTANCE, userId); engine.AuthorizationService.saveAuthorization(authProcessInstance); // start a process instance engine.RuntimeService.startProcessInstanceByKey(PROCESS_DEF_KEY, scenarioName); }
public void execute(ProcessEngine engine, string scenarioName) { IdentityService identityService = engine.IdentityService; // create an user string userId = "test"; User user = identityService.newUser(userId); identityService.saveUser(user); // create group string groupId = "accounting"; Group group = identityService.newGroup(groupId); identityService.saveGroup(group); // create membership identityService.createMembership("test", "accounting"); // start a process instance engine.RuntimeService.startProcessInstanceByKey("oneTaskProcess", scenarioName); }
public virtual AuthorizationEntity[] tenantMembershipCreated(Tenant tenant, Group group) { return(null); }
public virtual AuthorizationEntity[] newGroup(Group group) { return(null); }