Ce projet contient la réalisation des 7 exercices de tests d’une application Spring Boot :
- ✅ Tests unitaires
- ✅ Tests d’intégration
- ✅ Tests REST
- ✅ Tests E2E
- ✅ Tests de performance
- ✅ Analyse de sécurité SAST / DAST
Technologies principales :
- Spring Boot
- JUnit 5
- AssertJ
- Mockito
- H2 Database
- Testcontainers
- PostgreSQL
- Gatling
- OWASP ZAP
- SpotBugs
hotel-tests/
├── .idea/
├── .mvn/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/example/hotel_tests/
│ │ │ ├── demo/
│ │ │ ├── employee/
│ │ │ ├── reservation/
│ │ │ ├── security/
│ │ │ ├── HotelTestsApplication.java
│ │ │ └── InitData.java
│ │ └── resources/
│ │ └── application.properties
│ └── test/
│ └── java/
│ └── com/example/hotel_tests/
│ ├── employee/
│ ├── facturation/
│ ├── integration/
│ ├── performance/
│ ├── reservation/
│ └── HotelTestsApplicationTests.java
├── target/
├── screenshots/
├── .gitattributes
├── .gitignore
├── HELP.md
├── mvnw
├── mvnw.cmd
├── pom.xml
├── zap.yaml
├── zap-report.html
└── zap-report-after.html Tester la logique métier du service ReservationService.
- Calcul du prix total
- Séjour court / long
- Vérification des prix négatifs
- Vérification de disponibilité
- Génération du code de confirmation
JUnit 5 • AssertJ
Tester FacturationService en isolant les dépendances.
- Mock de
ClientRepository - Mock de
NotificationService - Vérification des interactions
- Gestion des exceptions
Mockito
Tester les accès aux données avec H2.
- Recherche par département
- Recherche par salaire
- Vérification des requêtes personnalisées
@DataJpaTest • H2 Database
Tester le contrôleur REST EmployeeController.
- GET Employee
- POST Employee
- Validation des entrées
- Vérification des erreurs 400
@WebMvcTest • MockMvc
Tester l’application avec une vraie base PostgreSQL.
- Création d’employé
- Récupération par ID
- Suppression d’employé
Testcontainers • PostgreSQL • Docker
Valider les performances de l’API.
- Charge normale : 30 utilisateurs
- Stress test : 200 utilisateurs
- 95e percentile < 300 ms
- Taux d’erreur < 1 %
Gatling
Détection des dépendances vulnérables :
CVE-2025-7962- Score CVSS : 7.5
SQL_INJECTION_JPAHARD_CODE_PASSWORD
- Paramètres sécurisés
- Suppression des mots de passe codés en dur
- Scan avant/après sécurisation
- Réduction des alertes de sécurité
- Ajout des headers HTTP sécurisés
| Exercice | Outils |
|---|---|
| 1 | JUnit 5, AssertJ |
| 2 | Mockito |
| 3 | @DataJpaTest, H2 |
| 4 | @WebMvcTest, MockMvc |
| 5 | Testcontainers, PostgreSQL |
| 6 | Gatling |
| 7 | OWASP DC, SpotBugs, ZAP |
./mvnw test./mvnw test -Dtest=ReservationServiceTest./mvnw dependency-check:check./mvnw spotbugs:check./mvnw gatling:testdocker run --rm -v ${PWD}:/zap/wrk \
ghcr.io/zaproxy/zaproxy:stable \
zap-baseline.py -t http://localhost:8080 -r zap-report.htmlMaster DevOps Engineering








