from __future__ import annotations

import unittest

from daily_report.feishu_auth import create_session_cookie, parse_session_cookie


class FeishuAuthTest(unittest.TestCase):
    def test_session_cookie_round_trip_and_rejects_tampering(self) -> None:
        cookie = create_session_cookie({"feishu_user_id": "ou_1", "name": "张三"}, "secret")
        session = parse_session_cookie(cookie, "secret")

        self.assertEqual(session["feishu_user_id"], "ou_1")
        self.assertEqual(session["name"], "张三")
        self.assertIsNone(parse_session_cookie(cookie + "x", "secret"))


if __name__ == "__main__":
    unittest.main()
