|
66 | 66 | "read:metadata", |
67 | 67 | "write:data", |
68 | 68 | "write:metadata", |
| 69 | + "delete:node", |
| 70 | + "delete:revision", |
69 | 71 | "create", |
70 | 72 | "register", |
71 | 73 | ] |
@@ -651,6 +653,23 @@ def test_writing_access_control(access_control_test_context_factory): |
651 | 653 | sue_client[top].write_array(arr, key="data_X", access_tags=["chemists_tag"]) |
652 | 654 |
|
653 | 655 |
|
| 656 | +def test_deletion_access_control(access_control_test_context_factory): |
| 657 | + """ |
| 658 | + Test that deletion access control is working. |
| 659 | + Only tests that the deletion request does not fail. |
| 660 | + Does not test that data is actually deleted. |
| 661 | + """ |
| 662 | + |
| 663 | + alice_client = access_control_test_context_factory("alice", "alice") |
| 664 | + chris_client = access_control_test_context_factory("chris", "chris") |
| 665 | + |
| 666 | + top = "foo" |
| 667 | + alice_client[top].write_array(arr, key="data_H", access_tags=["alice_tag"]) |
| 668 | + with fail_with_status_code(HTTP_403_FORBIDDEN): |
| 669 | + chris_client[top]["data_H"].delete(external_only=False) |
| 670 | + alice_client[top]["data_H"].delete(external_only=False) |
| 671 | + |
| 672 | + |
654 | 673 | def test_user_owned_node_access_control(access_control_test_context_factory): |
655 | 674 | """ |
656 | 675 | Test that user-owned nodes (i.e. nodes created without access tags applied) |
@@ -756,6 +775,8 @@ def test_update_node_access_control(access_control_test_context_factory): |
756 | 775 | This tests the following: |
757 | 776 | - Update metadata while having write access |
758 | 777 | - Prevent updating metadata without having write access |
| 778 | + - Prevent deleting a metadata revision without having deletion access |
| 779 | + - Delete a metadata revision while having deletion access |
759 | 780 | - Successfully add an access tag and remove an access tag |
760 | 781 | - Prevent adding or removing an access tag without having write access |
761 | 782 | - Prevent adding or removing access tags which the user does not own |
@@ -783,6 +804,13 @@ def test_update_node_access_control(access_control_test_context_factory): |
783 | 804 | ) |
784 | 805 | assert "Au" not in chris_client[top][data].metadata["materials"] |
785 | 806 |
|
| 807 | + # fails to delete a metadata revision |
| 808 | + with fail_with_status_code(HTTP_403_FORBIDDEN): |
| 809 | + chris_client[top][data].metadata_revisions.delete_revision(1) |
| 810 | + |
| 811 | + # succeeds to delete a metadata revision |
| 812 | + alice_client[top][data].metadata_revisions.delete_revision(1) |
| 813 | + |
786 | 814 | # succeeds to add a new access tag and remove the old access tag |
787 | 815 | alice_client[top][data].replace_metadata(access_tags=["biologists_tag"]) |
788 | 816 | access_tags = alice_client[top][data].access_blob["tags"] |
|
0 commit comments