# Test API v1

This API provides endpoints for testing authentication and authorization.

## Endpoints

### Ping - `/test/v1/ping`

Tests JWT token authentication and returns authenticated user information.

**Authentication Required:** Yes (JWT token with `read` scope)

**Request:**
```bash
GET /test/v1/ping
Authorization: Bearer <jwt_token>
```

**Response:**
```json
{
  "authenticated": true,
  "clientEmail": "default.prod-us-east@acme-corp.sa.iam.tetrate.ai",
  "issuer": "mp",
  "audience": "dataplane-services",
  "subject": "default.prod-us-east@acme-corp.sa.iam.tetrate.ai",
  "scopes": ["read", "write"],
  "expiresAt": "2025-11-25T12:00:00Z",
  "issuedAt": "2025-11-25T11:00:00Z",
  "serverTime": "2025-11-25T11:30:00Z",
  "customClaims": {}
}
```

## Usage with valet-cli

Generate a JWT token and test it:

```bash
# Generate token
TOKEN=$(./valet-cli -service-account /path/to/service-account.json)

# Test authentication
curl -H "Authorization: Bearer $TOKEN" https://api.tetrate.ai/test/v1/ping

# Or with jq for pretty output
curl -H "Authorization: Bearer $TOKEN" https://api.tetrate.ai/test/v1/ping | jq
```

## Error Responses

- `401 Unauthorized`: Invalid or missing JWT token
- `403 Forbidden`: Valid token but missing required scope
- `500 Internal Server Error`: Server error during authentication
