def test_check_success(self):
     service = AuthService(self.repo)
     token = 'access token 1'
     user = self.repo.get_by_access_token(token)
     expected = ({'user_id': user.get('id')}, 200)
     actual = service.check(token)
     self.assertEqual(actual, expected)
 def test_refresh_failure(self):
     service = AuthService(self.repo)
     token = 'refresh token invalid'
     expected = ({'message': INVALID_TOKEN_ERROR}, 401)
     actual = service.refresh(token)
     self.assertEqual(actual, expected)
 def test_refresh_success(self):
     service = AuthService(self.repo)
     token = 'refresh token 1'
     expected = (self.repo.get_by_refresh_token(token), 200)
     actual = service.refresh(token)
     self.assertEqual(actual, expected)
 def test_check_failure(self):
     service = AuthService(self.repo)
     token = 'access token invalid'
     expected = ({'message': INVALID_TOKEN_ERROR}, 401)
     actual = service.check(token)
     self.assertEqual(actual, expected)
 def test_verify_success(self):
     service = AuthService(self.repo)
     token = 'access token 1'
     expected = (self.repo.get_by_access_token(token), 200)
     actual = service.verify(token)
     self.assertEqual(actual, expected)
 def test_log_in_invalid_password(self):
     service = AuthService(self.repo)
     email = '*****@*****.**'
     expected = ({'message': LOGIN_ERROR}, 400)
     actual = service.log_in(email, 'invalid')
     self.assertEqual(actual, expected)
 def test_log_in_success(self):
     service = AuthService(self.repo)
     email = '*****@*****.**'
     expected = (self.repo.get_by_email(email), 200)
     actual = service.log_in(email, 'passw0rd')
     self.assertEqual(actual, expected)
示例#8
0
 def create():
     with open(os.path.join(BASE_DIR, 'storage/users.json'), 'r') as f:
         repo = UserRepo(f.read())
         return AuthService(repo)
示例#9
0
class AuthBaseResource(Resource):
    auth_service = AuthService()