diff --git a/code/backend/nest_backend/test/user_delete_test.py b/code/backend/nest_backend/test/user_delete_test.py index c7d87f3..747381b 100644 --- a/code/backend/nest_backend/test/user_delete_test.py +++ b/code/backend/nest_backend/test/user_delete_test.py @@ -9,13 +9,43 @@ class MyTestCase(unittest.TestCase): def test_user_delete(self): global auth_code - r = requests.post('http://localhost:5000/api/login', json={'email': 'admin@admin.com', 'password': 'password'}) + # sono un utente normale + r = requests.post('http://localhost:5000/api/v1/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/remove', headers={'authorization': "Bearer " + auth_code}, - json={'email': 'utente_test@nest.com'}) + # elimino ma non sono admin + r = requests.delete(f'http://localhost:5000/api/v1/users/admin@admin.com', + headers={'authorization': "Bearer " + auth_code},) + j = json.loads(r.text) + assert j['result'] == "failure" + + print("delete User NON eseguito correttamente!") + + # adesso divento admin + r = requests.post('http://localhost:5000/api/v1/login', json={'email': 'admin@admin.com', 'password': 'password'}) + j = json.loads(r.text) + assert j['result'] == "success" + auth_code = j['data']['access_token'] + + # elimino un utente che non c'รจ + r = requests.delete(f'http://localhost:5000/api/v1/users/none@nest.com', + headers={'authorization': "Bearer " + auth_code},) + j = json.loads(r.text) + assert j['result'] == "failure" + + print("delete User NON eseguito correttamente!") + + r = requests.delete(f'http://localhost:5000/api/v1/users/admin@admin.com', + headers={'authorization': "Bearer " + auth_code},) + j = json.loads(r.text) + assert j['result'] == "failure" + + print("delete User NON eseguito correttamente!") + + r = requests.delete(f'http://localhost:5000/api/v1/users/utente12@nest.com', + headers={'authorization': "Bearer " + auth_code},) j = json.loads(r.text) assert j['result'] == "success"