mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-22 04:54:18 +00:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
28979d7f8a
2 changed files with 37 additions and 7 deletions
|
@ -8,13 +8,13 @@ auth_code = ""
|
||||||
class MyTestCase(unittest.TestCase):
|
class MyTestCase(unittest.TestCase):
|
||||||
def test_login(self):
|
def test_login(self):
|
||||||
global auth_code
|
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)
|
j = json.loads(r.text)
|
||||||
assert j['result'] == "failure"
|
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)
|
j = json.loads(r.text)
|
||||||
assert j['result'] == "failure"
|
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)
|
j = json.loads(r.text)
|
||||||
assert j['result'] == "success"
|
assert j['result'] == "success"
|
||||||
auth_code = j['data']['access_token']
|
auth_code = j['data']['access_token']
|
||||||
|
|
|
@ -9,18 +9,48 @@ class MyTestCase(unittest.TestCase):
|
||||||
def test_user_delete(self):
|
def test_user_delete(self):
|
||||||
global auth_code
|
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)
|
j = json.loads(r.text)
|
||||||
assert j['result'] == "success"
|
assert j['result'] == "success"
|
||||||
auth_code = j['data']['access_token']
|
auth_code = j['data']['access_token']
|
||||||
|
|
||||||
r = requests.post(f'http://localhost:5000/api/user/remove', headers={'authorization': "Bearer " + auth_code},
|
# elimino ma non sono admin
|
||||||
json={'email': 'utente_test@nest.com'})
|
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/utente3@nest.com',
|
||||||
|
headers={'authorization': "Bearer " + auth_code},)
|
||||||
j = json.loads(r.text)
|
j = json.loads(r.text)
|
||||||
assert j['result'] == "success"
|
assert j['result'] == "success"
|
||||||
|
|
||||||
print("User_delete eseguito correttamente!")
|
print("User_delete eseguito correttamente!")
|
||||||
|
|
||||||
print("Testing del metodo user_delete")
|
print("Testing del metodo user delete")
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue