예제 #1
0
//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);
        }
예제 #2
0
//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);
        }
예제 #3
0
//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);
        }