Code Monkey home page Code Monkey logo

restful-booker's Introduction

restful-booker

A simple Node booking form for testing RESTful web services.

Installation

In order to run restful booker you will need to install:

  1. npm and node
  2. 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.

Swagger documentation

API documentation with Swagger can be found on Swagger when the application is running.

Unit Tests

There are some unit tests in the /tests folder. Run these tests:

npm test

Integration tests with TextTest

In order to run the TextTest integration tests in the folder 'integration_tests' you will need to install:

  1. Python
  2. TextTest - see TextTest for instructions for your platform
  3. 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.

API tests with Specmatic

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

OpenAPI validator code

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.

Exploratory testing

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=

Running Specmatic Contract Tests

Pre-requisites

Please ensure you have the latest Docker Desktop Install, the contract test using testcontainers to spin up a MongoDB for the test

Running tests

npm run contract-test

restful-booker's People

Contributors

mwinteringham avatar emilybache avatar harikrishnan83 avatar joelrosario avatar dependabot[bot] avatar thywen avatar sheymouse avatar gjb1002 avatar ham1 avatar vidhya-manojkumar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.