https://github.com/martincantillo/technical-test-backend-hypersoft
Technical-test backend involving Springboot , JUnit , Mockito and Mysql for db
https://github.com/martincantillo/technical-test-backend-hypersoft
junit5 jwt mockito mysql rest-api spring-boot spring-security
Last synced: 3 months ago
JSON representation
Technical-test backend involving Springboot , JUnit , Mockito and Mysql for db
- Host: GitHub
- URL: https://github.com/martincantillo/technical-test-backend-hypersoft
- Owner: MartinCantillo
- Created: 2024-10-15T17:05:10.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-10-16T20:57:50.000Z (over 1 year ago)
- Last Synced: 2025-07-28T12:44:46.314Z (12 months ago)
- Topics: junit5, jwt, mockito, mysql, rest-api, spring-boot, spring-security
- Language: Java
- Homepage:
- Size: 40 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🛠️ Backend API - Spring Boot
This project is a **backend API** developed in **Spring Boot**. It allows for user and product management with JWT authentication and specific roles.
## 🚀 Project Features
- **Authentication** with JWT.
- **User roles**: Admin, User.
- **Product CRUD**: Add, Read, Update, Delete products.
- **Database**: MySQL.
- **Spring Security** for route protection.
## 📝 API Endpoints
### 📦 Users
#### Register a user
- `POST /user/register`
- Request body:
```json
{
"username": "user",
"password": "password",
"role": "ROLE_USER" // Or ROLE_ADMIN
}
```
- **Response**: `User registered successfully`
#### Login (Generate JWT)
- `POST /user/login`
- Request body:
```json
{
"username": "user",
"password": "password"
}
```
- **Response**: JWT token
### 🛒 Products
#### Create product (Admin only)
- `POST /api/addProduct`
- Request body:
```json
{
"name": "Product A",
"price": 100.0,
"quantity": 10
}
```
- **Response**: `Product created successfully`
#### Get all products (User and Admin)
- `GET /api/getAll`
- **Response**: List of products in JSON format
#### Get product by ID (User and Admin)
- `GET /api/getById/{id}`
- **Response**: Product with the specified ID.
#### Update product (Admin only)
- `PUT /api/update/{id}`
- Request body:
```json
{
"name": "Updated Product",
"price": 200.0,
"quantity": 50
}
```
- **Response**: `Product updated successfully`
#### Delete product (Admin only)
- `DELETE /api/delete/{id}`
- **Response**: `No content` if deleted successfully.
## ⚙️ Configuration
### Database
The backend connects to a MySQL database. Make sure MySQL is installed and running.
```properties
spring.application.name=Backend
spring.datasource.url=jdbc:mysql://localhost:3306/bdcrud
spring.datasource.username=root
spring.datasource.password=your_password
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL8Dialect
spring.jpa.properties.hibernate.format_sql=true
server.port=8020