This server was generated by the swagger-codegen project. By using the OpenAPI-Spec from a remote server, you can easily generate a server stub. This is an example of building a swagger-enabled Flask server.
This example uses the Connexion library on top of Flask.
Everything is here. Just invoke the tests and enjoy the show.
./setup_MC_certs.sh
./run_VIS_unittests.sh
This example requires Python 3.5 to run the test suites
It also requires a fairly new release of OpenSSL for running TLSv1.2 that is required by STM.
After trying Raspberry Pi with Raspbian and EC2 AWS instances with AMI I finally found one good distro with all the right tools. It was Ubuntu 16.04 LTS release which will be supported for 4 years.
In order to use SSL certificates you need to add your service instance certificates in the VesselVIS directory. The code will look for the files
VesselVIS/Certificate_VIS*.pem
VesselVIS/PrivateKey_VIS*.pem
VesselVIS/mc-ca-chain.pem
As the MarineCloud certificates are self-signed you also need to set them up correctly for OpenSSL. This is done by running a script.
VesselVIS/setup_MC_certs.sh
To run the server, please execute the following from the root directory:
pip3 install -r requirements.txt
python3 -m swagger_server
and open your browser to here:
https://stm.furuno.fi:8001/ui/ -- Vessel 1
https://stm.furuno.fi:8002/ui/ -- Vessel 2
https://stm.furuno.fi:8003/ui/ -- Vessel 3
https://stm.furuno.fi:8004/ui/ -- Vessel 4
...
Your Swagger definition lives here:
https://stm.furuno.fi:8002/swagger.json
Point your web browser here to try out the services:
https://stm.furuno.fi:8002/ui/
To set up the env environment for testing, launch tox:
sudo pip3 install tox
tox
To run the integration test suite we need to launch two vessel service instances that are capable of communicating with each other
./run_VIS_unittests.sh
By peeking inside the previous script you have examples of how to run single tests.
To set the parameters up for each vessel there is now a new script:
python3 vesselconf.py
It builds a new file called vessel.conf that contains the port and host of the new service.
{"host": "127.0.0.1", "port": 8103}
You can of course just edit this file by hand also.
For security we are using a nginx front end that takes care of certificates. The content is served by this flask server. Setting up the nginx server is a separate project. If you want help in setting up nginx drop me a line.