예제 #1
0
def main():
    cred = auth.Credential(
        "[email protected]",
        "46f09bb9fab4f12dfc160dae12273d5332b5debe",
    )
    d = {"Action": "DescribeUHostInstance", "Region": "cn-bj2", "Limit": 10}
    print(cred.verify_ac(d))
예제 #2
0
def author(d):
    cred = auth.Credential(
        public_key,
        private_key,
    )
    signation = cred.verify_ac(d)
    return signation
예제 #3
0
def test_verify_ac():
    d = {
        "Action": "CreateUHostInstance",
        "CPU": 2,
        "ChargeType": "Month",
        "DiskSpace": 10,
        "ImageId": "f43736e1-65a5-4bea-ad2e-8a46e18883c2",
        "LoginMode": "Password",
        "Memory": 2048,
        "Name": "Host01",
        "Password": "******",
        "PublicKey": "[email protected]",
        "Quantity": 1,
        "Region": "cn-bj2",
        "Zone": "cn-bj2-04",
    }
    cred = auth.Credential(
        "[email protected]",
        "46f09bb9fab4f12dfc160dae12273d5332b5debe",
    )
    assert cred.verify_ac(d) == "4f9ef5df2abab2c6fccd1e9515cb7e2df8c6bb65"
    assert cred.to_dict() == {
        "public_key": "[email protected]",
        "private_key": "46f09bb9fab4f12dfc160dae12273d5332b5debe",
    }
예제 #4
0
def author(d):
    # 签名算法,输出签名
    public_key = ""  # 公私钥 https://console.ucloud.cn/uapi/apikey
    private_key = ""
    cred = auth.Credential(
        public_key,
        private_key,
    )
    signation = cred.verify_ac(d)
    return signation