prisma_auth 0.2.1

A simple authentication crate supporting both Rocket backend API and Yew frontend authentication components
Documentation
# API Testing with Hurl

This directory contains [Hurl](https://hurl.dev) test files for testing the Prisma Auth API endpoints.

## Test Files

- `auth.hurl` - Authentication endpoint tests
- `users.hurl` - User management API tests

## Quick Start

### Using the Test Script (Recommended)

The easiest way to run tests is using the provided test script:

```bash
# Start the application and run all tests
./test.sh start && ./test.sh test

# Or run specific test suites
./test.sh test-auth    # Authentication tests only
./test.sh test-users   # User management tests only

# Stop the application when done
./test.sh stop
```

### Manual Docker Compose Commands

If you prefer manual control:

```bash
# Start the application
cd example && docker compose up -d --build

# Wait for the application to be ready
curl -s http://localhost:8000/ || echo "Waiting for app..."

# Run all tests
cd tests && hurl --test *.hurl

# Run specific test file
hurl --test auth.hurl

# Stop the application
cd example && docker compose down
```

### Local Hurl Installation

If you have Hurl installed locally, you can run tests directly:

```bash
# Start the application first
cd example && docker compose up -d --build

# Run tests with local Hurl
cd tests
hurl --test *.hurl

# Or run specific tests
hurl --test auth.hurl
hurl --test users.hurl --verbose  # with verbose output
```

## Authentication

The tests use the default admin credentials:
- Username: `admin`
- Password: `admin123` (from the example backend configuration)

## Customizing Tests

### Adding New Tests

1. Create a new `.hurl` file in the `tests/` directory
2. Follow the authentication pattern from existing files
3. Add your API endpoint tests
4. Update the test script if needed

### Modifying Existing Tests

You can edit the `.hurl` files to:
- Add new assertions
- Test different request payloads
- Add performance testing with timing assertions
- Test error scenarios

### Environment Variables

You can use Hurl's variable features:

```bash
# Run with custom host
hurl --variable host=localhost:8000 --test *.hurl

# Run with custom credentials
hurl --variable username=admin --variable password=mypassword --test *.hurl
```

## Troubleshooting

### Application Not Ready

If tests fail because the application isn't ready:
- Use the test script which includes health checks
- Wait longer for the application to start
- Check logs: `./test.sh logs`

### Authentication Failures

If auth tests fail:
- Verify the admin credentials in the example backend
- Check if the password matches the one used in test files

### Network Issues

If connection fails:
- Ensure the application is running: `cd example && docker compose ps`
- Check port mapping: port 8000 should be accessible
- Verify Docker networks are properly configured

### Test File Syntax

If Hurl complains about syntax:
- Check the Hurl documentation: https://hurl.dev/docs/
- Validate JSON payloads
- Ensure proper indentation and formatting

## Contributing

When adding new API endpoints:
1. Add corresponding Hurl tests
2. Update this README if needed
3. Test both success and failure scenarios
4. Include proper assertions for response validation