예제 #1
0
    def test_authentication_without_username(self):
        result, status = authentication(
            {
                'username': None,
                'password': self.user['password']
            }
        )

        self.assertEqual(status, 401)
        self.assertEqual(result, "O nome de usuário e senha são obrigatórios")
예제 #2
0
    def test_authentication_with_inexisting_user(self):
        result, status = authentication(
            {
                'username': '******',
                'password': self.user['password']
            }
        )

        self.assertEqual(status, 404)
        self.assertEqual(result, "Not Found!")
예제 #3
0
    def test_authentication(self):
        result, status = authentication(
            {
                'username': self.user['username'],
                'password': '******'
            }
        )
        self.assertEqual(status, 401)
        self.assertEqual(result, 'Senha inválida')

        result, status = authentication(
            {
                'username': self.user['username'],
                'password': self.user['password']
            }
        )
        self.assertEqual(status, 200)
        self.assertEqual(result['msg'], 'Login bem sucedido')

        result, status = authentication()
        self.assertEqual(status, 401)
        self.assertEqual(result, 'É necessário realizar o login')
def make_auth():
    response, status = controller.authentication(request.authorization)

    return create_response(response, status)