A simple Node booking form for testing RESTful web services.
In order to run restful booker you will need to install:
- npm and node
- mongo db
From this folder you should then be able to execute:
npm install
npm start
Restful booker should then start running on localhost and you can access it from a browser.
API documentation with Swagger can be found on Swagger when the application is running.
There are some unit tests in the /tests folder. Run these tests:
npm test
In order to run the TextTest integration tests in the folder 'integration_tests' you will need to install:
- Python
- TextTest - see TextTest for instructions for your platform
- A lightweight editor like Sublime Text
You will want to configure TextTest to use the correct editor - see How to Configure Default Editor and Diff Tool
When you are developing, updating and fixing tests, you will want to do this interactively with the TextTest GUI. Start it like this:
cd integration_tests
.\start_texttest.bat
or on posix:
cd integration_tests
./start_texttest.sh
This should open the TextTest GUI. If you just want to run the tests non-interactively (eg on a build server) then you can pass the argument "-con" to just run the tests on the command line.
These tests will check the actual api against the OpenAPI specification in oas.yaml. Before you can run these tests you will need to download Specmatic. It comes in the form of a jar file so you will also need to install Java or a JRE in order to run it.
First start the application under test running:
npm start
Then run specmatic to check the api complies with the spec:
java -jar specmatic.jar test oas.yaml --testBaseURL=http://localhost:3001
In app.js you can find some validation code using OpenApiValidator that will check the API matches the spec. This code is currenly only checking the responses match the specs, not the requests. If you want to check the reqeusts too, set 'validateRequests' to true.
You can use the Swagger interface to explore the API. If you are a system administrator you will know the special Auth header that can be used for example to delete bookings:
Basic YWRtaW46cGFzc3dvcmQxMjM=
Please ensure you have the latest Docker Desktop Install, the contract test using testcontainers to spin up a MongoDB for the test
npm run contract-test