示例#1
0
        public virtual void createInitialUser(string id, string password, string firstName, string lastName)
        {
            UserDto            user        = new UserDto();
            UserCredentialsDto credentials = new UserCredentialsDto();

            credentials.Password = password;
            user.Credentials     = credentials;
            UserProfileDto profile = new UserProfileDto();

            profile.Id        = id;
            profile.FirstName = firstName;
            profile.LastName  = lastName;
            user.Profile      = profile;

            WebResource    webResource    = client.resource(testProperties.getApplicationPath("/camunda/api/admin/setup/default/user/create"));
            ClientResponse clientResponse = webResource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).post(typeof(ClientResponse), user);

            try
            {
                if (clientResponse.ResponseStatus != Response.Status.NO_CONTENT)
                {
                    throw new WebApplicationException(clientResponse.ResponseStatus);
                }
            }
            finally
            {
                clientResponse.close();
            }
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testReadOnlyUserCreateFails()
        public virtual void testReadOnlyUserCreateFails()
        {
            User newUser = MockProvider.createMockUser();

            when(identityServiceMock.ReadOnly).thenReturn(true);

            given().body(UserDto.fromUser(newUser, true)).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().post(USER_CREATE_URL);

            verify(identityServiceMock, never()).newUser(MockProvider.EXAMPLE_USER_ID);
        }
示例#3
0
//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);
        }
示例#4
0
//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);
        }
示例#5
0
//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);
        }