58 lines
1.1 KiB
Python
58 lines
1.1 KiB
Python
import pytest
|
|
from code_privacy_shield.patterns import PatternLibrary
|
|
from code_privacy_shield.redactor import Redactor
|
|
from code_privacy_shield.config import Config
|
|
|
|
|
|
@pytest.fixture
|
|
def pattern_library():
|
|
return PatternLibrary()
|
|
|
|
|
|
@pytest.fixture
|
|
def redactor():
|
|
return Redactor()
|
|
|
|
|
|
@pytest.fixture
|
|
def config():
|
|
return Config()
|
|
|
|
|
|
@pytest.fixture
|
|
def sample_sensitive_code():
|
|
return '''
|
|
import os
|
|
import requests
|
|
|
|
API_KEY = "sk-abc123def456ghi789"
|
|
DATABASE_URL = "postgresql://user:password@localhost:5432/mydb"
|
|
EMAIL = "developer@company.com"
|
|
AWS_SECRET = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
|
|
|
|
# Environment variable access
|
|
db_password = os.environ.get("DB_PASSWORD")
|
|
|
|
# Database connection
|
|
conn_string = "mysql://admin:secretpass@db.example.com:3306/users"
|
|
|
|
# Authorization header
|
|
headers = {"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"}
|
|
'''
|
|
|
|
|
|
@pytest.fixture
|
|
def sample_clean_code():
|
|
return '''
|
|
def calculate_sum(a, b):
|
|
"""Calculate sum of two numbers."""
|
|
return a + b
|
|
|
|
class MyClass:
|
|
def __init__(self, value):
|
|
self.value = value
|
|
|
|
def get_value(self):
|
|
return self.value
|
|
'''
|