# NOTE: Generated By HttpRunner v3.1.4
# FROM: testcases\园业务web\yadongitest.icampus.clife.net_园业务web_登陆.yml


from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase


class TestCaseYadongitestIcampusClifeNet园业务Web登陆(HttpRunner):

    config = (
        Config("园业务_web登陆")
        .variables(
            **{
                "Protocol": "${ENV(Protocol)}",
                "host": "${ENV(HOST)}",
                "domainName": "${ENV(DONAIN_NAME)}",
            }
        )
        .verify(False)
    )

    teststeps = [
        Step(
            RunRequest("园业务_登陆")
            .post("$Protocol://$host/v1/web/eduaccount/sys/login")
            .with_headers(
                **{
                    "Accept": "application/json, text/plain, */*",
                    "Accept-Encoding": "gzip, deflate",
                    "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
                    "Connection": "keep-alive",
                    "Content-Length": "76",
                    "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
                    "Host": "$host",
                    "Origin": "$Protocol://$host",
                    "Referer": "$Protocol://$host/school/",
                    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36",
                    "X-Requested-With": "XMLHttpRequest",
                    "domainName": "$domainName",
                }
            )
            .with_data(
                {
                    "systemCode": "garden",
                    "password": "${ENV(GARDEN_PASSWORD)}",
                    "username": "${ENV(GARDEN_USERNAME)}",
                }
            )
            .extract()
            .with_jmespath("body.data.token", "token")
            .validate()
            .assert_equal("status_code", 200)
            .assert_equal('headers."Content-Type"', "application/json;charset=UTF-8")
            .assert_equal("body.code", 0)
        ),
    ]


if __name__ == "__main__":
    TestCaseYadongitestIcampusClifeNet园业务Web登陆().test_start()
