-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
319027c
commit afc92d3
Showing
2 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
version: "2" | ||
name: Test Borrow and Return Book Handlers | ||
|
||
vars: | ||
api.url: "http://localhost:8081" | ||
|
||
steps: | ||
# Step 1: Test BorrowBook with valid data | ||
- name: Borrow a book with valid data | ||
type: http | ||
method: POST | ||
url: "{{ api.url }}/borrow-book" | ||
body: | | ||
{ | ||
"subscriber_id": 1, | ||
"book_id": 1 | ||
} | ||
assertions: | ||
- result.statuscode ShouldEqual 201 | ||
- result.bodyjson.message ShouldEqual "Book borrowed successfully" | ||
|
||
# Step 2: Test BorrowBook with already borrowed book | ||
- name: Try to borrow an already borrowed book | ||
type: http | ||
method: POST | ||
url: "{{ api.url }}/borrow-book" | ||
body: | | ||
{ | ||
"subscriber_id": 1, | ||
"book_id": 1 | ||
} | ||
assertions: | ||
- result.statuscode ShouldEqual 409 | ||
- result.body ShouldContain "Book is already borrowed" | ||
|
||
# Step 3: Test BorrowBook with missing fields | ||
- name: BorrowBook with missing fields | ||
type: http | ||
method: POST | ||
url: "{{ api.url }}/borrow-book" | ||
body: | | ||
{ | ||
"subscriber_id": 0, | ||
"book_id": 1 | ||
} | ||
assertions: | ||
- result.statuscode ShouldEqual 400 | ||
- result.body ShouldContain "Missing required fields" | ||
|
||
# Step 4: Test ReturnBorrowedBook with valid data | ||
- name: Return a borrowed book | ||
type: http | ||
method: POST | ||
url: "{{ api.url }}/return-borrowed-book" | ||
body: | | ||
{ | ||
"subscriber_id": 1, | ||
"book_id": 1 | ||
} | ||
assertions: | ||
- result.statuscode ShouldEqual 200 | ||
- result.body ShouldContain "Book returned successfully" | ||
|
||
# Step 5: Test ReturnBorrowedBook for a book not borrowed | ||
- name: Try to return a book that was not borrowed | ||
type: http | ||
method: POST | ||
url: "{{ api.url }}/return-borrowed-book" | ||
body: | | ||
{ | ||
"subscriber_id": 1, | ||
"book_id": 2 | ||
} | ||
assertions: | ||
- result.statuscode ShouldEqual 400 | ||
- result.body ShouldContain "Book is not borrowed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: User signup and login tests | ||
|
||
vars: | ||
api.url: "http://localhost:8081" | ||
mysql.url: "filip:password@(localhost:4450)/db" | ||
|
||
steps: | ||
# Step 1: Test Signup with valid data | ||
- name: Signup with valid data | ||
type: http | ||
method: POST | ||
url: "{{ api.url }}/signup" | ||
body: | | ||
{ | ||
"email": "[email protected]", | ||
"password": "password123" | ||
} | ||
assertions: | ||
- result.statuscode ShouldEqual 201 | ||
- result.bodyjson.message ShouldEqual "User registered successfully" | ||
|
||
# Step 2: Test Login with valid credentials | ||
- name: Login with valid credentials | ||
type: http | ||
method: POST | ||
url: "{{ api.url }}/login" | ||
body: | | ||
{ | ||
"email": "[email protected]", | ||
"password": "password123" | ||
} | ||
assertions: | ||
- result.statuscode ShouldEqual 200 | ||
- result.bodyjson.message ShouldEqual "User logged in successfully" | ||
- result.bodyjson.existingUserID ShouldNotBeEmpty | ||
|
||
# Step 3: Test Login with invalid credentials | ||
- name: Login with invalid credentials | ||
type: http | ||
method: POST | ||
url: "{{ api.url }}/login" | ||
body: | | ||
{ | ||
"email": "[email protected]", | ||
"password": "wrongpassword" | ||
} | ||
assertions: | ||
- result.statuscode ShouldEqual 400 | ||
- result.bodyjson.message ShouldEqual "Invalid email or password" | ||
|
||
# Step 4: Test Signup with an already registered email | ||
- name: Signup with existing email | ||
type: http | ||
method: POST | ||
url: "{{ api.url }}/signup" | ||
body: | | ||
{ | ||
"email": "[email protected]", | ||
"password": "anotherpassword" | ||
} | ||
assertions: | ||
- result.statuscode ShouldEqual 409 | ||
- result.bodyjson.message ShouldEqual "Email already in use" |