Exemplo n.º 1
0
 def test_auth_chgpwd_oldpassword_error(self):
     ''' 旧密码不正确 '''
     payload = {'oldpassword': '******', 'newpassword': '******', 'token': globaldata.get_token()}
     r = requests.post(self.base_url, data=payload)
     self.result = r.json()
     self.assertEqual(self.result['error_code'], 213008)
     self.assertEqual(self.result['error'], 'No old password')
Exemplo n.º 2
0
 def test_auth_chgpwd_newpassword_not_exist(self):
     ''' 新密码未填写 '''
     payload = {'oldpassword': '******', 'newpassword': '', 'token': globaldata.get_token()}
     r = requests.post(self.base_url,data=payload)
     self.result = r.json()
     self.assertEqual(self.result['error_code'], 400410)
     self.assertEqual(self.result['error'], 'The {attribute} field is required.')
Exemplo n.º 3
0
 def test_user_add_username_success(self):
     ''' 新增用户成功 '''
     payload = {
         'username': '******',
         'password': '******',
         'token': globaldata.get_token()
     }
     r = requests.post(self.base_url, data=payload)
     self.result = r.json()
     self.assertEqual(self.result['username'], 'yayatest2')
Exemplo n.º 4
0
 def test_auth_Resetpwd_success(self):
     ''' 重置成功 '''
     payload = {
         'username': '******',
         'password': '******',
         'token': globaldata.get_token()
     }
     r = requests.post(self.base_url, data=payload)
     self.result = r.json()
     self.assertEqual(self.result['result'], True)
Exemplo n.º 5
0
 def test_auth_Resetpwd_username_not_exist(self):
     ''' 用户名不存在 '''
     payload = {
         'username': '******',
         'password': '******',
         'token': globaldata.get_token()
     }
     r = requests.post(self.base_url, data=payload)
     self.result = r.json()
     self.assertEqual(self.result['error_code'], 213007)
     self.assertEqual(self.result['error'], '未找到账号who')
Exemplo n.º 6
0
 def test_auth_login_success(self):
     ''' 登录成功 '''
     payload = {'username': '******', 'password': '******'}
     r = requests.post(self.base_url, data=payload)
     self.result = r.json()
     self.assertEqual(self.result['username'], 'yayatest')
     login_token = self.result['token']
     print(login_token)
     globaldata.set_token(login_token)
     t = globaldata.get_token()
     print(t)
Exemplo n.º 7
0
 def test_user_add_password_not_set(self):
     ''' 密码未设置'''
     payload = {
         'username': '******',
         'password': '',
         'token': globaldata.get_token()
     }
     r = requests.post(self.base_url, data=payload)
     self.result = r.json()
     self.assertEqual(self.result['error_code'], 500405)
     self.assertEqual(self.result['error'], 'loop.user.password')
Exemplo n.º 8
0
 def test_auth_Resetpwd_password_not_exist(self):
     ''' 密码未填写 '''
     payload = {
         'username': '******',
         'password': '',
         'token': globaldata.get_token()
     }
     r = requests.post(self.base_url, data=payload)
     self.result = r.json()
     self.assertEqual(self.result['error_code'], 400410)
     self.assertEqual(self.result['error'],
                      'The {attribute} field is required.')
Exemplo n.º 9
0
 def test_user_add_username_exist(self):
     ''' 用户名已存在'''
     payload = {
         'username': '******',
         'password': '******',
         'token': globaldata.get_token()
     }
     r = requests.post(self.base_url, data=payload)
     self.result = r.json()
     # TODO:抛错,返回码未知
     self.assertEqual(self.result['error_code'], 500405)
     self.assertEqual(self.result['error'], 'loop.user.password')
Exemplo n.º 10
0
 def test_auth_logout_success(self):
     ''' 密码修改成功 '''
     payload = {'token': globaldata.get_token()}
     r = requests.post(self.base_url, data=payload)
     self.result = r.json()
     self.assertEqual(self.result['result'], True)
Exemplo n.º 11
0
 def test_auth_chgpwd_success(self):
     ''' 密码修改成功 '''
     payload = {'oldpassword': '******', 'newpassword': '******', 'token': globaldata.get_token()}
     r = requests.post(self.base_url,data=payload)
     self.result = r.json()
     self.assertEqual(self.result['result'], True)