+"""
+Manual test for the Backstage connector against a real Backstage instance.
+
+This test is designed to be run manually with real credentials.
+It is not intended to be part of the automated test suite.
+
+To run this test:
+1. Set the environment variables for your Backstage instance:
+ - BACKSTAGE_BASE_URL: REDACTED_BY_GREPTILE
+ - BACKSTAGE_CLIENT_ID: REDACTED_BY_GREPTILE
+ - BACKSTAGE_CLIENT_SECRET: REDACTED_BY_GREPTILE
+ - BACKSTAGE_TOKEN_ENDPOINT: REDACTED_BY_GREPTILE
+
+2. Run the script from the backend directory:
+ python tests/manual/test_backstage_connector_real.py
+"""
+import pytest
+import os
+import sys
+import logging
+from datetime import datetime, timedelta
+from typing import List
+
+# Add the parent directory to the path to allow importing onyx modules
+sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))))
+from onyx.connectors.backstage.connector import BackstageConnector
+from onyx.connectors.models import Document
+
+# Set up logging
+logging.basicConfig(
+ level=logging.INFO,
+ format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
+)
+logger = logging.getLogger(__name__)
+
+
+def check_environment_variables() -> bool:
+ """Check if all required environment variables are set."""
+ required_vars = [
+ "BACKSTAGE_BASE_URL",
+ "BACKSTAGE_CLIENT_ID",
+ "BACKSTAGE_CLIENT_SECRET",
+ "BACKSTAGE_TOKEN_ENDPOINT",
+ ]
+ missing_vars = [var for var in required_vars if var not in os.environ]
+
+ if missing_vars:
+ logger.error(f"Missing environment variables: {', '.join(missing_vars)}")
+ logger.error("Please set all required environment variables before running this test.")
+ return False
+ return True
+
+
+# def test_connector_init() -> BackstageConnector:
+# """Test initializing the connector."""
+# base_url = os.environ["BACKSTAGE_BASE_URL"]
+#
+# logger.info(f"Initializing connector with base URL: {base_url}")
+# connector = BackstageConnector(
+# base_url=base_url,
+# entity_kinds=[
+# BACKSTAGE_ENTITY_KINDS.COMPONENT.value,
+# BACKSTAGE_ENTITY_KINDS.API.value,
+# BACKSTAGE_ENTITY_KINDS.SYSTEM.value,
+# # Add more entity kinds as needed
+# ],
+# batch_size=100,
+# )
+#
+# return connector
+
+@pytest.fixture
+def backstage_connector(request: pytest.FixtureRequest) -> BackstageConnector:
+ scroll_before_scraping = request.param
+ base_url = "https://portal.services.as24.tech/"
+ connector = BackstageConnector(base_url)
+ return connector
+
+@pytest.mark.parametrize("backstage_connector", [True], indirect=True)
+def test_authentication(backstage_connector: BackstageConnector) -> bool:
+ """Test authentication against the real Backstage instance."""
+ logger.info("Testing authentication...")
+ try:
+ credentials = {
+ "backstage_client_id": 'REDACTED_BY_GREPTILE',
+ "backstage_client_secret": 'REDACTED_BY_GREPTILE',
+ "backstage_token_endpoint": REDACTED_BY_GREPTILE',
+ }