Files
image-apiv3/API_TEST.md
Beyhan Oğur 031582ea2c first commit
2026-04-26 22:11:03 +03:00

85 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Image API - Test Senaryoları
## API Test Komutları (cURL)
### 1. Kayıt Ol
```bash
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
```bash
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:
```bash
export TOKEN="buraya_token_yapistirin"
```
### 3. Resim Yükle
```bash
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
```bash
curl -X GET http://localhost:3000/api/v1/images \
-H "Authorization: Bearer $TOKEN"
```
### 5. Resim Sil
```bash
export IMAGE_ID="buraya_image_id_yapistirin"
curl -X DELETE http://localhost:3000/api/v1/images/$IMAGE_ID \
-H "Authorization: Bearer $TOKEN"
```
## Test Flow
1. Önce register olun ve token alın
2. Token ile resim yükleyin
3. Yüklenen resimleri listeleyin
4. Bir resmi silin
5. Tekrar listeleyin ve silindiğini doğrulayın
## Hata Testleri
### Geçersiz Token
```bash
curl -X GET http://localhost:3000/api/v1/images \
-H "Authorization: Bearer invalid_token"
```
### Token Olmadan
```bash
curl -X GET http://localhost:3000/api/v1/images
```
### Geçersiz Login
```bash
curl -X POST http://localhost:3000/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "test@example.com",
"password": "yanlis_sifre"
}'
```