"""SSO 单点登录路由测试"""

import pytest


@pytest.mark.asyncio
async def test_sso_initiate_unknown_tenant(client):
    """未知租户发起 SSO 应返回 400"""
    r = await client.get("/api/v1/auth/sso/unknown/initiate")
    assert r.status_code == 400
    assert "SSO not configured" in r.json()["error"]["message"]


@pytest.mark.asyncio
async def test_sso_initiate_unsupported_provider(client):
    """不支持的 provider（非 oidc）应返回 400"""
    r = await client.get("/api/v1/auth/sso/unknown/initiate?provider=google")
    assert r.status_code == 400
    assert r.json()["error"]["message"] == "Only OIDC supported currently"


@pytest.mark.asyncio
async def test_sso_initiate_defaults_to_oidc(client):
    """未指定 provider 时默认使用 oidc，对未知租户仍返回 400"""
    r = await client.get("/api/v1/auth/sso/unknown/initiate")
    assert r.status_code == 400


@pytest.mark.asyncio
async def test_sso_callback_unknown_tenant(client):
    """未知租户的 OIDC 回调应返回 400"""
    r = await client.get("/api/v1/auth/sso/unknown/callback?code=test&state=test")
    assert r.status_code == 400


__all__ = []
