This Spring boot project shows simple CRUD operations with a REST API and CI integration with Travis CI
It also shows Authentication using Spring Security
Travis CI deploys the code to Google Cloud Platform(GCE)
I have deployed the application to http://saf.beatbox.co.ke/ with Travis for testing
-
Install Grails.Grails is used to provide the
json-views
needed to render json with HAL -
clone this repository and open it in IntelliJ
-
Open a terminal and make sure you
cd
to the project root -
Run
grails run-app
and open http://localhost:8080/
This uses Spring Security
-
POST:
/api/login
.The default credentials are{"username": "user", "password": "pass"}
.The headerAccept: application/json
-
You will get an authorization token from the above step. Pass it as a header in the following subsequent API calls
Authorization: Bearer <Access_Token>
- POST:
/api/movies
Parameters{ "name" :"Test Movie", "dateCreated" : "12/12/2018", "rating" : 3.5, "isReleased" : false }
- PUT:
api/movies/1
Parameters{ "name" :"Test Movie", "dateCreated" : "12/12/2018", "rating" : 3.5, "isReleased" : false }
- GET :
/api/movies/1
- To get all the movies: GET:
api/movies
- DELETE:
/api/movies/1
All the unit tests are under src/test
The two tests check if login is working and that a movie can be saved with the correct entities or can't otherwise.
The repository is integrated with Travis CI. The configuration file can be found at .travis.yml
Once a user commits to the master branch, Travis runs the automated tests and if they succeed it deploys it
with the deploy.sh
file.
The deploy.sh
file simply pushes the code to the server.
On the server a git post-receive
hook builds a war file and deploys it to Tomcat webapps folder.