Exemplo n.º 1
0
 def test_login_without_password(self):
     request = construct_dummy_request()
     request.json_body = {'nickname': 'Walter'}
     response = apiviews.user_login(request)
     self.assertIn('nickname', request.validated)
     self.assertEqual(400, response.status_code)
     self.assertIsInstance(response, httpexceptions.HTTPError)
Exemplo n.º 2
0
 def test_login_empty_user_is_not_allowed_to_login(self):
     request = construct_dummy_request(json_body={
         'nickname': '',
         'password': '******'
     })
     response = apiviews.user_login(request)
     self.assertEqual(401, response.status_code)
     self.assertIsInstance(response, httpexceptions.HTTPError)
Exemplo n.º 3
0
 def test_valid_login_attempt(self):
     request = construct_dummy_request(json_body={
         'nickname': 'Walter',
         'password': '******'
     })
     response = apiviews.user_login(request)
     self.assertIn('nickname', request.validated)
     self.assertIn('token', response)
     self.assertIn('nickname', response)
Exemplo n.º 4
0
 def test_login_wrong_user(self):
     request = construct_dummy_request(json_body={
         'nickname': r'¯\_(ツ)_/¯',
         'password': '******'
     })
     response = apiviews.user_login(request)
     self.assertIn('nickname', request.validated)
     self.assertEqual(401, response.status_code)
     self.assertIsInstance(response, httpexceptions.HTTPError)
Exemplo n.º 5
0
 def test_login_wrong_password(self, password: str):
     pwd = password.replace('\x00', '')
     pwd = pwd.replace('iamatestuser2016', r'¯\_(ツ)_/¯')
     request = construct_dummy_request(json_body={
         'nickname': 'Walter',
         'password': pwd
     })
     response = apiviews.user_login(request)
     self.assertIn('nickname', request.validated)
     self.assertEqual(401, response.status_code)
     self.assertIsInstance(response, httpexceptions.HTTPError)