diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34b6b64..ba034b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,10 +21,13 @@ jobs: - name: Build and test run: | docker compose version + # Ensure tests directory exists and is copied to the right place + mkdir -p docker/backend/tests + cp tests/test_api.py docker/backend/tests/ docker compose -f docker-compose.dev.yml build docker compose -f docker-compose.dev.yml up -d docker compose -f docker-compose.dev.yml exec -T reproschema-server pip install pytest pytest-asyncio pytest-cov - docker compose -f docker-compose.dev.yml exec -T reproschema-server python -m pytest tests/ + docker compose -f docker-compose.dev.yml exec -T reproschema-server python -m pytest /app/tests/ docker compose -f docker-compose.dev.yml down env: # Core settings diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 763bee1..5e6a1f8 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -1,4 +1,3 @@ -version: '3.8' services: reproschema-server: container_name: ${CONTAINER_NAME:-reproschema-server} @@ -19,7 +18,7 @@ services: - ${DATA_PATH:-./data}:/data:rw # Development volumes - ./docker/backend:/app # For live backend changes - - ./tests:/app/tests:ro # Mount from project root, read-only + - ./docker/backend/tests:/app/tests:ro # Mount from backend directory environment: # Core settings - NODE_ENV=${NODE_ENV:-development} # Default to development diff --git a/docs/api-testing.md b/docs/api-testing.md index e69de29..08825a7 100644 --- a/docs/api-testing.md +++ b/docs/api-testing.md @@ -0,0 +1,59 @@ +# API Testing Guide + +## Overview +This guide explains how to test the ReproSchema backend API endpoints manually. + +## Prerequisites +- `curl` command-line tool +- Running ReproSchema server (via `docker compose up`) +- Initial token (found in backend logs) + +## Getting Started + +1. First, check the backend logs to get the initial token: + + +2. Get an auth token using the initial token: + + + +3. Use the auth token to submit data: + + +## API Endpoints + +### Health Check + + +### Get Auth Token + +Parameters: +- `token`: Initial token from backend logs +- `project`: Project name (default: "study") +- `expiry_minutes`: Token expiry in minutes (default: 90) + +### Submit Data + +Headers: +- `Authorization`: Auth token from `/api/token` endpoint +- `Content-Type`: Must be `application/json` + +### Get Schema + + +## Data Storage +Submitted responses are stored in: + + +## Common Issues +1. "Invalid token" error: + - Make sure you're using the correct initial token from logs + - Initial tokens are regenerated on container restart + +2. "Invalid auth token" error: + - Auth tokens expire after 90 minutes + - Get a new auth token using the initial token + - Don't include "Bearer " prefix in Authorization header + +## Development Testing +For development mode features: \ No newline at end of file