Skip to content

Latest commit

 

History

History
122 lines (99 loc) · 2.84 KB

File metadata and controls

122 lines (99 loc) · 2.84 KB

StreamFlix Testing Guide

1. Environment Verification

Before testing, ensure the system is running correctly.

Container Health Check

# Check if containers are running
docker ps

# Expected Output:
# streamflix-api   ...   Up   0.0.0.0:8080->8080/tcp
# streamflix-db    ...   Up   0.0.0.0:5432->5432/tcp

Database Connection Check

# Verify database is accepting connections
docker exec -it streamflix-db pg_isready -U admin -d streamflix

2. API Testing (Manual)

You can use Swagger UI or curl to test endpoints.

Swagger UI: http://localhost:8080/swagger-ui.html

Workflow 1: User Registration & Login

  1. Register:

    • Endpoint: POST /api/v1/auth/register
    • Body:
      {
        "email": "testuser@example.com",
        "password": "password123"
      }
    • Expected: 201 Created
  2. Login:

    • Endpoint: POST /api/v1/auth/login
    • Body:
      {
        "email": "testuser@example.com",
        "password": "password123"
      }
    • Expected: 200 OK with a JWT token.
  3. Authorize:

    • Copy the token.
    • Click "Authorize" in Swagger.
    • Enter Bearer <your_token>.

Workflow 2: Profile Management

  1. Create Profile:
    • Endpoint: POST /api/v1/profiles
    • Body:
      {
        "name": "Test Profile",
        "ageRatingId": 1
      }
    • Expected: 201 Created

Workflow 3: Browsing Content

  1. Get All Media:

    • Endpoint: GET /api/v1/media
    • Expected: 200 OK with list of movies/series.
  2. Get Specific Movie:

    • Endpoint: GET /api/v1/media/movies/1 (Shawshank Redemption)
    • Expected: 200 OK with details.

Workflow 4: Watchlist & Viewing

  1. Add to Watchlist:

    • Endpoint: POST /api/v1/watchlist
    • Body: {"mediaId": 1}
    • Expected: 200 OK
  2. Start Watching:

    • Endpoint: POST /api/v1/viewing-progress/start
    • Body: {"movieId": 1}
    • Expected: 200 OK

3. Database Verification

Use these SQL queries to verify data persistence.

-- Check if user was created
SELECT * FROM accounts WHERE email = 'testuser@example.com';

-- Check viewing progress
SELECT * FROM viewing_progress;

-- Verify trigger (Watchlist removal)
-- 1. Add item to watchlist
-- 2. Mark item as finished in viewing_progress
-- 3. Check if removed from watch_list
SELECT * FROM watch_list;

4. Automated Testing

Run the included JUnit tests.

# Linux/Mac
./mvnw test

# Windows
mvnw.cmd test

5. Security Testing

  1. Access without Token:

    • Try to access GET /api/v1/media without logging in.
    • Expected: 401 Unauthorized.
  2. Role Access:

    • Try to access Admin endpoints (e.g., POST /api/v1/media/movies) as a regular user.
    • Expected: 403 Forbidden.