|
5 | 5 | 1. Maven 3.6.0
|
6 | 6 | 1. MySQL 5.7.33
|
7 | 7 |
|
8 |
| -## Build Locally. Follow the steps one after the other. |
9 |
| - 1.Download dependency |
| 8 | +## Build Locally by following the steps one after the another. |
| 9 | +1. Download project |
| 10 | +> https://github.com/ssmtariq/taskmanager-rest-api-spring-security-jpa.git |
10 | 11 |
|
11 |
| -2.Go to project directory |
| 12 | +2. Open terminal and Go to project directory |
| 13 | +> cd taskmanager-rest-api-spring-security-jpa/ |
12 | 14 |
|
13 |
| -3.Build project with test: |
14 |
| -> mvn clean package |
| 15 | +3. Build project |
| 16 | +> mvn clean install -DskipTests |
15 | 17 |
|
16 |
| -4.Build project without test: |
17 |
| -> mvn clean package -DskipTests |
| 18 | +4. Running the project with the JAR: |
| 19 | +> java -jar target/taskmanager-rest-api-spring-security-jpa-0.0.1-SNAPSHOT.jar |
18 | 20 |
|
19 |
| -5.Running the project with the JAR: |
| 21 | +## Prepare Demo |
| 22 | +##### Prepare data for local demonstration using the following curl |
| 23 | + curl --location --request GET 'http://localhost:8080/prepare/demo' \ |
| 24 | + --header 'Content-Type: application/json' \ |
| 25 | + --data-raw '' |
20 | 26 |
|
21 |
| -## GET |
22 |
| - http://localhost:8080/task |
| 27 | +The above curl will create 2 **user** (1 ADMIN and 1 USER) as below- |
| 28 | +User-1: username=admin1, password=12345, role=ADMIN |
| 29 | +User-2: username=user1, password=1234, role=USER |
| 30 | +You can generate **Authorization** header using the above credential form this [link](https://www.blitter.se/utils/basic-authentication-header-generator/) |
23 | 31 |
|
24 |
| -## GET By ID |
25 |
| - http://localhost:8080/task/1 |
| 32 | +Following headers are generated using the above credentials |
| 33 | +Header for User1(ADMIN): **Authorization: Basic YWRtaW4xOjEyMzQ1** |
| 34 | +Header for User2(USER): **Authorization: Basic dXNlcjE6MTIzNA==** |
| 35 | +Apart from this, you can import curl in **postman** and input the above authorization credentials directly. |
| 36 | +## Sample Requests |
| 37 | +#### Create Project |
| 38 | + curl --location --request POST 'http://localhost:8080/project' \ |
| 39 | + --header 'Content-Type: application/json' \ |
| 40 | + --header 'Authorization: Basic dXNlcjE6MTIzNA==' \ |
| 41 | + --data-raw '{ |
| 42 | + "name": "Add Integration Tests" |
| 43 | + }' |
26 | 44 |
|
27 |
| -## POST |
28 |
| - http://localhost:8080/task |
| 45 | +#### GET All Projects |
| 46 | + curl --location --request GET 'http://localhost:8080/projects' \ |
| 47 | + --header 'Content-Type: application/json' \ |
| 48 | + --header 'Authorization: Basic dXNlcjE6MTIzNA==' \ |
| 49 | + --data-raw '' |
29 | 50 |
|
30 |
| -# PUT |
31 |
| - http://localhost:8080/task |
| 51 | +#### Delete Project |
| 52 | + curl --location --request DELETE 'http://localhost:8080/project/109' \ |
| 53 | + --header 'Content-Type: application/json' \ |
| 54 | + --header 'Authorization: Basic dXNlcjE6MTIzNA==' \ |
| 55 | + --data-raw '' |
32 | 56 |
|
33 |
| -# DELETE |
34 |
| - http://localhost:8080/task/1 |
| 57 | +#### GET All Projects By User |
| 58 | +##### Only accessible to ADMIN users |
| 59 | + curl --location --request GET 'http://localhost:8080/projects/user/98' \ |
| 60 | + --header 'Content-Type: application/json' \ |
| 61 | + --header 'Authorization: Basic YWRtaW4xOjEyMzQ1' \ |
| 62 | + --data-raw '' |
35 | 63 |
|
36 |
| -# Requests |
| 64 | +#### Create Task |
| 65 | + curl --location --request POST 'http://localhost:8080/task' \ |
| 66 | + --header 'Content-Type: application/json' \ |
| 67 | + --header 'Authorization: Basic dXNlcjE6MTIzNA==' \ |
| 68 | + --data-raw '{ |
| 69 | + "description": "Design Data Flow Diagram", |
| 70 | + "status": "OPEN", |
| 71 | + "project": { |
| 72 | + "projectId": 100 |
| 73 | + }, |
| 74 | + "dueDate": "2021-01-31" |
| 75 | + }' |
37 | 76 |
|
| 77 | +#### Edit Task |
| 78 | + curl --location --request PUT 'http://localhost:8080/task' \ |
| 79 | + --header 'Content-Type: application/json' \ |
| 80 | + --header 'Authorization: Basic dXNlcjE6MTIzNA==' \ |
| 81 | + --data-raw '{ |
| 82 | + "taskId":102, |
| 83 | + "description": "Navigation API Sequence Diagram Design", |
| 84 | + "status": "closed", |
| 85 | + "project": { |
| 86 | + "projectId": 100 |
| 87 | + }, |
| 88 | + "dueDate": "2021-02-07" |
| 89 | + }' |
38 | 90 |
|
| 91 | +#### Get Task |
| 92 | + curl --location --request GET 'http://localhost:8080/task/101' \ |
| 93 | + --header 'Content-Type: application/json' \ |
| 94 | + --header 'Authorization: Basic dXNlcjE6MTIzNA==' \ |
| 95 | + --data-raw '' |
| 96 | + |
| 97 | +#### Get All Tasks By Project |
| 98 | + curl --location --request GET 'http://localhost:8080/tasks/project/100' \ |
| 99 | + --header 'Content-Type: application/json' \ |
| 100 | + --header 'Authorization: Basic dXNlcjE6MTIzNA==' \ |
| 101 | + --data-raw '' |
| 102 | + |
| 103 | +#### Get Expired Tasks |
| 104 | + curl --location --request GET 'http://localhost:8080/tasks/expired' \ |
| 105 | + --header 'Content-Type: application/json' \ |
| 106 | + --header 'Authorization: Basic dXNlcjE6MTIzNA==' \ |
| 107 | + --data-raw '' |
| 108 | + |
| 109 | +#### Get All Tasks By Status |
| 110 | + curl --location --request GET 'http://localhost:8080/tasks/status/open' \ |
| 111 | + --header 'Content-Type: application/json' \ |
| 112 | + --header 'Authorization: Basic dXNlcjE6MTIzNA==' \ |
| 113 | + --data-raw '' |
| 114 | + |
| 115 | +#### GET All Tasks By User |
| 116 | +##### Only accessible to ADMIN users |
| 117 | + curl --location --request GET 'http://localhost:8080/tasks/user/98' \ |
| 118 | + --header 'Content-Type: application/json' \ |
| 119 | + --header 'Authorization: Basic YWRtaW4xOjEyMzQ1' \ |
| 120 | + --data-raw '' |
| 121 | + |
| 122 | +## Additional Requests |
| 123 | +#### GET All Users |
| 124 | + curl --location --request GET 'http://localhost:8080/users' \ |
| 125 | + --header 'Content-Type: application/json' \ |
| 126 | + --header 'Authorization: Basic YWRtaW4xOjEyMzQ1' \ |
| 127 | + --data-raw '' |
0 commit comments