Web app - adamkral12/PA165 GitHub Wiki
mvn clean install && cd Secret-agency-web && mvn spring-boot:run
application runs on http://localhost:8080/pa165/
There are 3 predefined users (agents) now. Their credentials and roles are the following:
CodeName | Password | Role |
---|---|---|
Bures | nikdyNeodstoupim | Admin |
007 | Shaken,notStirred | User |
Ovar | putin | User |
you need to login to get the session cookie
curl -X POST -F 'username=Bures' -F 'password=nikdyNeodstoupim' -D - http://localhost:8080/pa165/login --silent | grep "Set-Cookie: JSESSIONID"
this should output something like Set-Cookie: JSESSIONID=E95FD245A71BDEFAE0E9A269452557F5; Path=/pa165; HttpOnly
part JSESSIONID=E95FD245A71BDEFAE0E9A269452557F5; Path=/pa165; HttpOnly
will be referenced as {COOKIE_VALUE}
in the rest of curl commands
You need to obtain JSESSIONID to test Rest api. How to do it is described in previous section.
-
Get all departments
curl --cookie "{COOKIE_VALUE}" -i -X GET http://localhost:8080/pa165/rest/departments/
-
Get department by id
curl --cookie "{COOKIE_VALUE}" -i -X GET http://localhost:8080/pa165/rest/departments/1
-
Create department
curl --cookie "{COOKIE_VALUE}" -X POST -i -H "Content-Type: application/json" --data \ '{ "city": "Ostrava", "country": "Czech Republic","longitude": 123213.32,"latitude": 123.231,"specialization": "ASSASSINATION"}'\ http://localhost:8080/pa165/rest/departments/
-
Get all specializations
curl --cookie "{COOKIE_VALUE}" -i -X GET http://localhost:8080/pa165/rest/departments/specializations
-
Get departments by specialization
curl --cookie "{COOKIE_VALUE}" -i -X GET http://localhost:8080/pa165/rest/departments/specialization/ASSASSINATION
-
get departments by city
curl --cookie "{COOKIE_VALUE}" -i -X GET http://localhost:8080/pa165/rest/departments/city/Prague
-
get departments by country
curl --cookie "{COOKIE_VALUE}" -i -X GET http://localhost:8080/pa165/rest/departments/country/Czech%20Republic
-
get departments by area
curl --cookie "{COOKIE_VALUE}" -i -X GET http://localhost:8080/pa165/rest/departments/area/50.08804/14.4207/20
-
Get all reports
curl --cookie "{COOKIE_VALUE}" -i -X GET http://localhost:8080/pa165/rest/reports/
-
Get report by id
curl --cookie "{COOKIE_VALUE}" -i -X GET http://localhost:8080/pa165/rest/reports/report/1
-
Create report
curl --cookie "{COOKIE_VALUE}" -X POST -i -H "Content-Type: application/json" --data \ '{ "text": "This message was never written before", "missionResult": "FAILED","agentId": 1,"missionId": 1}'\ http://localhost:8080/pa165/rest/reports/
-
Update report's text
curl --cookie "{COOKIE_VALUE}" -X PUT -i -H "Content-Type: application/json" --data \ '{ "id": 1, "text": "The report I made before was full of bullshit"}'\ http://localhost:8080/pa165/rest/reports/report/{id}
-
Delete report
curl --cookie "{COOKIE_VALUE}" -i -X PUT http://localhost:8080/pa165/rest/reports/report/1
-
Approve report
curl --cookie "{COOKIE_VALUE}" -i -X PUT http://localhost:8080/pa165/rest/reports/report/1/approve/
-
Deny report
curl --cookie "{COOKIE_VALUE}" -i -X PUT http://localhost:8080/pa165/rest/reports/report/1/deny/
-
Get reports from an interval
curl --cookie "{COOKIE_VALUE}" -i -X GET http://localhost:8080/pa165/rest/reports/interval/2018-01-01/2018-12-12/
-
Get reports with mission result
curl --cookie "{COOKIE_VALUE}" -i -X GET http://localhost:8080/pa165/rest/reports/missionResult/FAILED/
-
Get reports with status
curl --cookie "{COOKIE_VALUE}" -i -X GET http://localhost:8080/pa165/rest/reports/reportStatus/NEW/
-
get all missions
curl --cookie "{COOKIE_VALUE}" -i -X GET http://localhost:8080/pa165/rest/missions
-
get mission by id
curl --cookie "{COOKIE_VALUE}" -i -X GET http://localhost:8080/pa165/rest/missions/1
-
create mission
curl --cookie "{COOKIE_VALUE}" -X POST -i -H "Content-Type: application/json" --data '{ "latitude": "23.52", "longitude": "15.22", "missionType": "SABOTAGE", "started":"2013-02-11"}' http://localhost:8080/pa165/rest/missions
-
delete mission
curl --cookie "{COOKIE_VALUE}" -i -X DELETE http://localhost:8080/pa165/rest/missions/1
cd Secret-agency-web/src/main/react/secret-agency && npm install && npm run start
the app should start on http://localhost:3000/
npm run build