forked from kompetenzinventar/ki-backend
31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
# SPDX-FileCopyrightText: WTF Kooperative eG <https://wtf-eg.de/>
|
|
#
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
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()
|