ki-backend/ki/test/test_login_endpoint.py
Michael Weimann 78c539c30a
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
implement auth
2021-06-27 14:25:44 +02:00

27 lines
931 B
Python

import json
import unittest
from ki.test.ApiTest import ApiTest
class TestLoginEndpoint(ApiTest):
def test_login(self):
response1_data = self.login("peter", "geheim")
response2_data = self.login("peter", "geheim")
self.assertNotEqual(response1_data["token"], response2_data["token"])
def test_login_wrong_credentails(self):
login_data = {"username": "peter", "password": "123456"}
login_response = self.client.post("/users/login", data=json.dumps(login_data), content_type="application/json")
self.assertEqual(login_response.status_code, 403)
def test_login_unknown_user(self):
login_data = {"username": "karl", "password": "123456"}
login_response = self.client.post("/users/login", data=json.dumps(login_data), content_type="application/json")
self.assertEqual(login_response.status_code, 403)
if __name__ == "main":
unittest.main()