# This file is auto-generated by oagen. Do not edit.

"""Model round-trip tests: from_dict(to_dict()) preserves data."""

from tests.generated_helpers import load_fixture

from workos.multi_factor_auth.models import (
    AuthenticationChallenge,
    AuthenticationChallengeVerifyResponse,
    AuthenticationFactor,
    AuthenticationFactorEnrolled,
    AuthenticationFactorEnrolledSms,
    AuthenticationFactorEnrolledTotp,
    AuthenticationFactorSms,
    AuthenticationFactorTotp,
    UserAuthenticationFactorEnrollResponse,
)


class TestModelRoundTrip:
    def test_authentication_challenge_round_trip(self):
        data = load_fixture("authentication_challenge.json")
        instance = AuthenticationChallenge.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = AuthenticationChallenge.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_authentication_challenge_minimal_payload(self):
        data = {
            "object": "authentication_challenge",
            "id": "auth_challenge_01FVYZ5QM8N98T9ME5BCB2BBMJ",
            "authentication_factor_id": "auth_factor_01FVYZ5QM8N98T9ME5BCB2BBMJ",
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = AuthenticationChallenge.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["id"] == data["id"]
        assert (
            serialized["authentication_factor_id"] == data["authentication_factor_id"]
        )
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]

    def test_authentication_challenge_omits_absent_optional_non_nullable_fields(self):
        data = {
            "object": "authentication_challenge",
            "id": "auth_challenge_01FVYZ5QM8N98T9ME5BCB2BBMJ",
            "authentication_factor_id": "auth_factor_01FVYZ5QM8N98T9ME5BCB2BBMJ",
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = AuthenticationChallenge.from_dict(data)
        serialized = instance.to_dict()
        assert "expires_at" not in serialized
        assert "code" not in serialized

    def test_authentication_challenge_verify_response_round_trip(self):
        data = load_fixture("authentication_challenge_verify_response.json")
        instance = AuthenticationChallengeVerifyResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = AuthenticationChallengeVerifyResponse.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_authentication_challenge_verify_response_minimal_payload(self):
        data = {
            "challenge": {
                "object": "authentication_challenge",
                "id": "auth_challenge_01FVYZ5QM8N98T9ME5BCB2BBMJ",
                "expires_at": "2026-01-15T12:00:00.000Z",
                "code": "123456",
                "authentication_factor_id": "auth_factor_01FVYZ5QM8N98T9ME5BCB2BBMJ",
                "created_at": "2026-01-15T12:00:00.000Z",
                "updated_at": "2026-01-15T12:00:00.000Z",
            },
            "valid": True,
        }
        instance = AuthenticationChallengeVerifyResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["challenge"] == data["challenge"]
        assert serialized["valid"] == data["valid"]

    def test_authentication_factor_enrolled_round_trip(self):
        data = load_fixture("authentication_factor_enrolled.json")
        instance = AuthenticationFactorEnrolled.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = AuthenticationFactorEnrolled.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_authentication_factor_enrolled_minimal_payload(self):
        data = {
            "object": "authentication_factor",
            "id": "auth_factor_01FVYZ5QM8N98T9ME5BCB2BBMJ",
            "type": "totp",
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = AuthenticationFactorEnrolled.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["id"] == data["id"]
        assert serialized["type"] == data["type"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]

    def test_authentication_factor_enrolled_omits_absent_optional_non_nullable_fields(
        self,
    ):
        data = {
            "object": "authentication_factor",
            "id": "auth_factor_01FVYZ5QM8N98T9ME5BCB2BBMJ",
            "type": "totp",
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = AuthenticationFactorEnrolled.from_dict(data)
        serialized = instance.to_dict()
        assert "user_id" not in serialized
        assert "sms" not in serialized
        assert "totp" not in serialized

    def test_authentication_factor_enrolled_round_trips_unknown_enum_values(self):
        data = {
            "object": "authentication_factor",
            "id": "auth_factor_01FVYZ5QM8N98T9ME5BCB2BBMJ",
            "type": "unexpected_authentication_factor_enrolled_type",
            "user_id": "user_01E4ZCR3C56J083X43JQXF3JK5",
            "sms": {"phone_number": "+15005550006"},
            "totp": {
                "issuer": "WorkOS",
                "user": "user@example.com",
                "secret": "JBSWY3DPEHPK3PXP",
                "qr_code": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...",
                "uri": "otpauth://totp/WorkOS:user@example.com?secret=JBSWY3DPEHPK3PXP&issuer=WorkOS",
            },
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = AuthenticationFactorEnrolled.from_dict(data)
        assert instance.to_dict() == data

    def test_authentication_factor_round_trip(self):
        data = load_fixture("authentication_factor.json")
        instance = AuthenticationFactor.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = AuthenticationFactor.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_authentication_factor_minimal_payload(self):
        data = {
            "object": "authentication_factor",
            "id": "auth_factor_01FVYZ5QM8N98T9ME5BCB2BBMJ",
            "type": "totp",
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = AuthenticationFactor.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["id"] == data["id"]
        assert serialized["type"] == data["type"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]

    def test_authentication_factor_omits_absent_optional_non_nullable_fields(self):
        data = {
            "object": "authentication_factor",
            "id": "auth_factor_01FVYZ5QM8N98T9ME5BCB2BBMJ",
            "type": "totp",
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = AuthenticationFactor.from_dict(data)
        serialized = instance.to_dict()
        assert "user_id" not in serialized
        assert "sms" not in serialized
        assert "totp" not in serialized

    def test_authentication_factor_round_trips_unknown_enum_values(self):
        data = {
            "object": "authentication_factor",
            "id": "auth_factor_01FVYZ5QM8N98T9ME5BCB2BBMJ",
            "type": "unexpected_authentication_factor_type",
            "user_id": "user_01E4ZCR3C56J083X43JQXF3JK5",
            "sms": {"phone_number": "+15005550006"},
            "totp": {"issuer": "WorkOS", "user": "user@example.com"},
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = AuthenticationFactor.from_dict(data)
        assert instance.to_dict() == data

    def test_user_authentication_factor_enroll_response_round_trip(self):
        data = load_fixture("user_authentication_factor_enroll_response.json")
        instance = UserAuthenticationFactorEnrollResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = UserAuthenticationFactorEnrollResponse.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_user_authentication_factor_enroll_response_minimal_payload(self):
        data = {
            "authentication_factor": {
                "object": "authentication_factor",
                "id": "auth_factor_01FVYZ5QM8N98T9ME5BCB2BBMJ",
                "type": "totp",
                "user_id": "user_01E4ZCR3C56J083X43JQXF3JK5",
                "sms": {"phone_number": "+15005550006"},
                "totp": {
                    "issuer": "WorkOS",
                    "user": "user@example.com",
                    "secret": "JBSWY3DPEHPK3PXP",
                    "qr_code": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...",
                    "uri": "otpauth://totp/WorkOS:user@example.com?secret=JBSWY3DPEHPK3PXP&issuer=WorkOS",
                },
                "created_at": "2026-01-15T12:00:00.000Z",
                "updated_at": "2026-01-15T12:00:00.000Z",
            },
            "authentication_challenge": {
                "object": "authentication_challenge",
                "id": "auth_challenge_01FVYZ5QM8N98T9ME5BCB2BBMJ",
                "expires_at": "2026-01-15T12:00:00.000Z",
                "code": "123456",
                "authentication_factor_id": "auth_factor_01FVYZ5QM8N98T9ME5BCB2BBMJ",
                "created_at": "2026-01-15T12:00:00.000Z",
                "updated_at": "2026-01-15T12:00:00.000Z",
            },
        }
        instance = UserAuthenticationFactorEnrollResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["authentication_factor"] == data["authentication_factor"]
        assert (
            serialized["authentication_challenge"] == data["authentication_challenge"]
        )

    def test_authentication_factor_sms_round_trip(self):
        data = load_fixture("authentication_factor_sms.json")
        instance = AuthenticationFactorSms.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = AuthenticationFactorSms.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_authentication_factor_sms_minimal_payload(self):
        data = {"phone_number": "+15005550006"}
        instance = AuthenticationFactorSms.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["phone_number"] == data["phone_number"]

    def test_authentication_factor_totp_round_trip(self):
        data = load_fixture("authentication_factor_totp.json")
        instance = AuthenticationFactorTotp.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = AuthenticationFactorTotp.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_authentication_factor_totp_minimal_payload(self):
        data = {"issuer": "WorkOS", "user": "user@example.com"}
        instance = AuthenticationFactorTotp.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["issuer"] == data["issuer"]
        assert serialized["user"] == data["user"]

    def test_authentication_factor_enrolled_sms_round_trip(self):
        data = load_fixture("authentication_factor_enrolled_sms.json")
        instance = AuthenticationFactorEnrolledSms.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = AuthenticationFactorEnrolledSms.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_authentication_factor_enrolled_sms_minimal_payload(self):
        data = {"phone_number": "+15005550006"}
        instance = AuthenticationFactorEnrolledSms.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["phone_number"] == data["phone_number"]

    def test_authentication_factor_enrolled_totp_round_trip(self):
        data = load_fixture("authentication_factor_enrolled_totp.json")
        instance = AuthenticationFactorEnrolledTotp.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = AuthenticationFactorEnrolledTotp.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_authentication_factor_enrolled_totp_minimal_payload(self):
        data = {
            "issuer": "WorkOS",
            "user": "user@example.com",
            "secret": "JBSWY3DPEHPK3PXP",
            "qr_code": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...",
            "uri": "otpauth://totp/WorkOS:user@example.com?secret=JBSWY3DPEHPK3PXP&issuer=WorkOS",
        }
        instance = AuthenticationFactorEnrolledTotp.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["issuer"] == data["issuer"]
        assert serialized["user"] == data["user"]
        assert serialized["secret"] == data["secret"]
        assert serialized["qr_code"] == data["qr_code"]
        assert serialized["uri"] == data["uri"]
