import pytest def clients(): return { "client-1": { "client_id": "client-1", "client_name": "Client 1", "subscription": "soar.#", "secret": "abc123", }, "client-2": { "client_id": "client-2", "client_name": "Client 2", "subscription": "soar.client-2.#", "secret": "xyz789", }, } def get_auth_header(client, credentials): token_response = client.get("/token", query_string=credentials) if token_response.status_code == 200: token = token_response.json["token"] return {"Authorization": f"Bearer {token}"} else: return None @pytest.fixture def mock_clients(): return clients() @pytest.fixture def mock_new_client(): return { "client_id": "client-3", "client_name": "Client 3", "subscription": "soar.client-3.#", } @pytest.fixture def mock_client_credentials(): mock_clients = clients() return { "client_id": mock_clients["client-1"]["client_id"], "secret": mock_clients["client-1"]["secret"], } @pytest.fixture def mock_invalid_credentials(): return {"client_id": "client-invalid", "secret": "fake-secret"} @pytest.fixture def mock_token_secret(): return "2UrRyeb9c6hq8Gj9nmI5safPz9LpPeUFtifeMNx4GQo=" def posts(): return { "send": { "topic": "soar.client-1.message", "body": "this is a pub/sub message from client-1", }, "notify": {"body": "this is a broadcast message from client-1"}, } @pytest.fixture def mock_post_send(): return posts()["send"] @pytest.fixture def mock_message_send(): post = posts()["send"] return {"topic": post["topic"], "message": post["body"]} @pytest.fixture def mock_post_notify(): return posts()["notify"] @pytest.fixture def mock_message_notify(): post = posts()["notify"] return {"topic": "broadcast", "message": post["body"]} @pytest.fixture def mock_read_from_queue_return(): return [ { "topic": "soar.client-1.something", "message": "this is a pub/sub message from client-1" } ]