Skip to content

Commit

Permalink
tests: add test to verify api header size limitation, closes #740
Browse files Browse the repository at this point in the history
Signed-off-by: Evgeniy Zayats <[email protected]>
  • Loading branch information
Evgeniy Zayats committed Apr 12, 2024
1 parent 02ba9c4 commit 4492ee7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions pytest_tests/lib/helpers/grpc_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions pytest_tests/lib/helpers/neofs_verbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
18 changes: 18 additions & 0 deletions pytest_tests/tests/object/test_object_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 4492ee7

Please sign in to comment.