2022-07-08 17:24:55 +00:00
|
|
|
import allure
|
|
|
|
import pytest
|
2023-11-29 13:34:59 +00:00
|
|
|
from frostfs_testlib import reporter
|
2023-05-15 09:59:33 +00:00
|
|
|
from frostfs_testlib.resources.wellknown_acl import PRIVATE_ACL_F, PUBLIC_ACL_F, READONLY_ACL_F
|
|
|
|
from frostfs_testlib.shell import Shell
|
|
|
|
from frostfs_testlib.steps.cli.container import create_container
|
|
|
|
from frostfs_testlib.steps.cli.object import put_object_to_random_node
|
|
|
|
from frostfs_testlib.storage.dataclasses.acl import EACLRole
|
|
|
|
from frostfs_testlib.testing.cluster_test_base import ClusterTestBase
|
2023-02-27 16:54:27 +00:00
|
|
|
|
|
|
|
from pytest_tests.helpers.container_access import (
|
2022-09-05 12:12:56 +00:00
|
|
|
check_full_access_to_container,
|
|
|
|
check_no_access_to_container,
|
|
|
|
check_read_only_container,
|
|
|
|
)
|
2023-05-15 09:59:33 +00:00
|
|
|
from pytest_tests.testsuites.acl.conftest import Wallets
|
2022-07-08 17:24:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sanity
|
2022-11-10 05:27:52 +00:00
|
|
|
@pytest.mark.smoke
|
2022-07-08 17:24:55 +00:00
|
|
|
@pytest.mark.acl
|
2022-09-05 12:12:56 +00:00
|
|
|
@pytest.mark.acl_basic
|
2022-12-05 22:31:45 +00:00
|
|
|
class TestACLBasic(ClusterTestBase):
|
2022-09-05 12:12:56 +00:00
|
|
|
@pytest.fixture(scope="function")
|
2024-03-11 16:34:54 +00:00
|
|
|
def public_container(self, wallets: Wallets):
|
2022-08-25 10:57:55 +00:00
|
|
|
user_wallet = wallets.get_wallet()
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Create public container"):
|
2022-10-13 18:53:44 +00:00
|
|
|
cid_public = create_container(
|
2024-03-11 16:34:54 +00:00
|
|
|
user_wallet,
|
2022-12-05 22:31:45 +00:00
|
|
|
basic_acl=PUBLIC_ACL_F,
|
|
|
|
shell=self.shell,
|
|
|
|
endpoint=self.cluster.default_rpc_endpoint,
|
2022-10-13 18:53:44 +00:00
|
|
|
)
|
2022-07-08 17:24:55 +00:00
|
|
|
|
2022-08-25 10:57:55 +00:00
|
|
|
yield cid_public
|
2022-07-08 17:24:55 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
# with reporter.step('Delete public container'):
|
2024-03-11 16:34:54 +00:00
|
|
|
# delete_container(user_wallet, cid_public)
|
2022-07-08 17:24:55 +00:00
|
|
|
|
2022-09-05 12:12:56 +00:00
|
|
|
@pytest.fixture(scope="function")
|
2023-05-15 09:59:33 +00:00
|
|
|
def private_container(self, wallets: Wallets):
|
2022-08-25 10:57:55 +00:00
|
|
|
user_wallet = wallets.get_wallet()
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Create private container"):
|
2022-10-13 18:53:44 +00:00
|
|
|
cid_private = create_container(
|
2024-03-11 16:34:54 +00:00
|
|
|
user_wallet,
|
2022-12-05 22:31:45 +00:00
|
|
|
basic_acl=PRIVATE_ACL_F,
|
|
|
|
shell=self.shell,
|
|
|
|
endpoint=self.cluster.default_rpc_endpoint,
|
2022-10-13 18:53:44 +00:00
|
|
|
)
|
2022-07-08 17:24:55 +00:00
|
|
|
|
2022-08-25 10:57:55 +00:00
|
|
|
yield cid_private
|
2022-07-08 17:24:55 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
# with reporter.step('Delete private container'):
|
2024-03-11 16:34:54 +00:00
|
|
|
# delete_container(user_wallet, cid_private)
|
2022-07-08 17:24:55 +00:00
|
|
|
|
2022-09-05 12:12:56 +00:00
|
|
|
@pytest.fixture(scope="function")
|
2023-05-15 09:59:33 +00:00
|
|
|
def read_only_container(self, wallets: Wallets):
|
2022-08-25 10:57:55 +00:00
|
|
|
user_wallet = wallets.get_wallet()
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Create public readonly container"):
|
2022-10-13 18:53:44 +00:00
|
|
|
cid_read_only = create_container(
|
2024-03-11 16:34:54 +00:00
|
|
|
user_wallet,
|
2022-12-05 22:31:45 +00:00
|
|
|
basic_acl=READONLY_ACL_F,
|
|
|
|
shell=self.shell,
|
|
|
|
endpoint=self.cluster.default_rpc_endpoint,
|
2022-10-13 18:53:44 +00:00
|
|
|
)
|
2022-07-08 17:24:55 +00:00
|
|
|
|
2022-08-25 10:57:55 +00:00
|
|
|
yield cid_read_only
|
2022-07-08 17:24:55 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
# with reporter.step('Delete public readonly container'):
|
2024-03-11 16:34:54 +00:00
|
|
|
# delete_container(user_wallet, cid_read_only)
|
2022-07-08 17:24:55 +00:00
|
|
|
|
2023-09-08 10:35:34 +00:00
|
|
|
@allure.title("Operations with basic ACL on public container (obj_size={object_size})")
|
2023-05-15 09:59:33 +00:00
|
|
|
def test_basic_acl_public(self, wallets: Wallets, public_container: str, file_path: str):
|
2022-08-25 10:57:55 +00:00
|
|
|
"""
|
|
|
|
Test basic ACL set during public container creation.
|
|
|
|
"""
|
|
|
|
user_wallet = wallets.get_wallet()
|
|
|
|
other_wallet = wallets.get_wallet(role=EACLRole.OTHERS)
|
|
|
|
cid = public_container
|
2022-09-05 12:12:56 +00:00
|
|
|
for wallet, desc in ((user_wallet, "owner"), (other_wallet, "other users")):
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Add test objects to container"):
|
2022-09-05 12:12:56 +00:00
|
|
|
# We create new objects for each wallet because check_full_access_to_container
|
|
|
|
# deletes the object
|
2022-12-05 22:31:45 +00:00
|
|
|
owner_object_oid = put_object_to_random_node(
|
2024-03-11 16:34:54 +00:00
|
|
|
user_wallet,
|
2022-09-05 12:12:56 +00:00
|
|
|
file_path,
|
|
|
|
cid,
|
2022-12-05 22:31:45 +00:00
|
|
|
shell=self.shell,
|
|
|
|
cluster=self.cluster,
|
2022-09-05 12:12:56 +00:00
|
|
|
attributes={"created": "owner"},
|
|
|
|
)
|
2022-12-05 22:31:45 +00:00
|
|
|
other_object_oid = put_object_to_random_node(
|
2024-03-11 16:34:54 +00:00
|
|
|
other_wallet,
|
2022-09-05 12:12:56 +00:00
|
|
|
file_path,
|
|
|
|
cid,
|
2022-12-05 22:31:45 +00:00
|
|
|
shell=self.shell,
|
|
|
|
cluster=self.cluster,
|
2022-09-05 12:12:56 +00:00
|
|
|
attributes={"created": "other"},
|
|
|
|
)
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step(f"Check {desc} has full access to public container"):
|
2022-10-13 18:53:44 +00:00
|
|
|
check_full_access_to_container(
|
2024-03-11 16:34:54 +00:00
|
|
|
wallet,
|
2022-12-05 22:31:45 +00:00
|
|
|
cid,
|
|
|
|
owner_object_oid,
|
|
|
|
file_path,
|
|
|
|
shell=self.shell,
|
|
|
|
cluster=self.cluster,
|
2022-10-13 18:53:44 +00:00
|
|
|
)
|
|
|
|
check_full_access_to_container(
|
2024-03-11 16:34:54 +00:00
|
|
|
wallet,
|
2022-12-05 22:31:45 +00:00
|
|
|
cid,
|
|
|
|
other_object_oid,
|
|
|
|
file_path,
|
|
|
|
shell=self.shell,
|
|
|
|
cluster=self.cluster,
|
2022-10-13 18:53:44 +00:00
|
|
|
)
|
2022-09-05 12:12:56 +00:00
|
|
|
|
2023-09-08 10:35:34 +00:00
|
|
|
@allure.title("Operations with basic ACL on PRIVATE container (obj_size={object_size})")
|
2023-05-15 09:59:33 +00:00
|
|
|
def test_basic_acl_private(self, wallets: Wallets, private_container: str, file_path: str):
|
2022-08-25 10:57:55 +00:00
|
|
|
"""
|
|
|
|
Test basic ACL set during private container creation.
|
|
|
|
"""
|
|
|
|
user_wallet = wallets.get_wallet()
|
|
|
|
other_wallet = wallets.get_wallet(role=EACLRole.OTHERS)
|
|
|
|
cid = private_container
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Add test objects to container"):
|
2024-06-24 23:27:54 +00:00
|
|
|
owner_object_oid = put_object_to_random_node(user_wallet, file_path, cid, self.shell, self.cluster)
|
2022-07-08 17:24:55 +00:00
|
|
|
|
2024-06-24 23:27:54 +00:00
|
|
|
with reporter.step("Check no one except owner has access to operations with container"):
|
|
|
|
check_no_access_to_container(other_wallet, cid, owner_object_oid, file_path, self.shell, self.cluster)
|
2022-07-08 17:24:55 +00:00
|
|
|
|
2024-06-24 23:27:54 +00:00
|
|
|
with reporter.step("Check owner has full access to private container"):
|
|
|
|
check_full_access_to_container(user_wallet, cid, owner_object_oid, file_path, self.shell, self.cluster)
|
2022-07-08 17:24:55 +00:00
|
|
|
|
2023-09-08 10:35:34 +00:00
|
|
|
@allure.title("Operations with basic ACL on READONLY container (obj_size={object_size})")
|
2023-11-29 13:34:59 +00:00
|
|
|
def test_basic_acl_readonly(self, wallets: Wallets, client_shell: Shell, read_only_container: str, file_path: str):
|
2022-08-25 10:57:55 +00:00
|
|
|
"""
|
|
|
|
Test basic ACL Operations for Read-Only Container.
|
|
|
|
"""
|
|
|
|
user_wallet = wallets.get_wallet()
|
|
|
|
other_wallet = wallets.get_wallet(role=EACLRole.OTHERS)
|
|
|
|
cid = read_only_container
|
2022-07-08 17:24:55 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Add test objects to container"):
|
2024-06-24 23:27:54 +00:00
|
|
|
object_oid = put_object_to_random_node(user_wallet, file_path, cid, client_shell, self.cluster)
|
2022-07-08 17:24:55 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Check other has read-only access to operations with container"):
|
2024-06-24 23:27:54 +00:00
|
|
|
check_read_only_container(other_wallet, cid, object_oid, file_path, client_shell, self.cluster)
|
2022-09-05 12:12:56 +00:00
|
|
|
|
2023-11-29 13:34:59 +00:00
|
|
|
with reporter.step("Check owner has full access to public container"):
|
2024-06-24 23:27:54 +00:00
|
|
|
check_full_access_to_container(user_wallet, cid, object_oid, file_path, client_shell, self.cluster)
|