1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-22 04:54:18 +00:00

inserito test con utente non amministratore

This commit is contained in:
stefanogoldoni 2021-04-29 00:32:06 +02:00
parent 5b28931e9d
commit 0b09d2274a

View file

@ -10,16 +10,30 @@ class MyTestCase(unittest.TestCase):
def test_user_create(self):
global auth_code
# testo come admin: successo
r = requests.post('http://localhost:5000/api/login', json={'email': 'admin@admin.com', 'password': 'password'})
j = json.loads(r.text)
assert j['result'] == "success"
auth_code = j['data']['access_token']
r = requests.post(f'http://localhost:5000/api/user/create', headers={'authorization': "Bearer " + auth_code},
json={'email': 'utente_test@nest.com', 'password': 'password', 'username': 'utente'})
json={'email': 'utente_test@nest.com', 'password': 'password', 'username': 'utente_test'})
j = json.loads(r.text)
assert j['result'] == "success"
# testo come utente normale: fallisce
auth_code = ""
r = requests.post('http://localhost:5000/api/login', json={'email': 'utente_test@nest.com', 'password': 'password'})
j = json.loads(r.text)
assert j['result'] == "success"
auth_code = j['data']['access_token']
r = requests.post(f'http://localhost:5000/api/user/create', headers={'authorization': "Bearer " + auth_code},
json={'email': 'utente_test_2@nest.com', 'password': 'password', 'username': 'utente_test_2'})
j = json.loads(r.text)
assert j['result'] == "failure"
print("User_create eseguito correttamente!")