1.7 KiB
1.7 KiB
Image API - Test Senaryoları
API Test Komutları (cURL)
1. Kayıt Ol
curl -X POST http://localhost:3000/api/v1/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "test@example.com",
"password": "test12345",
"name": "Test User"
}'
2. Login
curl -X POST http://localhost:3000/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "test@example.com",
"password": "test12345"
}'
Yanıttan accessToken değerini alın ve aşağıdaki komutlarda kullanın:
export TOKEN="buraya_token_yapistirin"
3. Resim Yükle
curl -X POST http://localhost:3000/api/v1/images/upload \
-H "Authorization: Bearer $TOKEN" \
-F "file=@/path/to/image.jpg" \
-F "width=800" \
-F "height=600" \
-F "quality=90" \
-F "format=webp"
4. Resimleri Listele
curl -X GET http://localhost:3000/api/v1/images \
-H "Authorization: Bearer $TOKEN"
5. Resim Sil
export IMAGE_ID="buraya_image_id_yapistirin"
curl -X DELETE http://localhost:3000/api/v1/images/$IMAGE_ID \
-H "Authorization: Bearer $TOKEN"
Test Flow
- Önce register olun ve token alın
- Token ile resim yükleyin
- Yüklenen resimleri listeleyin
- Bir resmi silin
- Tekrar listeleyin ve silindiğini doğrulayın
Hata Testleri
Geçersiz Token
curl -X GET http://localhost:3000/api/v1/images \
-H "Authorization: Bearer invalid_token"
Token Olmadan
curl -X GET http://localhost:3000/api/v1/images
Geçersiz Login
curl -X POST http://localhost:3000/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "test@example.com",
"password": "yanlis_sifre"
}'