# Path: e2e-test-server/e2e_test_server/constants.py
# PROJECT_ID = os.environ["PROJECT_ID"]
# 
# PUSH_PORT = (
#     os.environ["PUSH_PORT"]
#     if SUBSCRIPTION_MODE is SubscriptionMode.PUSH
#     else None
# )
# 
# REQUEST_SUBSCRIPTION_NAME = os.environ["REQUEST_SUBSCRIPTION_NAME"]
# 
# RESPONSE_TOPIC_NAME = os.environ["RESPONSE_TOPIC_NAME"]
# 
# SCENARIO = "scenario"
# 
# STATUS_CODE = "status_code"
# 
# TEST_ID = "test_id"


import base64
import logging
from typing import Literal
from google.cloud import pubsub_v1
from google.cloud.pubsub_v1.subscriber.message import Message
from google.rpc import code_pb2
from . import scenarios, types
from .constants import (
    PROJECT_ID,
    PUSH_PORT,
    REQUEST_SUBSCRIPTION_NAME,
    RESPONSE_TOPIC_NAME,
    SCENARIO,
    STATUS_CODE,
    TEST_ID,
)
    from flask import Flask, Response, request
    from waitress import serve
        return "ack"

    scenario = message.attributes[SCENARIO]
    handler = scenarios.SCENARIO_TO_HANDLER.get(
        scenario, scenarios.not_implemented_handler
    )

    try:
        res = handler(
            scenarios.Request(
                test_id=test_id,
                headers=dict(message.attributes),
                data=message.data,
            )
        )
    except Exception as e:
        logger.exception("exception trying to handle request")
        res = scenarios.Response(
            status_code=code_pb2.INTERNAL, data=str(e).encode()
        )
    finally:
        responder.respond(test_id, res)
        return "ack"


def pubsub_pull() -> None:
    """Pull incoming pub/sub push messages on REQUEST_SUBSCRIPTION_NAME"""
    responder = _Responder()
    subscriber = pubsub_v1.SubscriberClient()
    subscription_path = subscriber.subscription_path(

# Path: e2e-test-server/e2e_test_server/constants.py
# PROJECT_ID = os.environ["PROJECT_ID"]
# 
# PUSH_PORT = (
#     os.environ["PUSH_PORT"]
#     if SUBSCRIPTION_MODE is SubscriptionMode.PUSH
#     else None
# )
# 
# REQUEST_SUBSCRIPTION_NAME = os.environ["REQUEST_SUBSCRIPTION_NAME"]
# 
# RESPONSE_TOPIC_NAME = os.environ["RESPONSE_TOPIC_NAME"]
# 
# SCENARIO = "scenario"
# 
# STATUS_CODE = "status_code"
# 
# TEST_ID = "test_id"


# Path: e2e-test-server/e2e_test_server/server.py
import base64
import logging
from typing import Literal
from google.cloud import pubsub_v1
from google.cloud.pubsub_v1.subscriber.message import Message
from google.rpc import code_pb2
from . import scenarios, types
from .constants import (
    PROJECT_ID,
    PUSH_PORT,
    REQUEST_SUBSCRIPTION_NAME,
    RESPONSE_TOPIC_NAME,
    SCENARIO,
    STATUS_CODE,
    TEST_ID,
)
    from flask import Flask, Response, request
    from waitress import serve

        return "ack"

    scenario = message.attributes[SCENARIO]
    handler = scenarios.SCENARIO_TO_HANDLER.get(
        scenario, scenarios.not_implemented_handler
    )

    try:
        res = handler(
            scenarios.Request(
                test_id=test_id,
                headers=dict(message.attributes),
                data=message.data,
            )
        )
    except Exception as e:
        logger.exception("exception trying to handle request")
        res = scenarios.Response(
            status_code=code_pb2.INTERNAL, data=str(e).encode()
        )
    finally:
        responder.respond(test_id, res)
        return "ack"


def pubsub_pull() -> None:
    """Pull incoming pub/sub push messages on REQUEST_SUBSCRIPTION_NAME"""
    responder = _Responder()
    subscriber = pubsub_v1.SubscriberClient()
    subscription_path = subscriber.subscription_path(

        PROJECT_ID,