#!/bin/bash set -e echo "Logging in..." TOKEN=$(curl -s -X POST -H "Content-Type: application/json" -d '{"email":"test@example.com", "password":"password123"}' http://localhost:8000/auth/login | jq -r .access_token) echo "Getting My Profile to find nickname..." MY_PROFILE=$(curl -s -H "Authorization: Bearer $TOKEN" http://localhost:8000/me/profile) NICKNAME=$(echo $MY_PROFILE | jq -r .nickname) echo "My Nickname: $NICKNAME" echo "--- Testing Public Profile ($NICKNAME) ---" PUBLIC_PROFILE=$(curl -s http://localhost:8000/profiles/$NICKNAME) echo "Public Profile: $PUBLIC_PROFILE" CHECK_NICK=$(echo $PUBLIC_PROFILE | jq -r .nickname) if [ "$CHECK_NICK" == "$NICKNAME" ]; then echo "SUCCESS: Public profile nickname matches." else echo "FAILURE: Public profile nickname mismatch." exit 1 fi echo "--- Testing Public Collection ($NICKNAME) ---" COLLECTION=$(curl -s http://localhost:8000/profiles/$NICKNAME/collection) COUNT=$(echo $COLLECTION | jq '. | length') echo "Collection count: $COUNT" if [ "$COUNT" -ge 0 ]; then echo "SUCCESS: Collection retrieved." else echo "FAILURE: Collection failed." exit 1 fi echo "--- Testing Non-Existent Profile ---" HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/profiles/nonexistent_user_123) echo "HTTP Code: $HTTP_CODE" if [ "$HTTP_CODE" == "404" ]; then echo "SUCCESS: Non-existent profile returned 404." else # wait, could be 500 if DB error? echo "FAILURE: Non-existent profile returned $HTTP_CODE" exit 1 fi echo "ALL TESTS PASSED"