# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName:   test67
# FileName:      test_auth.py
# Author:       lao_zhao
# Datetime:     2025/6/12 10:03
# Description:
# 
# ---------------------------------------------------------------------------
import allure
import pytest


class TestAuth:

    @allure.epic("BPM-添加组织的场景测试")
    @allure.feature("认证接口")
    @allure.story("登录系统")
    @allure.title("登录系统-正向用例")
    @pytest.mark.dependency(scope="session")  # 标记当前用例被后续的用例依赖
    def test_login(self, session_fix):
        """登录用例"""
        login_url = "http://36.139.193.99:8088/auth"
        login_data = {"username":"admin","password":"BU/ceNi41fsd0LDJfOtEqVWN5PxwvvO7Den25+tLku0VMtGkhZ17AkZeiww2Kj2euobUQEDaEt6TYbXHBykJ/bPpBj3Lc1bnF/RBIQjirPSFqml9iV+4gUSLpfyu3sSloW9ruKg8RT4MKbbWu1I74FlvqcZi5BW9zJLUj39sgJk="}
        res = session_fix.post(url=login_url, json=login_data)
        try:
            assert "超级管理员" in res.text
        except AssertionError as e:
            raise AssertionError("断言失败")
        else:
            # 提取token将token添加到session对象的headers中
            session_fix.headers["Authorization"] = "Bearer "+res.json()["token"]