REST API which stores, updates, retrieves and deletes Person entities
- Java 8
- Maven
- git
- jq (optional)
Tested in Vagrant (after (1) issue, and (2) vagrant up --provider virtualbox
).
- Clone repository
$ git clone https://github.com/flawmop/EBI01562.git
- Move to cloned repository and start
$ cd EBI01562
- Unit and integration testing
$ mvn clean verify
- (Optional
sudo yum install lynx -y
) Code coverage
$ lynx target/site/jacoco/index.html
- Start REST API.
$ mvn clean spring-boot:run
Username | Password | ROLE(S) |
---|---|---|
user | password | USER |
admin | password | USER, ADMIN |
Action | URL | ROLE | Operation |
---|---|---|---|
GET | /persons | USER | Retrieve all users |
GET | /persons/{personId} | USER | Retrieve a single user (by id) |
PATCH | /persons/{personId} | ADMIN | Modify a person's age (by id) |
POST | /persons | ADMIN | Add a new person |
PUT | /persons/{personId} | ADMIN | Update a person (by id) |
DELETE | /persons/{personId} | ADMIN | Delete a person (by id) |
curl -v -u user:password 127.0.0.1:8080/persons | jq
curl -v -u admin:password 127.0.0.1:8080/persons -H 'Content-type:application/json' \
-d '{"first_name":"fn1","last_name":"ln1","age":10,"favourite_colour":"fc1","hobby":["h1.1", "h1.2"]}' | jq
curl -v -u admin:password 127.0.0.1:8080/persons -H 'Content-type:application/json' \
-d '{"first_name":"fn2","last_name":"ln2","age":20,"favourite_colour":"fc2","hobby":["h2.1", "h2.2"]}' | jq
curl -v -u user:password 127.0.0.1:8080/persons | jq
curl -v -u user:password 127.0.0.1:8080/persons/1 | jq
curl -v -u admin:password -X PUT 127.0.0.1:8080/persons/1 -H 'Content-type:application/json' \
-d '{"first_name":"fn1.1","last_name":"ln1.1","age":11,"favourite_colour":"fc1.1","hobby":["h1.11", "h1.21"]}' | jq
curl -v -u user:password 127.0.0.1:8080/persons/1 | jq
curl -v -u admin:password -X PATCH 127.0.0.1:8080/persons/1 -H 'Content-type:application/json' \
-d '{"age":12}' | jq
curl -v -u user:password 127.0.0.1:8080/persons/1 | jq
curl -v -u admin:password -X DELETE 127.0.0.1:8080/persons/1 | jq
curl -v -u admin:password -X DELETE 127.0.0.1:8080/persons/2 | jq
curl -v -u user:password 127.0.0.1:8080/persons | jq
grep -r 'TODO' src/ | awk -F'TODO' '{print $2}'