A Sample Rest API Project for Cardinity Evaluation Test
This is a sample REST API Service Cardinity Evaluation Test, has been developed in spring-boot
.
It contains spring-security
jwt-token
role-base-authentication
jpa-hibernate
Check all the endpoints from Swagger
NOTE
There are some additional endpoints which might be used for further usage.
Since this is a REST API Service, We need an external REST Client
to Test
the API endpoints
- If you want to use
Swagger
, You don't need to configure any client. - Postman Configuration
- Import postman_environment.json as Postman Environment.
- Import postman_collection.json as Postman Collection.
- Open the
pom.xml
as a Maven Project in yourIDE
- Run the command bellow in your
Terminal
mvn clean install
- Configure DB
db.url=jdbc:mysql://localhost:3306/<DB_NAME>
db.username=<DB_USERNAME>
db.password=<DB_PASSWORD>
Cardinity Users can have bellow Roles
- USER
- ADMIN
We have bellow status for the Tasks
and Projects
- Open
- In Progress
- Closed
- Run the application by executing
CardinityTaskManagerRestApiApplication.java
- Import the Postman Collection to test the
API
endpoints
POST
/authenticate- Request Body
{
"username": "dummy_user",
"password": "user"
}
- You will get a
JWT TOKEN
in Success Response which is actually aBearer
token. - Token format
Bearer {{AuthenticationToken}}
- After that, You will use this Token in
Authorization
Header of each request.
Each of the endpoints will require this Header bellow to authenticate the USER
Authorization: Bearer {{AuthenticationToken}}
-
Create Project
- Method
POST
- URL /project/create
- Request Body
{ "name": "Cardinity REST API Project", "description": "Sample project for test", "status": "open", "assignedTo": "dummy_user" }
- Method
-
Get All Projects
- Method
GET
- URL /project/get-all
- Method
-
Delete Project by
ID
- Method
GET
- URL /project/delete/{id}
- Method
-
Create Task
- Method
POST
- URL /task/create
- Request Body
{ "name": "Spring Security Integration", "description": "Spring Security Integration", "status": "open", "expiryHour": 8, "assignedTo":"dummy_user", "projectId": 1 }
- Method
-
Edit Task
- Method
POST
- URL /task/update
- Request Body
{ "taskId": 1, "name": "Spring Security Integration", "description": "Spring Security Integration", "status": "in progress", "expiryHour": 16, "assignedTo":"", "projectId": 1 }
- Method
-
GET Tasks
OWN USER TASK
- Method
GET
- URL /task/get
- Method
-
GET All
Tasks
byProject
- Method
GET
- URL /task/get-all/by-project/{projectId}
- Method
-
GET ALL
Expired
Tasks- Method
GET
- URL /task/get-all/expired
- Method
-
GET ALL Tasks by
Status
- Method
GET
- URL /task/get-by/status/{status}
- Method
Only users with ADMIN
Role can access these endpoints
-
GET ALL Tasks by
User
- Method
GET
- URL /task/get-all/by-user/{username}
- Method
-
GET ALL Projects by
User
- Method
GET
- URL /project/get-by/{username}
- Method
- Server Port Configuration
server.port=8080
- We already have a
StartupLoader
to populate the Dummy Users and Roles. Username and Password in theapplication.property
file
dummy.admin.username=dummy_admin
dummy.user.username=dummy_user
dummy.user2.username=dummy_user2
dummy.admin.password.common=admin
dummy.user.password.common=user
- Toggle
Hibernate
DDL Auto Generation bycreate
orupdate
hibernate.hbm2ddl.auto=create
- Configure Token Expiry
minute
by changing
jwt.token.expirey.minute=30
Dipanjal Maitra @linkedin - dipanjalmaitra@gmail.com