- Library : Rest Assured
- Framwork : BDD, Cucumber, Page Object Model
- Language : JAVA
- IDE: Eclipse
- API : Pocketbase
Steps :
- Create a collection in Pocketbase – Books
Create some fields like these
{
“id”:”test123″,
“bookname”: “Algorithms”,
“price”:100,
“sellername”:”local”
“sold”: false
}
2. Now go to edit collection>API rules>>>Here you can edit the behaviour of the api.
Now, I want this api to create a record, only when they are authorised user.
So I set this in the create rule>> @request.auth.id != “”
Save changes.
3. Steps for Pocketbase:
So in pocketbase I have setup a users collection. Where I’ll see Auth with password.
Steps for rest assured
I need to use the JWT token to create any record in the books collection.
- Make a post call to(api/collections/users/auth-with-password) and get the token
- Use> jsonPath().getString(“token”) > to get the value of the token field
- Now make a post call to > api/collections/books/records
- In headers give the token value >> header(“Authorization”,”Bearer “+ jwttokenValue)
Now go to edit collection>API rules>>>Here you can edit the behaviour of the api.
Now, I want this api to create a record, only when they are authorised user.
So I set this in the create rule>> @request.auth.id != “”
Save changes.
Steps for pocketable:
So in pocketbase I have setup a users collection. Where I’ll see Auth with password.
Steps for rest assured
I need to use the JWT token to create any record in the books collection.
- Make a post call to(api/collections/users/auth-with-password) and get the token
- Use> jsonPath().getString(“token”) > to get the value of the token field
- Now make a post call to > api/collections/books/records
• 4. In headers give the token value >> header(“Authorization”,”Bearer “+ jwttokenValue)