//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testUserCreateThrowsAuthorizationException() public virtual void testUserCreateThrowsAuthorizationException() { User newUser = MockProvider.createMockUser(); string message = "exception expected"; when(identityServiceMock.newUser(MockProvider.EXAMPLE_USER_ID)).thenThrow(new AuthorizationException(message)); UserDto userDto = UserDto.fromUser(newUser, true); given().body(userDto).contentType(ContentType.JSON).then().statusCode(Status.FORBIDDEN.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(AuthorizationException).Name)).body("message", equalTo(message)).when().post(USER_CREATE_URL); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testGetSingleUserProfile() public virtual void testGetSingleUserProfile() { User sampleUser = MockProvider.createMockUser(); UserQuery sampleUserQuery = mock(typeof(UserQuery)); when(identityServiceMock.createUserQuery()).thenReturn(sampleUserQuery); when(sampleUserQuery.userId(MockProvider.EXAMPLE_USER_ID)).thenReturn(sampleUserQuery); when(sampleUserQuery.singleResult()).thenReturn(sampleUser); given().pathParam("id", MockProvider.EXAMPLE_USER_ID).then().statusCode(Status.OK.StatusCode).body("id", equalTo(MockProvider.EXAMPLE_USER_ID)).body("firstName", equalTo(MockProvider.EXAMPLE_USER_FIRST_NAME)).body("lastName", equalTo(MockProvider.EXAMPLE_USER_LAST_NAME)).body("email", equalTo(MockProvider.EXAMPLE_USER_EMAIL)).when().get(USER_PROFILE_URL); }
//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.User build() public virtual User build() { User user = mock(typeof(User)); when(user.Id).thenReturn(id_Renamed); when(user.FirstName).thenReturn(firstName_Renamed); when(user.LastName).thenReturn(lastName_Renamed); when(user.Email).thenReturn(email_Renamed); when(user.Password).thenReturn(password_Renamed); return(user); }
// transformers ////////////////////////////////// public static UserDto fromUser(User user, bool isIncludeCredentials) { UserDto userDto = new UserDto(); userDto.Profile = UserProfileDto.fromUser(user); if (isIncludeCredentials) { userDto.Credentials = UserCredentialsDto.fromUser(user); } return(userDto); }
public void execute(ProcessEngine engine, string scenarioName) { // given IdentityService identityService = engine.IdentityService; User user = identityService.newUser(USER_NAME); user.Password = USER_PWD; // when identityService.saveUser(user); }
public virtual UserProfileDto getUserProfile(UriInfo context) { User dbUser = findUserObject(); if (dbUser == null) { throw new InvalidRequestException(Status.NOT_FOUND, "User with id " + resourceId + " does not exist"); } UserProfileDto user = UserProfileDto.fromUser(dbUser); return(user); }
public void execute(ProcessEngine processEngine, string s) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.engine.IdentityService identityService = processEngine.getIdentityService(); IdentityService identityService = processEngine.IdentityService; User user = identityService.newUser(USER_ID); user.Password = PASSWORD; identityService.saveUser(user); ((ProcessEngineConfigurationImpl)processEngine.ProcessEngineConfiguration).CommandExecutorTxRequired.execute(new CommandAnonymousInnerClass(this, identityService)); }
public static HalUser fromUser(User user) { HalUser halUser = new HalUser(); halUser.id = user.Id; halUser.firstName = user.FirstName; halUser.lastName = user.LastName; halUser.email = user.Email; halUser.linker.createLink(REL_SELF, user.Id); return(halUser); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testUserCreateExistingFails() public virtual void testUserCreateExistingFails() { User newUser = MockProvider.createMockUser(); when(identityServiceMock.newUser(MockProvider.EXAMPLE_USER_ID)).thenReturn(newUser); doThrow(new ProcessEngineException("")).when(identityServiceMock).saveUser(newUser); UserDto userDto = UserDto.fromUser(newUser, true); given().body(userDto).contentType(ContentType.JSON).then().statusCode(Status.INTERNAL_SERVER_ERROR.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(ProcessEngineException).Name)).when().post(USER_CREATE_URL); verify(identityServiceMock).newUser(MockProvider.EXAMPLE_USER_ID); verify(identityServiceMock).saveUser(newUser); }
public virtual void updateProfile(UserProfileDto profile) { ensureNotReadOnly(); User dbUser = findUserObject(); if (dbUser == null) { throw new InvalidRequestException(Status.NOT_FOUND, "User with id " + resourceId + " does not exist"); } profile.update(dbUser); identityService.saveUser(dbUser); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldLogUserDeletion() public virtual void shouldLogUserDeletion() { // given User newUser = identityService.newUser(TEST_USER_ID); identityService.saveUser(newUser); assertEquals(0, query.count()); // when identityService.AuthenticatedUserId = "userId"; identityService.deleteUser(newUser.Id); identityService.clearAuthentication(); // then assertLog(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_DELETE, EntityTypes.USER, null, TEST_USER_ID); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testCreateNewUserWithCredentials() public virtual void testCreateNewUserWithCredentials() { User newUser = MockProvider.createMockUser(); when(identityServiceMock.newUser(MockProvider.EXAMPLE_USER_ID)).thenReturn(newUser); UserDto userDto = UserDto.fromUser(newUser, true); given().body(userDto).contentType(ContentType.JSON).expect().statusCode(Status.NO_CONTENT.StatusCode).when().post(USER_CREATE_URL); verify(identityServiceMock).newUser(MockProvider.EXAMPLE_USER_ID); verify(newUser).FirstName = MockProvider.EXAMPLE_USER_FIRST_NAME; verify(newUser).LastName = MockProvider.EXAMPLE_USER_LAST_NAME; verify(newUser).Email = MockProvider.EXAMPLE_USER_EMAIL; verify(newUser).Password = MockProvider.EXAMPLE_USER_PASSWORD; verify(identityServiceMock).saveUser(newUser); }
//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 testPutProfileNonexistingFails() public virtual void testPutProfileNonexistingFails() { User userUpdate = MockProvider.createMockUserUpdate(); UserQuery sampleUserQuery = mock(typeof(UserQuery)); when(identityServiceMock.createUserQuery()).thenReturn(sampleUserQuery); when(sampleUserQuery.userId("aNonExistingUser")).thenReturn(sampleUserQuery); when(sampleUserQuery.singleResult()).thenReturn(null); UserProfileDto updateDto = UserProfileDto.fromUser(userUpdate); given().pathParam("id", "aNonExistingUser").body(updateDto).contentType(ContentType.JSON).then().then().expect().statusCode(Status.NOT_FOUND.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(InvalidRequestException).Name)).body("message", equalTo("User with id aNonExistingUser does not exist")).when().put(USER_PROFILE_URL); // nothing was saved verify(identityServiceMock, never()).saveUser(any(typeof(User))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testUserOptimisticLockingException() public virtual void testUserOptimisticLockingException() { User user = identityService.newUser("kermit"); identityService.saveUser(user); User user1 = identityService.createUserQuery().singleResult(); User user2 = identityService.createUserQuery().singleResult(); user1.FirstName = "name one"; identityService.saveUser(user1); thrown.expect(typeof(OptimisticLockingException)); user2.FirstName = "name two"; identityService.saveUser(user2); }
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 testUserResourceOptionsUnauthenticated() public virtual void testUserResourceOptionsUnauthenticated() { string fullUserUrl = "http://localhost:" + PORT + TEST_RESOURCE_ROOT_PATH + "/user/" + MockProvider.EXAMPLE_USER_ID; User sampleUser = MockProvider.createMockUser(); UserQuery sampleUserQuery = mock(typeof(UserQuery)); when(identityServiceMock.createUserQuery()).thenReturn(sampleUserQuery); when(sampleUserQuery.userId(MockProvider.EXAMPLE_USER_ID)).thenReturn(sampleUserQuery); when(sampleUserQuery.singleResult()).thenReturn(sampleUser); when(identityServiceMock.CurrentAuthentication).thenReturn(null); when(processEngineConfigurationMock.AuthorizationEnabled).thenReturn(true); given().pathParam("id", MockProvider.EXAMPLE_USER_ID).then().statusCode(Status.OK.StatusCode).body("links[0].href", equalTo(fullUserUrl + "/profile")).body("links[0].method", equalTo(HttpMethod.GET)).body("links[0].rel", equalTo("self")).body("links[1].href", equalTo(fullUserUrl)).body("links[1].method", equalTo(HttpMethod.DELETE)).body("links[1].rel", equalTo("delete")).body("links[2].href", equalTo(fullUserUrl + "/profile")).body("links[2].method", equalTo(HttpMethod.PUT)).body("links[2].rel", equalTo("update")).when().options(USER_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 shouldLogUserUnlock() public virtual void shouldLogUserUnlock() { // given User newUser = identityService.newUser(TEST_USER_ID); newUser.Password = "******"; identityService.saveUser(newUser); identityService.checkPassword(TEST_USER_ID, "wrong!"); assertEquals(0, query.count()); // when identityService.AuthenticatedUserId = "userId"; identityService.unlockUser(TEST_USER_ID); identityService.clearAuthentication(); // then assertLog(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.OPERATION_TYPE_UNLOCK, EntityTypes.USER, null, TEST_USER_ID); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testPutCredentialsThrowsAuthorizationException() public virtual void testPutCredentialsThrowsAuthorizationException() { User initialUser = MockProvider.createMockUser(); UserQuery sampleUserQuery = mock(typeof(UserQuery)); when(identityServiceMock.createUserQuery()).thenReturn(sampleUserQuery); when(sampleUserQuery.userId(MockProvider.EXAMPLE_USER_ID)).thenReturn(sampleUserQuery); when(sampleUserQuery.singleResult()).thenReturn(initialUser); string message = "exception expected"; doThrow(new AuthorizationException(message)).when(identityServiceMock).saveUser(any(typeof(User))); UserCredentialsDto dto = new UserCredentialsDto(); dto.Password = "******"; given().pathParam("id", MockProvider.EXAMPLE_USER_ID).body(dto).contentType(ContentType.JSON).then().statusCode(Status.FORBIDDEN.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(AuthorizationException).Name)).body("message", equalTo(message)).when().put(USER_CREDENTIALS_URL); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testPutProfileThrowsAuthorizationException() public virtual void testPutProfileThrowsAuthorizationException() { User initialUser = MockProvider.createMockUser(); User userUpdate = MockProvider.createMockUserUpdate(); UserQuery sampleUserQuery = mock(typeof(UserQuery)); when(identityServiceMock.createUserQuery()).thenReturn(sampleUserQuery); when(sampleUserQuery.userId(MockProvider.EXAMPLE_USER_ID)).thenReturn(sampleUserQuery); when(sampleUserQuery.singleResult()).thenReturn(initialUser); string message = "exception expected"; doThrow(new AuthorizationException(message)).when(identityServiceMock).saveUser(any(typeof(User))); UserProfileDto updateDto = UserProfileDto.fromUser(userUpdate); given().pathParam("id", MockProvider.EXAMPLE_USER_ID).body(updateDto).contentType(ContentType.JSON).then().statusCode(Status.FORBIDDEN.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(AuthorizationException).Name)).body("message", equalTo(message)).when().put(USER_PROFILE_URL); }
// user //////////////////////////////////////////////////////////////// protected internal virtual User createUser(string userId) { User user = identityService.newUser(userId); identityService.saveUser(user); // give user all permission to manipulate authorizations Authorization authorization = createGrantAuthorization(AUTHORIZATION, ANY); authorization.UserId = userId; authorization.addPermission(ALL); saveAuthorization(authorization); // give user all permission to manipulate users authorization = createGrantAuthorization(USER, ANY); authorization.UserId = userId; authorization.addPermission(Permissions.ALL); saveAuthorization(authorization); return(user); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testPutCredentials() public virtual void testPutCredentials() { User initialUser = MockProvider.createMockUser(); UserQuery sampleUserQuery = mock(typeof(UserQuery)); when(identityServiceMock.createUserQuery()).thenReturn(sampleUserQuery); when(sampleUserQuery.userId(MockProvider.EXAMPLE_USER_ID)).thenReturn(sampleUserQuery); when(sampleUserQuery.singleResult()).thenReturn(initialUser); UserCredentialsDto dto = new UserCredentialsDto(); dto.Password = "******"; given().pathParam("id", MockProvider.EXAMPLE_USER_ID).body(dto).contentType(ContentType.JSON).then().statusCode(Status.NO_CONTENT.StatusCode).when().put(USER_CREDENTIALS_URL); // password was updated verify(initialUser).Password = dto.Password; // and then saved verify(identityServiceMock).saveUser(initialUser); }
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); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testChangeCredentialsWithWrongAuthenticatedUserPassword() public virtual void testChangeCredentialsWithWrongAuthenticatedUserPassword() { User initialUser = MockProvider.createMockUser(); UserQuery sampleUserQuery = mock(typeof(UserQuery)); when(identityServiceMock.createUserQuery()).thenReturn(sampleUserQuery); when(sampleUserQuery.userId(MockProvider.EXAMPLE_USER_ID)).thenReturn(sampleUserQuery); when(sampleUserQuery.singleResult()).thenReturn(initialUser); Authentication authentication = MockProvider.createMockAuthentication(); when(identityServiceMock.CurrentAuthentication).thenReturn(authentication); when(identityServiceMock.checkPassword(MockProvider.EXAMPLE_USER_ID, MockProvider.EXAMPLE_USER_PASSWORD)).thenReturn(false); UserCredentialsDto dto = new UserCredentialsDto(); dto.Password = "******"; dto.AuthenticatedUserPassword = MockProvider.EXAMPLE_USER_PASSWORD; given().pathParam("id", MockProvider.EXAMPLE_USER_ID).contentType(ContentType.JSON).body(dto).then().statusCode(Status.BAD_REQUEST.StatusCode).contentType(ContentType.JSON).body("type", equalTo("InvalidRequestException")).body("message", equalTo("The given authenticated user password is not valid.")).when().put(USER_CREDENTIALS_URL); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testPutProfile() public virtual void testPutProfile() { User initialUser = MockProvider.createMockUser(); User userUpdate = MockProvider.createMockUserUpdate(); UserQuery sampleUserQuery = mock(typeof(UserQuery)); when(identityServiceMock.createUserQuery()).thenReturn(sampleUserQuery); when(sampleUserQuery.userId(MockProvider.EXAMPLE_USER_ID)).thenReturn(sampleUserQuery); when(sampleUserQuery.singleResult()).thenReturn(initialUser); UserProfileDto updateDto = UserProfileDto.fromUser(userUpdate); given().pathParam("id", MockProvider.EXAMPLE_USER_ID).body(updateDto).contentType(ContentType.JSON).then().statusCode(Status.NO_CONTENT.StatusCode).when().put(USER_PROFILE_URL); // password was updated verify(initialUser).Email = updateDto.Email; verify(initialUser).FirstName = updateDto.FirstName; verify(initialUser).LastName = updateDto.LastName; // and then saved verify(identityServiceMock).saveUser(initialUser); }
public virtual AuthorizationEntity[] newUser(User user) { return(null); }
public virtual AuthorizationEntity[] tenantMembershipCreated(Tenant tenant, User user) { return(null); }