Automation Week Challenges October 2020 - Web API

All the following challenges are focused on Web API automation.

Automation Week

These challenges are part of Automation Week. Complete them for your chance to talk at Test.bash(); about your approach and experience.

Application

The application for this challenge is Restful Booker Platform. More about the application is available here. You can also ask questions related to the application there.

The Challenges:

Complete these challenges using any tooling of your choice.

Beginner:

Perform a GET request on the branding API and assert the response.

Intermediate:

Create a new Room using the Rom API and assert it was successfully created. Tip, you’ll need to also need to prove you are authenticated by calling the Auth API and saving the token!

Advanced:

Create a solution/framework that allows you to test all the APIs. You’ll need to include tests for:

  • Branding: GET, PUT
  • Room: GET, PUT, POST, DELETE
  • Booking: GET, PUT, POST, DELETE
  • Auth: POST. Login, logout, validate
  • Report: GET
  • Messaging: GET, POST,

Bonus, test that you can mark a message as read.

Questions

If you have any questions at all about this challenge, please post them below.

Quick one - is the branding request definitely a POST and not a PUT? When I try to POST to https://automationintesting.online/branding/ endpoint its giving me a 405 method not allowed error? (I am a bit of a newbie at this though so I could well be doing something wrong!)

1 Like

Hi @bethtesterleeds

You’re correct it is a PUT for branding. Richard put the wrong method in but I’ve updated it now to be correct :man_facepalming:t2:

I can’t find a GET method for the auth service, only POSTs. Can you confirm that there is no GET method supported here? Thanks!

Correct!
I’ve amended.

1 Like

I can’t figure out how to do the intermediate challenge! I have my POST request and I seemingly get a 200 response but when I do a GET, the room I tried to create isn’t in the response. I managed to get a token from the auth endpoint but I think I don’t know what I need it for. I’m clearly missing something! Is anyone able to point me in a direction to investigate without giving too much away?!

Can you show us the response that you are getting from the GET request?
HTTP code & JSON response?

Do you get an id in the response after you send a POST request and the room is created?
Can you put that id into the subsequent GET request?

so when I do an initial GET on the room endpoint (using https://automationintesting.online/room), I get this response:

{
"rooms": [
    {
        "roomid": 1,
        "roomNumber": 101,
        "type": "single",
        "accessible": true,
        "image": "https://www.mwtestconsultancy.co.uk/img/testim/room2.jpg",
        "description": "Aenean porttitor mauris sit amet lacinia molestie. In posuere accumsan aliquet. Maecenas sit amet nisl massa. Interdum et malesuada fames ac ante.",
        "features": [
            "TV",
            "WiFi",
            "Safe"
        ],
        "roomPrice": 100
    }
]

}

I’ve not really done POST requests before so I assumed that I needed to put my room information in the body. It looks like this:

{

    "roomid": 2,

    "roomNumber": 199,

            "type": "double",

            "accessible": true,

            "image": "https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.housebeautiful.com%2Froom-decorating%2Fbedrooms%2Fg648%2Fbeautiful-designer-bedrooms%2F&psig=AOvVaw1iGFx-pUXBnLX39wj7QveN&ust=1603534977935000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCIDy-7e_yuwCFQAAAAAdAAAAABAE",

            "description": "A really nice room. 3 stars",

            "features": [

                "TV",

                "WiFi",

                "Safe",

                "Snacks"

            ],

            "roomPrice": 400

        }

When I send that, the response body doesn’t seem to change from the original.

I thought maybe I needed the token I get from the auth request and use it in the authentication tab somehow but that didn’t seem to make a difference.

I apologise if this is stupid - I’ve done a lot with POSTman recently but not in a web api sense so this is all new!

Does this Swagger page help you? Pay particular attention to the parameters in the GET request.

Happy to go into more detail if you’d like! Might be good via DM so we don’t give away the solution for others.

ooh, awesome thank you. I was struggling to figure out how to access the swagger pages so I’m sure this will help!

1 Like

Given I’m testing room endpoint
When I use method POST
Then in the response logs I see a couple of times status code 301
And then 200 with the response of “roomid”:1 (irrespective of the request)
I was expecting 201
My Request:
{
“rooms”: [
{
“roomid”: 99,
“roomNumber”: 299,
“type”: “single”,
“accessible”: true,
“image”: “https://www.mwtestconsultancy.co.uk/img/testim/room2.jpg”,
“description”: “Aenean porttitor mauris sit amet lacinia molestie. In posuere accumsan aliquet. Maecenas sit amet nisl massa. Interdum et malesuada fames ac ante.”,
“features”: [
“TV”,
“WiFi”,
“Safe”
],
“roomPrice”: 299
}
]
}

Logs after performing the post
logs

Room is not an end point. The end point is ‘/’.
Try sending it to ‘https://automationintesting.online/room/’ notice the ending ‘/’

So I was having the same issue and I’ve just tried it with the / on the end and still only seem to get the first room id back. If I do room/2 for example, I get the room I created but I don’t seem to be able to bring ALL rooms back

Hey,

Here is the link to the API code @vivrichards and I demo’d in today’s TestBash:-

Please feel free to fork, improve and enjoy!

Beth

4 Likes

'ello!

Here’s the link to my repo which holds the Postman Collection and Environment JSON files. You can import these yourself into Postman so you can see some of the weird stuff I’m doing in there.

Thanks!

3 Likes

Here is a link to the code I showed during today’s Test.bash(‘Online’);!

2 Likes