mirror of
https://github.com/wekan/wekan.git
synced 2025-12-29 13:48:49 +01:00
test_login solution
This commit is contained in:
parent
20f91ef893
commit
c9ae1feddf
2 changed files with 53 additions and 0 deletions
4
pytest.ini
Normal file
4
pytest.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[pytest]
|
||||
testpasths=test
|
||||
addopts= -s
|
||||
|
||||
49
tests_r/test_endpoint.py
Normal file
49
tests_r/test_endpoint.py
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import unittest
|
||||
import requests
|
||||
|
||||
class TestUserLogin(unittest.TestCase):
|
||||
def test_user_login_success(self):
|
||||
url = "http://localhost:80/users/login"
|
||||
payload = {
|
||||
"username": "rabeeaFaraj",
|
||||
"password": "30fnhk03"
|
||||
}
|
||||
response = requests.post(url, json=payload)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertIn("token", response.json())
|
||||
|
||||
def test_user_login_wrong_password(self):
|
||||
url = "http://localhost:80/users/login"
|
||||
payload = {
|
||||
"username": "rabeeaFaraj",
|
||||
"password": "wrongpassword"
|
||||
}
|
||||
response = requests.post(url, json=payload)
|
||||
self.assertEqual(response.status_code, 400) # או 400 בהתאם למימוש
|
||||
self.assertIn("error", response.json())
|
||||
|
||||
def test_user_login_missing_fields(self):
|
||||
url = "http://localhost:80/users/login"
|
||||
payload = {
|
||||
"username": "rabeeaFaraj"
|
||||
# חסר שדה סיסמה
|
||||
}
|
||||
response = requests.post(url, json=payload)
|
||||
self.assertEqual(response.status_code, 400)
|
||||
self.assertIn("error", response.json())
|
||||
|
||||
def test_user_login_nonexistent_user(self):
|
||||
url = "http://localhost:80/users/login"
|
||||
payload = {
|
||||
"username": "notexist",
|
||||
"password": "any"
|
||||
}
|
||||
response = requests.post(url, json=payload)
|
||||
|
||||
self.assertEqual(response.status_code, 400) # או 404 בהתאם למימוש
|
||||
self.assertIn("error", response.json())
|
||||
|
||||
# ana btal
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue