diff --git a/__pycache__/__init__.cpython-311.pyc b/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..824ffa4 Binary files /dev/null and b/__pycache__/__init__.cpython-311.pyc differ diff --git a/__pycache__/__init__.cpython-312.pyc b/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..c5b2959 Binary files /dev/null and b/__pycache__/__init__.cpython-312.pyc differ diff --git a/__pycache__/_service.cpython-311.pyc b/__pycache__/_service.cpython-311.pyc new file mode 100644 index 0000000..3c6e4b6 Binary files /dev/null and b/__pycache__/_service.cpython-311.pyc differ diff --git a/__pycache__/_service.cpython-312.pyc b/__pycache__/_service.cpython-312.pyc new file mode 100644 index 0000000..33f699d Binary files /dev/null and b/__pycache__/_service.cpython-312.pyc differ diff --git a/__pycache__/auth.cpython-311.pyc b/__pycache__/auth.cpython-311.pyc new file mode 100644 index 0000000..3ba2397 Binary files /dev/null and b/__pycache__/auth.cpython-311.pyc differ diff --git a/__pycache__/auth.cpython-312.pyc b/__pycache__/auth.cpython-312.pyc new file mode 100644 index 0000000..332c60d Binary files /dev/null and b/__pycache__/auth.cpython-312.pyc differ diff --git a/__pycache__/client.cpython-311.pyc b/__pycache__/client.cpython-311.pyc new file mode 100644 index 0000000..1d77d82 Binary files /dev/null and b/__pycache__/client.cpython-311.pyc differ diff --git a/__pycache__/client.cpython-312.pyc b/__pycache__/client.cpython-312.pyc new file mode 100644 index 0000000..1696081 Binary files /dev/null and b/__pycache__/client.cpython-312.pyc differ diff --git a/__pycache__/database.cpython-311.pyc b/__pycache__/database.cpython-311.pyc new file mode 100644 index 0000000..c2f5672 Binary files /dev/null and b/__pycache__/database.cpython-311.pyc differ diff --git a/__pycache__/database.cpython-312.pyc b/__pycache__/database.cpython-312.pyc new file mode 100644 index 0000000..8ae04a7 Binary files /dev/null and b/__pycache__/database.cpython-312.pyc differ diff --git a/__pycache__/edge_functions.cpython-311.pyc b/__pycache__/edge_functions.cpython-311.pyc new file mode 100644 index 0000000..76c3875 Binary files /dev/null and b/__pycache__/edge_functions.cpython-311.pyc differ diff --git a/__pycache__/edge_functions.cpython-312.pyc b/__pycache__/edge_functions.cpython-312.pyc new file mode 100644 index 0000000..a9199e2 Binary files /dev/null and b/__pycache__/edge_functions.cpython-312.pyc differ diff --git a/__pycache__/init.cpython-311.pyc b/__pycache__/init.cpython-311.pyc new file mode 100644 index 0000000..d545903 Binary files /dev/null and b/__pycache__/init.cpython-311.pyc differ diff --git a/__pycache__/init.cpython-312.pyc b/__pycache__/init.cpython-312.pyc new file mode 100644 index 0000000..542e1b7 Binary files /dev/null and b/__pycache__/init.cpython-312.pyc differ diff --git a/__pycache__/realtime.cpython-311.pyc b/__pycache__/realtime.cpython-311.pyc new file mode 100644 index 0000000..4bf52e1 Binary files /dev/null and b/__pycache__/realtime.cpython-311.pyc differ diff --git a/__pycache__/realtime.cpython-312.pyc b/__pycache__/realtime.cpython-312.pyc new file mode 100644 index 0000000..d9e1a81 Binary files /dev/null and b/__pycache__/realtime.cpython-312.pyc differ diff --git a/__pycache__/storage.cpython-311.pyc b/__pycache__/storage.cpython-311.pyc new file mode 100644 index 0000000..d1f21d8 Binary files /dev/null and b/__pycache__/storage.cpython-311.pyc differ diff --git a/__pycache__/storage.cpython-312.pyc b/__pycache__/storage.cpython-312.pyc new file mode 100644 index 0000000..85536ed Binary files /dev/null and b/__pycache__/storage.cpython-312.pyc differ diff --git a/_service.py b/_service.py index f0198a4..8078c55 100644 --- a/_service.py +++ b/_service.py @@ -1,8 +1,8 @@ import json from typing import Any, Dict, Optional +import os import requests -from django.conf import settings import logging logger = logging.getLogger(" apps.supabase_home") @@ -44,23 +44,23 @@ class SupabaseService: """ def __init__(self): - # Get configuration from settings - self.base_url = settings.SUPABASE_URL - self.anon_key = settings.SUPABASE_ANON_KEY - self.service_role_key = settings.SUPABASE_SERVICE_ROLE_KEY + # Get configuration from environment variables + self.base_url = os.getenv("SUPABASE_URL", "") + self.anon_key = os.getenv("SUPABASE_ANON_KEY", "") + self.service_role_key = os.getenv("SUPABASE_SERVICE_ROLE_KEY", "") # Validate required settings if not self.base_url: - logger.error("SUPABASE_URL is not set in settings") - raise ValueError("SUPABASE_URL is not set in settings") + logger.error("SUPABASE_URL is not set in environment variables") + raise ValueError("SUPABASE_URL is not set in environment variables") if not self.anon_key: - logger.error("SUPABASE_ANON_KEY is not set in settings") - raise ValueError("SUPABASE_ANON_KEY is not set in settings") + logger.error("SUPABASE_ANON_KEY is not set in environment variables") + raise ValueError("SUPABASE_ANON_KEY is not set in environment variables") if not self.service_role_key: logger.warning( - "SUPABASE_SERVICE_ROLE_KEY is not set in settings. Admin operations will not work." + "SUPABASE_SERVICE_ROLE_KEY is not set in environment variables. Admin operations will not work." ) def _get_headers( diff --git a/init.py b/init.py index 343a534..862a284 100644 --- a/init.py +++ b/init.py @@ -1,7 +1,7 @@ -from django.conf import settings import logging import sys -from backend.utils.sensitive import load_environment_files +# Import the environment file loader +from app.core.utils.sensitive import load_environment_files import os # Load environment variables @@ -53,7 +53,8 @@ def initialize_supabase() -> Client: # Check for required environment variables supabase_url = os.getenv("SUPABASE_URL") - supabase_key = os.getenv("SUPABASE_ANON_KEY") + # Use service role key for backend operations to bypass RLS + supabase_key = os.getenv("SUPABASE_SERVICE_ROLE_KEY") or os.getenv("SUPABASE_ANON_KEY") print(f"Supabase URL: {supabase_url}") # Added print statement to show the URL @@ -63,7 +64,7 @@ def initialize_supabase() -> Client: raise ValueError(error_msg) if not supabase_key: - error_msg = "SUPABASE_ANON_KEY is not set in environment variables" + error_msg = "SUPABASE_SERVICE_ROLE_KEY or SUPABASE_ANON_KEY is not set in environment variables" logger.error(error_msg) raise ValueError(error_msg) diff --git a/tests/conftest.py b/tests/conftest.py index 43e92c4..3f74976 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,7 +4,7 @@ import pytest from pathlib import Path from utils.sensitive import load_environment_files -from apps.supabase_home.tests._verify_supabase_connection import run_verification +from app.core.third_party_integrations.supabase_home.tests._verify_supabase_connection import run_verification import uuid # Add the backend directory to the Python path diff --git a/tests/test_edge_functions.py b/tests/test_edge_functions.py index 30ebac2..93b3bc6 100644 --- a/tests/test_edge_functions.py +++ b/tests/test_edge_functions.py @@ -4,7 +4,7 @@ import pytest -from apps.supabase_home.edge_functions import SupabaseEdgeFunctionsService +from app.core.third_party_integrations.supabase_home.edge_functions import SupabaseEdgeFunctionsService class TestSupabaseEdgeFunctionsService: diff --git a/tests/test_integration.py b/tests/test_integration.py index 5fc5fa6..1a22d4d 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -7,9 +7,9 @@ from django.conf import settings # Import the service classes from their respective modules -from apps.supabase_home.auth import SupabaseAuthService -from apps.supabase_home.storage import SupabaseStorageService -from apps.supabase_home.database import SupabaseDatabaseService +from app.core.third_party_integrations.supabase_home.auth import SupabaseAuthService +from app.core.third_party_integrations.supabase_home.storage import SupabaseStorageService +from app.core.third_party_integrations.supabase_home.database import SupabaseDatabaseService # Load environment variables for tests load_environment_files() diff --git a/tests/test_service.py b/tests/test_service.py index 8e3d0c1..8eae2d4 100644 --- a/tests/test_service.py +++ b/tests/test_service.py @@ -2,7 +2,7 @@ import requests import os -from apps.supabase_home._service import SupabaseService, SupabaseAPIError, SupabaseError +from app.core.third_party_integrations.supabase_home._service import SupabaseService, SupabaseAPIError, SupabaseError