-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_auth.py
More file actions
30 lines (27 loc) · 927 Bytes
/
test_auth.py
File metadata and controls
30 lines (27 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# -*- coding: utf-8 -*-
from ucloud.core import auth
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": "VUNsb3VkLmNu",
"PublicKey": "ucloudsomeone@example.com1296235120854146120",
"Quantity": 1,
"Region": "cn-bj2",
"Zone": "cn-bj2-04",
}
cred = auth.Credential(
"ucloudsomeone@example.com1296235120854146120",
"46f09bb9fab4f12dfc160dae12273d5332b5debe",
)
assert cred.verify_ac(d) == "4f9ef5df2abab2c6fccd1e9515cb7e2df8c6bb65"
assert cred.to_dict() == {
"public_key": "ucloudsomeone@example.com1296235120854146120",
"private_key": "46f09bb9fab4f12dfc160dae12273d5332b5debe",
}