File size: 1,505 Bytes
5eebd59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""
Configuration for pytest fixtures and shared test utilities.
"""

import pytest
import os
import sys

# Add the project root to the path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

# Set test environment variables
os.environ['TESTING'] = 'true'
os.environ['JWT_SECRET'] = 'test-jwt-secret-for-testing'
os.environ['ENVIRONMENT'] = 'test'


@pytest.fixture
def mock_user():
    """Fixture providing a mock user object."""
    return {
        "id": "test-user-123",
        "username": "testuser",
        "role": "CONTRIBUTOR",
        "avatarUrl": "https://github.com/test.png"
    }


@pytest.fixture
def mock_maintainer():
    """Fixture providing a mock maintainer user."""
    return {
        "id": "maintainer-123",
        "username": "maintainer",
        "role": "MAINTAINER",
        "avatarUrl": "https://github.com/maintainer.png"
    }


@pytest.fixture
def auth_headers(mock_user):
    """Fixture providing authorization headers with a valid token."""
    import jwt
    import time
    
    token = jwt.encode(
        {
            "user_id": mock_user["id"],
            "role": mock_user["role"],
            "exp": int(time.time()) + 3600
        },
        os.environ['JWT_SECRET'],
        algorithm="HS256"
    )
    return {"Authorization": f"Bearer {token}"}


@pytest.fixture
def api_key_headers():
    """Fixture providing API key headers for service-to-service calls."""
    return {"X-API-Key": os.environ.get("AI_ENGINE_API_KEY", "")}