# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName:   test65
# FileName:      test_demo.py
# Author:       lao_zhao
# Datetime:     2025/3/11 9:43
# Description:
# 
# ---------------------------------------------------------------------------
import pytest
import requests
import allure



@allure.epic("BPM项目-场景测试")
@allure.feature("认证接口")
@allure.story("登录系统")
@allure.title("正向用例")
@pytest.mark.dependency(scope="session")
def test_login(set_value, session_fix):
    res = session_fix.post(url="http://36.139.193.99:8088/auth", json={"username": "admin",
                                                               "password": "FMdrV2BOQbG4L+z83m+0X1+sS9ZjdHnmvZoUQI7cmv1YW///jK1vwsa4rJang9t+P+j9sPNM1gH/MAJ4frtA0mSvqTygUPj1cv3Lb5DTvwbvzC79osvC7EGH3pqYrWXiicx5PzghVYpstgTkWvniJ9CAiVVwtrj/q1AlWzqUB2U="})
    try:
        assert "loginStatus" in res.text
    except AssertionError:
        raise AssertionError("断言失败")
    else:
        token = res.json().get("token")
        session_fix.headers["Authorization"] = "Bearer "+token
        set_value("token", token)