- Java 11
- Maven 3.6.0
- MySQL 5.7.33
- Download project
https://github.com/ssmtariq/taskmanager-rest-api-spring-security-jpa.git
- Open terminal and Go to project directory
cd taskmanager-rest-api-spring-security-jpa/
- Build project
mvn clean install -DskipTests
- Running the project with the JAR:
java -jar target/taskmanager-rest-api-spring-security-jpa-0.0.1-SNAPSHOT.jar
curl --location --request GET 'http://localhost:8080/prepare/demo' \
--header 'Content-Type: application/json' \
--data-raw ''
The above curl will create 2 user (1 ADMIN and 1 USER) as below- User-1: username=admin1, password=12345, role=ADMIN User-2: username=user1, password=1234, role=USER You can generate Authorization header using the above credential form this link
Following headers are generated using the above credentials Header for User1(ADMIN): Authorization: Basic YWRtaW4xOjEyMzQ1 Header for User2(USER): Authorization: Basic dXNlcjE6MTIzNA== Apart from this, you can import curl in postman and input the above authorization credentials directly.
curl --location --request POST 'http://localhost:8080/project' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic dXNlcjE6MTIzNA==' \
--data-raw '{
"name": "Add Integration Tests"
}'
curl --location --request GET 'http://localhost:8080/projects' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic dXNlcjE6MTIzNA==' \
--data-raw ''
curl --location --request DELETE 'http://localhost:8080/project/109' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic dXNlcjE6MTIzNA==' \
--data-raw ''
curl --location --request GET 'http://localhost:8080/projects/user/98' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic YWRtaW4xOjEyMzQ1' \
--data-raw ''
curl --location --request POST 'http://localhost:8080/task' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic dXNlcjE6MTIzNA==' \
--data-raw '{
"description": "Design Data Flow Diagram",
"status": "OPEN",
"project": {
"projectId": 100
},
"dueDate": "2021-01-31"
}'
curl --location --request PUT 'http://localhost:8080/task' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic dXNlcjE6MTIzNA==' \
--data-raw '{
"taskId":102,
"description": "Navigation API Sequence Diagram Design",
"status": "closed",
"project": {
"projectId": 100
},
"dueDate": "2021-02-07"
}'
curl --location --request GET 'http://localhost:8080/task/101' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic dXNlcjE6MTIzNA==' \
--data-raw ''
curl --location --request GET 'http://localhost:8080/tasks/project/100' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic dXNlcjE6MTIzNA==' \
--data-raw ''
curl --location --request GET 'http://localhost:8080/tasks/expired' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic dXNlcjE6MTIzNA==' \
--data-raw ''
curl --location --request GET 'http://localhost:8080/tasks/status/open' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic dXNlcjE6MTIzNA==' \
--data-raw ''
curl --location --request GET 'http://localhost:8080/tasks/user/98' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic YWRtaW4xOjEyMzQ1' \
--data-raw ''
curl --location --request GET 'http://localhost:8080/users' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic YWRtaW4xOjEyMzQ1' \
--data-raw ''