In [1]:
import requests
In [27]:
import sys
In [28]:
sys.path.insert(0, 'auth-center.pyz')
In [30]:
import App
In [20]:
q = requests.post("http://localhost:4500/captcha",json={"type":"signup"})
In [21]:
x = q.json()
captcha_id = x["message"]['captcha_id']
content = x["message"]['content']
In [22]:
content
Out[22]:
In [23]:
from IPython.display import HTML
In [24]:
HTML(f"""
<img src="data:image/png;base64,{content}">""")
Out[24]:
In [25]:
q = requests.post("http://localhost:4500/auth/signup",
json={"username":"hsz",
"password":"hsz",
"main_email":"hsz1273327@gmail.com",
"captcha_id":captcha_id,
"captcha_code":"soqavw"
}
)
In [26]:
q.json()
Out[26]:
In [47]:
q = requests.post("http://localhost:4500/auth/signup/ajax/username",
json={"username":"hsz"}
)
In [48]:
q.json()
Out[48]:
In [49]:
q = requests.post("http://localhost:4500/auth/signup/ajax/main_email",
json={"main_email":"hsz@123.com"}
)
In [50]:
q.json()
Out[50]:
In [51]:
q = requests.post("http://localhost:4500/auth",json={"username":"admin","password":"admin"})
In [52]:
admin_token = q.json()["message"]
admin_token
Out[52]:
In [60]:
q = requests.post("http://localhost:4500/auth",json={"username":"hsz","password":"hsz"})
In [61]:
hsz_token = q.json()["message"]
hsz_token
Out[61]:
In [62]:
q = requests.get("http://localhost:4500/api/role",params={"service_name":"auth-center"},
headers={
"Authorization":admin_token})
In [63]:
q.json()
Out[63]:
In [64]:
q = requests.get("http://localhost:4500/api/role",
headers={
"Authorization":admin_token})
In [65]:
q.json()
Out[65]:
In [66]:
q = requests.post("http://localhost:4500/api/role",
json={"roles":[{"name":"abc"}]},
headers={
"Authorization":admin_token})
In [67]:
q.json()
Out[67]:
正确
In [68]:
q = requests.post("http://localhost:4500/api/role",
json={"roles":[{"service_name":"abc"}]},
headers={
"Authorization":admin_token})
In [69]:
q.json()
Out[69]:
In [70]:
q = requests.get("http://localhost:4500/api/role",
headers={
"Authorization":admin_token})
In [71]:
q.json()
Out[71]:
In [72]:
q = requests.delete("http://localhost:4500/api/role",
json={"service_name":"abc"},
headers={
"Authorization":admin_token})
In [73]:
q.json()
Out[73]:
In [74]:
q = requests.get("http://localhost:4500/api/role",
headers={
"Authorization":admin_token})
In [75]:
q.json()
Out[75]:
In [76]:
q = requests.get("http://localhost:4500/api/user",
headers={
"Authorization":admin_token})
In [77]:
q.json()
Out[77]:
In [78]:
q = requests.post("http://localhost:4500/api/user",
json={'users':[
{"username":"a",
"password":"a",
"main_email":"a@gmail.com"}
]},
headers={
"Authorization":admin_token})
In [79]:
q.json()
Out[79]:
In [83]:
q = requests.get("http://localhost:4500/api/user",
headers={
"Authorization":admin_token})
In [84]:
userlist = q.json()['userlist']
Out[84]:
In [90]:
admin = [i for i in userlist if i["username"]=="admin"][0]
In [91]:
hsz = [i for i in userlist if i["username"]=="hsz"][0]
In [92]:
a = [i for i in userlist if i["username"]=="a"][0]
In [93]:
q = requests.delete("http://localhost:4500/api/user",
json={'users':[a["_id"]]},
headers={
"Authorization":admin_token})
In [94]:
q.json()
Out[94]:
In [95]:
q = requests.get(f"http://localhost:4500/api/user/role/{hsz.get('_id')}",
headers={
"Authorization":admin_token})
In [96]:
q.json()
Out[96]:
admin查看admin
In [97]:
q = requests.get(f"http://localhost:4500/api/user/role/{admin.get('_id')}",
headers={
"Authorization":admin_token})
In [98]:
q.json()
Out[98]:
hsz查看hsz
In [99]:
q = requests.get(f"http://localhost:4500/api/user/role/{hsz.get('_id')}",
headers={
"Authorization":hsz_token})
In [100]:
q.json()
Out[100]:
hsz查看admin
In [101]:
q = requests.get(f"http://localhost:4500/api/user/role/{admin.get('_id')}",
headers={
"Authorization":hsz_token})
In [102]:
q.status_code
Out[102]:
In [103]:
q.json()
Out[103]:
In [105]:
q = requests.post(f"http://localhost:4500/api/user/role/{hsz.get('_id')}",
json={"service_name":"msg_reverse_indexing"},
headers={
"Authorization":hsz_token})
In [106]:
q.json()
Out[106]:
admin为hsz添加权限
In [107]:
q = requests.post(f"http://localhost:4500/api/user/role/{hsz.get('_id')}",
json={"service_name":"msg_reverse_indexing"},
headers={
"Authorization":admin_token})
In [108]:
q.json()
Out[108]:
In [109]:
q = requests.delete(f"http://localhost:4500/api/user/role/{hsz.get('_id')}",
json={"service_name":"msg_reverse_indexing"},
headers={
"Authorization":hsz_token})
In [110]:
q.json()
Out[110]:
admin删除hsz权限
In [111]:
q = requests.delete(f"http://localhost:4500/api/user/role/{hsz.get('_id')}",
json={"service_name":"msg_reverse_indexing"},
headers={
"Authorization":admin_token})
In [112]:
q.json()
Out[112]:
In [ ]:
q = requests.get("http://localhost:4500/api/user/role/61179587-d2a1-43f3-8626-63c469c24e8b",
headers={
"Authorization":"eyJfaWQiOiJmODMwZTg3ZS0wMGRiLTQ2NTYtYmM3MS00OTE4MjNkNzlkZWEiLCJyb2xlcyI6WyJhdXRoLWNlbnRlciIsIm1zZ19yZXZlcnNlX2luZGV4aW5nIl19.DHQuJA.oJzNr7ZZR81lfrvHNtxYR4UaFH4"})