diff --git a/src/test/java/org/icatproject/authn_db/AuthenticateIT.java b/src/test/java/org/icatproject/authn_db/AuthenticateIT.java index 1a35e26..455e7e7 100644 --- a/src/test/java/org/icatproject/authn_db/AuthenticateIT.java +++ b/src/test/java/org/icatproject/authn_db/AuthenticateIT.java @@ -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() { @@ -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 @@ -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")); } } diff --git a/src/test/java/org/icatproject/authn_db/IPTestsIT.java b/src/test/java/org/icatproject/authn_db/IPTestsIT.java index 4eb7327..4c33bbf 100644 --- a/src/test/java/org/icatproject/authn_db/IPTestsIT.java +++ b/src/test/java/org/icatproject/authn_db/IPTestsIT.java @@ -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")); } @@ -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")); } }