forked from kompetenzinventar/ki-backend
27 lines
931 B
Python
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()
|