Skip to content

Commit

Permalink
Adjusted comments
Browse files Browse the repository at this point in the history
  • Loading branch information
moonraker595 committed Sep 5, 2024
1 parent e61e0f2 commit 76b3f94
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
18 changes: 9 additions & 9 deletions src/test/java/org/icatproject/authn_db/AuthenticateIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public void testValidLoginUser() {
.when()
.post("/authn.db/authenticate")
.then()
.statusCode(Response.Status.OK.getStatusCode()) // Expect a 200 OK status
.body("username", equalTo("user1")) // Validate the response body
.body("mechanism", equalTo("db")); // Validate the response body
.statusCode(Response.Status.OK.getStatusCode())
.body("username", equalTo("user1"))
.body("mechanism", equalTo("db"));
}
@Test
public void testInvalidUsername() {
Expand All @@ -34,9 +34,9 @@ public void testInvalidUsername() {
.header("Content-Type", "application/x-www-form-urlencoded") // Set Content-Type for form-urlencoded
.formParam("json", jsonString) // Send the JSON string as a form parameter with the key 'json'
.when()
.post("/authn.db/authenticate") // Ensure the path is correct
.post("/authn.db/authenticate")
.then()
.statusCode(Response.Status.FORBIDDEN.getStatusCode()) // Expect 403 Forbidden
.statusCode(Response.Status.FORBIDDEN.getStatusCode())
.body("message", equalTo("The username and password do not match"));
}
@Test
Expand All @@ -45,12 +45,12 @@ public void testInvalidPassword() {

// Perform an HTTP POST with invalid password, sending the JSON as a form parameter
given()
.header("Content-Type", "application/x-www-form-urlencoded") // Set Content-Type for form-urlencoded
.formParam("json", jsonString) // Send the JSON string as a form parameter with the key 'json'
.header("Content-Type", "application/x-www-form-urlencoded")
.formParam("json", jsonString)
.when()
.post("/authn.db/authenticate") // Ensure the path is correct
.post("/authn.db/authenticate")
.then()
.statusCode(Response.Status.FORBIDDEN.getStatusCode()) // Expect 403 Forbidden
.statusCode(Response.Status.FORBIDDEN.getStatusCode())
.body("message", equalTo("The username and password do not match"));
}
}
14 changes: 7 additions & 7 deletions src/test/java/org/icatproject/authn_db/IPTestsIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public void badIpInRequest() {

// Perform an HTTP POST request with a bad IP address
given()
.header("Content-Type", "application/x-www-form-urlencoded") // Set Content-Type for form-urlencoded
.formParam("json", jsonString) // Send the JSON string as a form parameter with the key 'json'
.header("Content-Type", "application/x-www-form-urlencoded")
.formParam("json", jsonString)
.when()
.post("/authn.db/authenticate")
.then()
.statusCode(Response.Status.FORBIDDEN.getStatusCode()) // Expect 403 Forbidden
.statusCode(Response.Status.FORBIDDEN.getStatusCode())
.body("message", equalTo("authn_db does not allow log in from your IP address 192.167.0.125"));
}

Expand All @@ -48,14 +48,14 @@ public void goodIpInRequest() {

// Perform an HTTP POST request with a valid IP address
given()
.header("Content-Type", "application/x-www-form-urlencoded") // Set Content-Type for form-urlencoded
.formParam("json", jsonString) // Send the JSON string as a form parameter with the key 'json'
.header("Content-Type", "application/x-www-form-urlencoded")
.formParam("json", jsonString)
.when()
.post("/authn.db/authenticate")
.then()
.statusCode(Response.Status.OK.getStatusCode()) // Expect 200 OK
.statusCode(Response.Status.OK.getStatusCode())
.body("username", equalTo("user1"))
.body("mechanism", equalTo("db")); // Adjust this based on your actual mechanism
.body("mechanism", equalTo("db"));
}

}

0 comments on commit 76b3f94

Please sign in to comment.