test-1000.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. import requests
  2. # --- test 获取token ---
  3. # url = 'http://58.34.94.177:29101/v1/token'
  4. # url = 'http://127.0.0.1:9000/v1/token'
  5. url = 'http://10.10.60.237:9000/v1/token'
  6. data = {
  7. # 'username': 'admin', # 登录账户
  8. # 'password': '123456', # 登录密码
  9. 'username': 'test003', # 登录账户
  10. 'password': '123456', # 登录密码
  11. # 'username': 'test01', # 登录账户
  12. # 'password': '123456', # 登录密码
  13. }
  14. response = requests.post(url=url, json=data)
  15. code = response.json().get('code')
  16. token = response.headers.get('authorization')
  17. print(response.json())
  18. # """
  19. # {
  20. # 'code': 0,
  21. # 'message': 'authorization passed.',
  22. # 'data': {
  23. # 'uid': '65dc4187e6e1bf491a4aad1f',
  24. # 'username': 'admin',
  25. # 'role': '超级管理员',
  26. # 'role_type': 1,
  27. # 'token': 'xxxxxxxx'
  28. # }
  29. # }
  30. # """
  31. # --- test 1001 新增用户 ---
  32. # url = 'http://58.34.94.177:29101/v6/api'
  33. # url = 'http://127.0.0.1:9000/v6/api'
  34. # url = 'http://10.10.60.237:9000/v6/api'
  35. # data = {
  36. # 'code': 1001, # 接口号
  37. # 'username': 'test003', # 登录账户(必须项)
  38. # 'password': '123456', # 登录密码(可选项)(默认值:baosteel@2024)
  39. # 'role_type': 1, # 角色类型(可选项)(1: 超级管理员 2: 普通管理员 3: 普通用户)
  40. # 'name': '张三003', # 姓名(可选项)
  41. # 'cid': '112233', # 身份证号(可选项)
  42. # 'phone': '112233', # 手机号(可选项)
  43. # 'sex': 0, # 性别(可选项)(0:未设置 1:男 2:女)
  44. # 'department': 'aabbcc', # 部门(可选项)
  45. # 'wid': 'aabbcc', # 工号(可选项)
  46. # }
  47. # response = requests.post(url=url, json=data, headers={'authorization': token})
  48. # print(response.json())
  49. # --- test 1002 查询用户列表 ---
  50. # url = 'http://58.34.94.177:29101/v6/api'
  51. url = 'http://127.0.0.1:9000/v6/api'
  52. data = {
  53. 'code': 1002, # 接口号
  54. 'page': 1, # 页码
  55. 'size': 3, # 每页条数
  56. 'name': '张', # 模糊姓名(可选项)
  57. 'phone': '', # 手机号(可选项)
  58. 'role_type': ['1'], # 角色类型(可选项) 1 超级管理员 2 普通管理员 3 普通用户(默认值)
  59. }
  60. response = requests.post(url=url, json=data, headers={'authorization': token})
  61. print(response.json())
  62. # """
  63. # {
  64. # 'code': 0,
  65. # 'data': [
  66. # {
  67. # 'uuid': '65dbeb1c49fbe311a3a01d34',
  68. # 'name': 'aabbcc',
  69. # 'cid': '112233',
  70. # 'phone': '112233',
  71. # 'sex': 0, # 性别 (0:未设置 1:男 2:女)
  72. # 'department': 'aabbcc',
  73. # 'wid': 'aabbcc',
  74. # 'state': 0, # 禁用状态 (0:激活 1:禁用)
  75. # 'allow_at': 1708911388 # 注册审批时间时间戳
  76. # }
  77. # ]
  78. # }
  79. # """
  80. # --- test 1003 删除指定用户 ---
  81. # url = 'http://58.34.94.177:29101/v6/api'
  82. # data = {
  83. # 'code': 1003, # 接口号
  84. # 'uuid': '65db84b35e305885648ec062', # 用户id(必须项)
  85. # }
  86. # response = requests.post(url=url, json=data, headers={'authorization': token})
  87. # print(response.json())
  88. # --- test 1004 禁用指定用户 ---
  89. # url = 'http://58.34.94.177:29101/v6/api'
  90. # data = {
  91. # 'code': 1004, # 接口号
  92. # 'uuid': '65decb7744b74ae33732d813', # 用户id(必须项)
  93. # }
  94. # response = requests.post(url=url, json=data, headers={'authorization': token})
  95. # print(response.json())
  96. # --- test 1005 启用指定用户 ---
  97. # url = 'http://58.34.94.177:29101/v6/api'
  98. # data = {
  99. # 'code': 1005, # 接口号
  100. # 'uuid': '65decb7744b74ae33732d813', # 用户id(必须项)
  101. # }
  102. # response = requests.post(url=url, json=data, headers={'authorization': token})
  103. # print(response.json())
  104. # --- test 1006 获取指定用户详情 ---
  105. # url = 'http://58.34.94.177:29101/v6/api'
  106. # data = {
  107. # 'code': 1006, # 接口号
  108. # 'uuid': '65dd775c44b74ae33732d7f7', # 用户id(必须项)
  109. # }
  110. # response = requests.post(url=url, json=data, headers={'authorization': token})
  111. # print(response.json())
  112. # --- test 1007 修改指定用户信息 ---
  113. # url = 'http://58.34.94.177:29101/v6/api'
  114. # data = {
  115. # 'code': 1007, # 接口号
  116. # 'uuid': '65dd775c44b74ae33732d7f7', # 用户id(必须项)
  117. # # 'username': 'aabbcc', # 登录账户(可选项)
  118. # # 'password': 'aabbcc', # 登录密码(可选项)(默认值:baosteel@2024)
  119. # # 'role_type': 3, # 角色类型(可选项)(1: 超级管理员 2: 普通管理员 3: 普通用户)
  120. # 'name': 'aabbcc', # 姓名(可选项)
  121. # # 'cid': '112233', # 身份证号(可选项)
  122. # # 'phone': '112233', # 手机号(可选项)
  123. # # 'sex': 0, # 性别(可选项)(0:未设置 1:男 2:女)
  124. # # 'department': 'aabbcc', # 部门(可选项)
  125. # # 'wid': 'aabbcc', # 工号(可选项)
  126. # }
  127. # response = requests.post(url=url, json=data, headers={'authorization': token})
  128. # print(response.json())