//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldParseHappyPath() public virtual void ShouldParseHappyPath() { // Given string username = "******"; string password = "******"; string header = HTTP.basicAuthHeader(username, password); // When string[] parsed = decode(header); // Then assertEquals(username, parsed[0]); assertEquals(password, parsed[1]); }
public virtual void IncorrectAuthentication() { // Given StartServerWithConfiguredUser(); // Document RESTRequestGenerator.ResponseEntity response = Gen.get().expectedStatus(401).withHeader(HttpHeaders.AUTHORIZATION, HTTP.basicAuthHeader("neo4j", "incorrect")).expectedHeader("WWW-Authenticate", "Basic realm=\"Neo4j\"").post(DataURL()); // Then JsonNode data = JsonHelper.jsonNode(response.Entity()); JsonNode firstError = data.get("errors").get(0); assertThat(firstError.get("code").asText(), equalTo("Neo.ClientError.Security.Unauthorized")); assertThat(firstError.get("message").asText(), equalTo("Invalid username or password.")); }
public virtual void SuccessfulAuthentication() { // Given StartServerWithConfiguredUser(); // Document RESTRequestGenerator.ResponseEntity response = Gen.get().expectedStatus(200).withHeader(HttpHeaders.AUTHORIZATION, HTTP.basicAuthHeader("neo4j", "secret")).get(UserURL("neo4j")); // Then JsonNode data = JsonHelper.jsonNode(response.Entity()); assertThat(data.get("username").asText(), equalTo("neo4j")); assertThat(data.get("password_change_required").asBoolean(), equalTo(false)); assertThat(data.get("password_change").asText(), equalTo(PasswordURL("neo4j"))); }
public virtual void PasswordChangeRequired() { // Given StartServer(true); // Document RESTRequestGenerator.ResponseEntity response = Gen.get().expectedStatus(403).withHeader(HttpHeaders.AUTHORIZATION, HTTP.basicAuthHeader("neo4j", "neo4j")).get(DataURL()); // Then JsonNode data = JsonHelper.jsonNode(response.Entity()); JsonNode firstError = data.get("errors").get(0); assertThat(firstError.get("code").asText(), equalTo("Neo.ClientError.Security.Forbidden")); assertThat(firstError.get("message").asText(), equalTo("User is required to change their password.")); assertThat(data.get("password_change").asText(), equalTo(PasswordURL("neo4j"))); }