From b96e19a7eafd27fba566b81aecb361b0acd9296f Mon Sep 17 00:00:00 2001 From: Roy Willy Haug <5484176+roywilly@users.noreply.github.com> Date: Mon, 24 Jun 2024 11:34:33 +0200 Subject: [PATCH] Add more delete tests using test identities (#333) --- .../test_access/tst_access_drogon_read_login.py | 17 +++++++++++++++++ tests/test_access/tst_access_no_access_login.py | 15 +++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/tests/test_access/tst_access_drogon_read_login.py b/tests/test_access/tst_access_drogon_read_login.py index d38c29d4..f314cd4d 100644 --- a/tests/test_access/tst_access_drogon_read_login.py +++ b/tests/test_access/tst_access_drogon_read_login.py @@ -75,6 +75,23 @@ def test_write(explorer: Explorer): print("Execution should never reach this line") +def test_delete(explorer: Explorer): + """Test a delete method""" + print("Running test:", inspect.currentframe().f_code.co_name) + + with pytest.raises(Exception, match="403*"): + res = explorer._sumo.delete(f"/objects('dcff880f-b35b-3598-08bc-2a408c85d204')") + print("Execution should never reach this line") + print("Unexpected status: ", res.status_code) + print("Unexpected response: ", res.text) + + with pytest.raises(Exception, match="403*"): + res = explorer._sumo.delete(f"/objects('392c3c70-dd1a-41b5-ac49-0e369a0ac4eb')") + print("Execution should never reach this line") + print("Unexpected status: ", res.status_code) + print("Unexpected response: ", res.text) + + def test_read_restricted_classification_data(explorer: Explorer): """Test if can read restriced data aka 'access:classification: restricted'""" print("Running test:", inspect.currentframe().f_code.co_name) diff --git a/tests/test_access/tst_access_no_access_login.py b/tests/test_access/tst_access_no_access_login.py index 5322a91d..af0e58b5 100644 --- a/tests/test_access/tst_access_no_access_login.py +++ b/tests/test_access/tst_access_no_access_login.py @@ -77,6 +77,21 @@ def test_write(explorer: Explorer): print("Unexpected status: ", response.status_code) print("Unexpected response: ", response.text) +def test_delete(explorer: Explorer): + """Test a delete method""" + print("Running test:", inspect.currentframe().f_code.co_name) + + with pytest.raises(Exception, match="403*"): + res = explorer._sumo.delete(f"/objects('dcff880f-b35b-3598-08bc-2a408c85d204')") + print("Execution should never reach this line") + print("Unexpected status: ", res.status_code) + print("Unexpected response: ", res.text) + + with pytest.raises(Exception, match="403*"): + res = explorer._sumo.delete(f"/objects('392c3c70-dd1a-41b5-ac49-0e369a0ac4eb')") + print("Execution should never reach this line") + print("Unexpected status: ", res.status_code) + print("Unexpected response: ", res.text) def test_read_restricted_classification_data(explorer: Explorer): """Test if can read restriced data aka 'access:classification: restricted'"""