From deefe6841a7416fe82c51d0277d98f823dd11078 Mon Sep 17 00:00:00 2001 From: stefanogoldoni Date: Thu, 29 Apr 2021 22:46:30 +0200 Subject: [PATCH 1/3] eliminate print di controllo --- code/backend/nest_backend/test/login_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/backend/nest_backend/test/login_test.py b/code/backend/nest_backend/test/login_test.py index 27a8758..f810295 100644 --- a/code/backend/nest_backend/test/login_test.py +++ b/code/backend/nest_backend/test/login_test.py @@ -8,13 +8,13 @@ auth_code = "" class MyTestCase(unittest.TestCase): def test_login(self): global auth_code - r = requests.post('http://localhost:5000/api/login', json={'email': 'admin@admin.com', 'password': 'amogus'}) + r = requests.post('http://localhost:5000/api/v1/login', json={'email': 'admin@admin.com', 'password': 'amogus'}) j = json.loads(r.text) assert j['result'] == "failure" - r = requests.post('http://localhost:5000/api/login', json={'email': '', 'password': ''}) + r = requests.post('http://localhost:5000/api/v1/login', json={'email': '', 'password': ''}) j = json.loads(r.text) assert j['result'] == "failure" - r = requests.post('http://localhost:5000/api/login', json={'email': 'admin@admin.com', 'password': 'password'}) + 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'] From be7820521c99c290d4350a3447888f60d9407fe1 Mon Sep 17 00:00:00 2001 From: stefanogoldoni Date: Fri, 30 Apr 2021 00:06:23 +0200 Subject: [PATCH 2/3] =?UTF-8?q?manca=20test=20della=20delete=20perch=C3=A8?= =?UTF-8?q?=20il=20server=20da=20errore=20500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nest_backend/test/user_delete_test.py | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) 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" From 549877fb5353fe6dcff36959785f40e53b6f4ced Mon Sep 17 00:00:00 2001 From: stefanogoldoni Date: Fri, 30 Apr 2021 00:12:25 +0200 Subject: [PATCH 3/3] delete testata in tutti i metodi --- code/backend/nest_backend/test/user_delete_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/backend/nest_backend/test/user_delete_test.py b/code/backend/nest_backend/test/user_delete_test.py index 747381b..bb83b20 100644 --- a/code/backend/nest_backend/test/user_delete_test.py +++ b/code/backend/nest_backend/test/user_delete_test.py @@ -44,13 +44,13 @@ class MyTestCase(unittest.TestCase): print("delete User NON eseguito correttamente!") - r = requests.delete(f'http://localhost:5000/api/v1/users/utente12@nest.com', + r = requests.delete(f'http://localhost:5000/api/v1/users/utente3@nest.com', headers={'authorization': "Bearer " + auth_code},) j = json.loads(r.text) assert j['result'] == "success" print("User_delete eseguito correttamente!") - print("Testing del metodo user_delete") + print("Testing del metodo user delete")