Files
image-apiv2/API_TEST.md
Beyhan Oğur 71eff2d979 first commit
2026-04-26 22:09:32 +03:00

1.7 KiB
Raw Blame History

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

  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

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"
  }'