# ivatar / libravatar

# Pipeline and coverage status

[![pipeline status](https://git.linux-kernel.at/oliver/ivatar/badges/master/pipeline.svg)](https://git.linux-kernel.at/oliver/ivatar/commits/master)
[![coverage report](https://git.linux-kernel.at/oliver/ivatar/badges/master/coverage.svg)](http://git.linux-kernel.at/oliver/ivatar/commits/master)

# Reports / code documentation

- [Coverage HTML report](http://oliver.git.linux-kernel.at/ivatar)
- [Code documentation (autogenerated, pycco)](http://oliver.git.linux-kernel.at/ivatar/pycco/)

# Environment Variables

## OpenTelemetry Configuration

OpenTelemetry instrumentation is always enabled in ivatar. The following environment variables control the behavior:

### Core Configuration

- `OTEL_SERVICE_NAME`: Service name for OpenTelemetry (default: "ivatar")
- `OTEL_ENVIRONMENT`: Deployment environment (default: "production")
- `OTEL_EXPORT_ENABLED`: Enable/disable data export (default: "false")
  - Set to "true" to enable sending telemetry data to external collectors
  - Set to "false" to disable export (instrumentation still active)

### Export Configuration

- `OTEL_EXPORTER_OTLP_ENDPOINT`: OTLP endpoint for traces and metrics export
  - Example: "http://localhost:4317" (gRPC) or "http://localhost:4318" (HTTP)
- `OTEL_PROMETHEUS_ENDPOINT`: Prometheus metrics endpoint (default: "0.0.0.0:9464")

## Example Configurations

### Development (Export Disabled)

```bash
export OTEL_EXPORT_ENABLED=false
export OTEL_SERVICE_NAME=ivatar-dev
export OTEL_ENVIRONMENT=development
```

### Production (Export Enabled)

```bash
export OTEL_EXPORT_ENABLED=true
export OTEL_SERVICE_NAME=ivatar
export OTEL_ENVIRONMENT=production
export OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
```

# Testing

## Running Tests

### Local Development (Recommended)

For local development, use the provided script to skip Bluesky tests that require external API credentials:

```bash
./scripts/run_tests_local.sh
```

This runs all tests except those marked with `@pytest.mark.bluesky`.

### All Tests

To run all tests including Bluesky tests (requires Bluesky API credentials):

```bash
python3 manage.py test -v3
```

### Specific Test Categories

```bash
# Run only Bluesky tests
python3 manage.py test ivatar.ivataraccount.test_views_bluesky -v3

# Run only file upload security tests
python3 manage.py test ivatar.test_file_security -v3

# Run only upload tests
python3 manage.py test ivatar.ivataraccount.test_views -v3
```

## Test Markers

Tests are categorized using pytest markers:

- `@pytest.mark.bluesky`: Tests requiring Bluesky API credentials
- `@pytest.mark.slow`: Long-running tests
- `@pytest.mark.integration`: Integration tests
- `@pytest.mark.unit`: Unit tests

# Authors and contributors

Lead developer/Owner: Oliver Falk (aka ofalk or falko) - https://git.linux-kernel.at/oliver

Operations: Michal Novotny (aka clime)

QA: Tristan Le Guern (aka tleguern)

Frontend developer: Lukas Schönsgibl (aka hybridpicker), Niklas Poslovski (aka nipos)

Organisation/Meeting moderation: Lars Kruse (aka sumpfralle)

Initial developer: François Marier - https://fmarier.org/
