From 4492ee7c4adcea89262c583446356f64923817cf Mon Sep 17 00:00:00 2001 From: Evgeniy Zayats Date: Thu, 11 Apr 2024 00:01:19 -0400 Subject: [PATCH] tests: add test to verify api header size limitation, closes #740 Signed-off-by: Evgeniy Zayats --- pytest_tests/lib/helpers/grpc_responses.py | 1 + pytest_tests/lib/helpers/neofs_verbs.py | 3 +++ pytest_tests/tests/object/test_object_api.py | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/pytest_tests/lib/helpers/grpc_responses.py b/pytest_tests/lib/helpers/grpc_responses.py index df86b431c..3e4597594 100644 --- a/pytest_tests/lib/helpers/grpc_responses.py +++ b/pytest_tests/lib/helpers/grpc_responses.py @@ -19,6 +19,7 @@ # LOCK_NON_REGULAR_OBJECT = "code = 2051.*message = ..." will be available once 2092 is fixed OBJECT_IS_LOCKED = "code = 2050" LOCK_NON_REGULAR_OBJECT = "code = 2051" +OBJECT_HEADER_LENGTH_LIMIT = ".*object header length exceeds the limit.*" LIFETIME_REQUIRED = ".*at least one of the flags in the group [expire-at lifetime] is required.*" LOCK_OBJECT_REMOVAL = "lock object removal" diff --git a/pytest_tests/lib/helpers/neofs_verbs.py b/pytest_tests/lib/helpers/neofs_verbs.py index 82191ca34..557a06c4d 100644 --- a/pytest_tests/lib/helpers/neofs_verbs.py +++ b/pytest_tests/lib/helpers/neofs_verbs.py @@ -15,6 +15,9 @@ logger = logging.getLogger("NeoLogger") +# https://github.com/nspcc-dev/neofs-api/blob/5c3535423c564fe63991812cb84d8334db1c553a/object/service.proto#L319 +NEOFS_API_HEADER_LIMIT = 16384 + @allure.step("Get object from random node") def get_object_from_random_node( diff --git a/pytest_tests/tests/object/test_object_api.py b/pytest_tests/tests/object/test_object_api.py index 551facdf9..5670b5af8 100755 --- a/pytest_tests/tests/object/test_object_api.py +++ b/pytest_tests/tests/object/test_object_api.py @@ -19,9 +19,11 @@ INVALID_RANGE_OVERFLOW, INVALID_RANGE_ZERO_LENGTH, INVALID_SEARCH_QUERY, + OBJECT_HEADER_LENGTH_LIMIT, OUT_OF_RANGE, ) from helpers.neofs_verbs import ( + NEOFS_API_HEADER_LIMIT, get_object_from_random_node, get_range, get_range_hash, @@ -736,6 +738,22 @@ def test_object_get_range_hash_negatives( endpoint=self.neofs_env.sn_rpc, range_cut=range_cut, ) + + def test_put_object_header_limitation( + self, default_wallet: NodeWallet, container: str, simple_object_size: int + ): + file_path = generate_file(simple_object_size) + attr_key = "a" * (NEOFS_API_HEADER_LIMIT // 2) + attr_val = "b" * (NEOFS_API_HEADER_LIMIT // 2) + with pytest.raises(Exception, match=OBJECT_HEADER_LENGTH_LIMIT): + put_object_to_random_node( + default_wallet.path, + file_path, + container, + shell=self.shell, + neofs_env=self.neofs_env, + attributes={attr_key: attr_val} + ) def check_header_is_presented(self, head_info: dict, object_header: dict) -> None: for key_to_check, val_to_check in object_header.items():