98 lines
1.9 KiB
Markdown
98 lines
1.9 KiB
Markdown
# Tests PKI API
|
|
|
|
Scripts de test pour vérifier les fonctionnalités de l'API PKI.
|
|
|
|
## Prérequis
|
|
|
|
- Docker Compose en cours d'exécution (API + MongoDB)
|
|
- `jq` et `curl` installés
|
|
- La stack accessible sur `http://localhost:8080`
|
|
|
|
## Scripts disponibles
|
|
|
|
### test_complete.sh
|
|
Test complet end-to-end de toutes les fonctionnalités:
|
|
- Création de Root CA
|
|
- Création de Sub-CA
|
|
- Création de certificat standard
|
|
- Exports (PEM, DER, avec clé privée, chaîne)
|
|
- Révocation de certificat
|
|
- Génération de CRL
|
|
- Vérification du stockage MongoDB
|
|
|
|
```bash
|
|
./test_complete.sh
|
|
```
|
|
|
|
### test_exports.sh
|
|
Test spécifique des formats d'export de certificats:
|
|
- PEM
|
|
- DER
|
|
- PEM avec clé privée
|
|
- Chaîne de certificats
|
|
|
|
```bash
|
|
./test_exports.sh
|
|
```
|
|
|
|
### test_private_keys.sh
|
|
Test de vérification du stockage des clés privées:
|
|
- Création de certificat standard (non-CA)
|
|
- Création de CA
|
|
- Export avec clés privées
|
|
- Vérification MongoDB
|
|
|
|
```bash
|
|
./test_private_keys.sh
|
|
```
|
|
|
|
## Exécuter tous les tests
|
|
|
|
```bash
|
|
cd tests/
|
|
bash test_complete.sh && bash test_exports.sh && bash test_private_keys.sh
|
|
```
|
|
|
|
## Résultats attendus
|
|
|
|
Tous les tests doivent afficher `✓` pour chaque étape:
|
|
|
|
```
|
|
=== PKI Complete Feature Test ===
|
|
[1] Login...
|
|
✓ Login successful
|
|
[2] Creating Root CA...
|
|
✓ Root CA created: <uuid>
|
|
...
|
|
=== All tests passed! ===
|
|
```
|
|
|
|
## Fichiers exportés
|
|
|
|
Les tests créent des fichiers d'export temporaires dans:
|
|
- `/tmp/pki_exports_test/` (test_exports.sh)
|
|
- `/tmp/` (test_private_keys.sh)
|
|
|
|
## Dépannage
|
|
|
|
**Erreur de connexion au serveur**:
|
|
```bash
|
|
# Vérifier que la stack est lancée
|
|
docker compose ps
|
|
|
|
# Redémarrer si nécessaire
|
|
docker compose down && docker compose up -d --build
|
|
```
|
|
|
|
**Erreur MongoDB**:
|
|
```bash
|
|
# Vérifier la connexion MongoDB
|
|
docker exec pkiapi-mongo mongosh -u admin -p password --authenticationDatabase admin pkiapi --eval "db.certificates.count()"
|
|
```
|
|
|
|
**Erreur jq**:
|
|
```bash
|
|
# Installer jq si nécessaire
|
|
sudo apt-get install jq
|
|
```
|