From f1b8838361fbf908f8c0deb5ee0e7f4af0746e0c Mon Sep 17 00:00:00 2001 From: Annielated Date: Tue, 25 May 2021 00:47:51 +0200 Subject: [PATCH] primi test sulle autorizzazioni --- nest_backend/test/test_5_authorizations.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 nest_backend/test/test_5_authorizations.py diff --git a/nest_backend/test/test_5_authorizations.py b/nest_backend/test/test_5_authorizations.py new file mode 100644 index 0000000..f2f54fb --- /dev/null +++ b/nest_backend/test/test_5_authorizations.py @@ -0,0 +1,20 @@ +from flask.testing import Client + +'''A file that contains tests classes and methods for all the requests concerning authorizations .''' + + +class TestAuthozitazionsGet: + def test_for_success(self, flask_client: Client, user_headers): + r = flask_client.get('/api/v1/repositories/1/authorizations/', headers=user_headers) + assert r.status_code == 200 + assert r.json["result"] == "success" + + def test_get_non_existing_repository(self, flask_client: Client, admin_headers): + r = flask_client.get('/api/v1/repositories/99/authorizations/', headers=admin_headers) + assert r.status_code == 404 + assert r.json["result"] == "failure" + + def test_wrong_owner(self, flask_client: Client, admin_headers): + r = flask_client.get(f'/api/v1/repositories/1/authorizations/', headers=admin_headers) + assert r.status_code == 403 + assert r.json["result"] == "failure"