//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReturn404WhenChangingPasswordIfNotAuthenticated() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReturn404WhenChangingPasswordIfNotAuthenticated() { // Given when(_request.UserPrincipal).thenReturn(null); OutputFormat outputFormat = new EntityOutputFormat(new JsonFormat(), new URI("http://www.example.com"), null); UserService userService = new UserService(mock(typeof(BasicAuthManager)), new JsonFormat(), outputFormat); // When Response response = userService.SetPassword("neo4j", _request, "{ \"password\" : \"test\" }"); // Then assertThat(response.Status, equalTo(404)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReturn404WhenRequestingUserIfDifferentUser() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReturn404WhenRequestingUserIfDifferentUser() { // Given when(_request.UserPrincipal).thenReturn(Neo4jPrinciple); OutputFormat outputFormat = new EntityOutputFormat(new JsonFormat(), new URI("http://www.example.com"), null); UserService userService = new UserService(mock(typeof(BasicAuthManager)), new JsonFormat(), outputFormat); // When Response response = userService.GetUser("fred", _request); // Then assertThat(response.Status, equalTo(404)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReturn404WhenRequestingUserIfNotAuthenticated() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReturn404WhenRequestingUserIfNotAuthenticated() { // Given when(_request.UserPrincipal).thenReturn(null); OutputFormat outputFormat = new EntityOutputFormat(new JsonFormat(), new URI("http://www.example.com"), null); UserService userService = new UserService(UserManagerSupplier, new JsonFormat(), outputFormat); // When Response response = userService.GetUser("neo4j", _request); // Then assertThat(response.Status, equalTo(404)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldChangePasswordAndReturnSuccess() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldChangePasswordAndReturnSuccess() { // Given when(_request.UserPrincipal).thenReturn(Neo4jPrinciple); OutputFormat outputFormat = new EntityOutputFormat(new JsonFormat(), new URI("http://www.example.com"), null); UserService userService = new UserService(UserManagerSupplier, new JsonFormat(), outputFormat); // When Response response = userService.SetPassword("neo4j", _request, "{ \"password\" : \"test\" }"); // Then assertThat(response.Status, equalTo(200)); UserManagerSupplier.UserManager.getUser("neo4j").credentials().matchesPassword("test"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReturn422WhenChangingPasswordIfUnknownUser() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReturn422WhenChangingPasswordIfUnknownUser() { // Given when(_request.UserPrincipal).thenReturn(Neo4jPrinciple); OutputFormat outputFormat = new EntityOutputFormat(new JsonFormat(), new URI("http://www.example.com"), null); UserService userService = new UserService(UserManagerSupplier, new JsonFormat(), outputFormat); UserRepository.delete(Neo4jUser); // When Response response = userService.SetPassword("neo4j", _request, "{ \"password\" : \"test\" }"); // Then assertThat(response.Status, equalTo(422)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReturn404WhenChangingPasswordIfDifferentUser() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReturn404WhenChangingPasswordIfDifferentUser() { // Given when(_request.UserPrincipal).thenReturn(Neo4jPrinciple); UserManager userManager = mock(typeof(UserManager)); OutputFormat outputFormat = new EntityOutputFormat(new JsonFormat(), new URI("http://www.example.com"), null); UserService userService = new UserService(UserManagerSupplier, new JsonFormat(), outputFormat); // When Response response = userService.SetPassword("fred", _request, "{ \"password\" : \"test\" }"); // Then assertThat(response.Status, equalTo(404)); verifyZeroInteractions(userManager); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReturn400IfPayloadIsInvalid() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReturn400IfPayloadIsInvalid() { // Given when(_request.UserPrincipal).thenReturn(Neo4jPrinciple); OutputFormat outputFormat = new EntityOutputFormat(new JsonFormat(), new URI("http://www.example.com"), null); UserService userService = new UserService(mock(typeof(BasicAuthManager)), new JsonFormat(), outputFormat); // When Response response = userService.SetPassword("neo4j", _request, "xxx"); // Then assertThat(response.Status, equalTo(400)); string json = StringHelper.NewString(( sbyte[] )response.Entity); assertNotNull(json); assertThat(json, containsString("\"code\" : \"Neo.ClientError.Request.InvalidFormat\"")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReturn422IfPasswordIdentical() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReturn422IfPasswordIdentical() { // Given when(_request.UserPrincipal).thenReturn(Neo4jPrinciple); OutputFormat outputFormat = new EntityOutputFormat(new JsonFormat(), new URI("http://www.example.com"), null); UserService userService = new UserService(UserManagerSupplier, new JsonFormat(), outputFormat); // When Response response = userService.SetPassword("neo4j", _request, "{ \"password\" : \"neo4j\" }"); // Then assertThat(response.Status, equalTo(422)); string json = StringHelper.NewString(( sbyte[] )response.Entity); assertNotNull(json); assertThat(json, containsString("\"code\" : \"Neo.ClientError.General.InvalidArguments\"")); assertThat(json, containsString("\"message\" : \"Old password and new password cannot be the same.\"")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReturnValidUserRepresentation() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReturnValidUserRepresentation() { // Given when(_request.UserPrincipal).thenReturn(Neo4jPrinciple); OutputFormat outputFormat = new EntityOutputFormat(new JsonFormat(), new URI("http://www.example.com"), null); UserService userService = new UserService(UserManagerSupplier, new JsonFormat(), outputFormat); // When Response response = userService.GetUser("neo4j", _request); // Then assertThat(response.Status, equalTo(200)); string json = StringHelper.NewString(( sbyte[] )response.Entity); assertNotNull(json); assertThat(json, containsString("\"username\" : \"neo4j\"")); assertThat(json, containsString("\"password_change\" : \"http://www.example.com/user/neo4j/password\"")); assertThat(json, containsString("\"password_change_required\" : true")); }