diff --git a/README.md b/README.md
index 61a38c4..e629d7b 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@ This project is the outcome of my self-learning about the API Testing Automation
## :hammer_and_wrench: Talking more about the Scenarios Covered in this project:
You will get the answers to the following questions and its respective working code example with [Playwright Java](https://playwright.dev/java/docs/api-testing#writing-api-test) framework in this repository:
-- How to write tests for `Get` requests?
+- How to write tests for `GET` requests?
- How to write tests for `POST` requests?
- How to write tests for `PUT` requests?
- How to write tests for `PATCH` requests?
@@ -35,12 +35,16 @@ You will get the answers to the following questions and its respective working c
- How to write end-to-end api tests?
- How to write Happy Path scenarios for the APIs?
- How to write Sad Path scenarios for the APIs?
+- How to log the Response ?
## :writing_hand: Blog Links
- [What is API Testing?](https://mfaisalkhatri.github.io/2020/08/08/apitesting/)
- [How to perform End to End API Testing using Playwright with Java and TestNG](https://medium.com/@iamfaisalkhatri/how-to-perform-end-to-end-api-testing-using-playwright-with-java-and-testng-26b318927115)
- [Playwright Java API Testing | How to test POST requests?](https://medium.com/@iamfaisalkhatri/playwright-java-api-testing-how-to-test-post-requests-4c9102d3ab03)
- [Playwright Java API Testing | How to test GET requests?](https://medium.com/@iamfaisalkhatri/playwright-java-api-testing-how-to-test-get-requests-c036b984cc6d)
+- [Playwright Java API Testing | How to test PUT requests?](https://medium.com/@iamfaisalkhatri/playwright-java-api-testing-how-to-test-put-requests-d6b1d054d64b)
+- [Playwright Java API Testing | How to test PATCH requests?](https://medium.com/@iamfaisalkhatri/playwright-java-api-testing-how-to-test-patch-requests-f6b0867d91e7)
+- [Playwright Java API Testing | How to test DELETE requests?](https://medium.com/@iamfaisalkhatri/playwright-java-api-testing-how-to-test-delete-requests-2ff77feb0383)
## :question: Need Assistance?
diff --git a/src/test/java/io/github/mfaisalkhatri/api/restfulecommerce/SadPathTests.java b/src/test/java/io/github/mfaisalkhatri/api/restfulecommerce/SadPathTests.java
index e5e2c0b..13afc85 100644
--- a/src/test/java/io/github/mfaisalkhatri/api/restfulecommerce/SadPathTests.java
+++ b/src/test/java/io/github/mfaisalkhatri/api/restfulecommerce/SadPathTests.java
@@ -5,6 +5,7 @@
import static io.github.mfaisalkhatri.api.restfulecommerce.testdata.OrderDataBuilder.getPartialUpdatedOrder;
import static io.github.mfaisalkhatri.api.restfulecommerce.testdata.OrderDataBuilder.getUpdatedOrder;
import static io.github.mfaisalkhatri.api.restfulecommerce.testdata.TokenBuilder.getCredentials;
+import static io.github.mfaisalkhatri.api.restfulecommerce.testdata.TokenBuilder.getInvalidCredentials;
import static org.testng.Assert.assertEquals;
import java.util.ArrayList;
@@ -294,6 +295,7 @@ public void testShouldNotDeleteOrder_WhenTokenIsMissing () {
@Test
public void testShouldNotDeleteOrder_WhenOrderIdIsNotFound () {
+
final APIResponse authResponse = this.request.post ("/auth", RequestOptions.create ()
.setData (getCredentials ()));
@@ -330,4 +332,32 @@ public void testShouldNotDeleteOrderWithInvalidToken () {
assertEquals (response.status (), 400);
assertEquals (responseObject.get ("message"), "Failed to authenticate token!");
}
+
+ @Test
+ public void testShouldNotGenerateToken_ForInvalidCredentials () {
+
+ final APIResponse response = this.request.post ("/auth", RequestOptions.create ()
+ .setData (getInvalidCredentials ()));
+
+ logResponse (response);
+
+ final JSONObject responseObject = new JSONObject (response.text ());
+
+ assertEquals (response.status (), 401);
+ assertEquals (responseObject.get ("message"), "Authentication Failed! Invalid username or password!");
+ }
+
+ @Test
+ public void testShouldNotGenerateToken_WhenCredentialsAreMissing () {
+
+ final APIResponse response = this.request.post ("/auth", RequestOptions.create ());
+
+ logResponse (response);
+
+ final JSONObject responseObject = new JSONObject (response.text ());
+
+ assertEquals (response.status (), 400);
+ assertEquals (responseObject.get ("message"), "Username and Password is required for authentication!");
+ }
+
}
diff --git a/src/test/java/io/github/mfaisalkhatri/api/restfulecommerce/testdata/TokenBuilder.java b/src/test/java/io/github/mfaisalkhatri/api/restfulecommerce/testdata/TokenBuilder.java
index d6c4284..4676fe9 100644
--- a/src/test/java/io/github/mfaisalkhatri/api/restfulecommerce/testdata/TokenBuilder.java
+++ b/src/test/java/io/github/mfaisalkhatri/api/restfulecommerce/testdata/TokenBuilder.java
@@ -8,4 +8,13 @@ public static TokenData getCredentials() {
.password ("secretPass123")
.build ();
}
+
+ public static TokenData getInvalidCredentials() {
+ return TokenData.builder ()
+ .username ("Manager")
+ .password ("PAssword@123")
+ .build ();
+
+
+ }
}
diff --git a/test-suite/testng-restfulecommerce.xml b/test-suite/testng-restfulecommerce.xml
index 96d9c59..4d9c1a7 100644
--- a/test-suite/testng-restfulecommerce.xml
+++ b/test-suite/testng-restfulecommerce.xml
@@ -21,6 +21,8 @@
+
+