Skip to content

Commit

Permalink
tests: fix tests wrt update node behavior for session tokens (#875)
Browse files Browse the repository at this point in the history
closes #872
  • Loading branch information
roman-khimov authored Oct 9, 2024
2 parents 5c72458 + dbb1aed commit 3d209c6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
7 changes: 7 additions & 0 deletions neofs-testlib/neofs_testlib/env/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,13 @@ def _wait_until_ready(self):
assert "Health status: READY" in result.stdout, "Health is not ready"
assert "Network status: ONLINE" in result.stdout, "Network is not online"

def _get_version(self) -> str:
raw_version_output = self.neofs_env._run_single_command(self.neofs_env.neofs_node_path, "--version")
for line in raw_version_output.splitlines():
if "Version:" in line:
return line.split("Version:")[1].strip()
return ""


class S3_GW:
def __init__(self, neofs_env: NeoFSEnv):
Expand Down
2 changes: 2 additions & 0 deletions pytest_tests/lib/helpers/grpc_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
MALFORMED_REQUEST = "code = 1024.*message = malformed request"
WRONG_CONTAINER = "code = 1024.*message = wrong container"
SESSION_NOT_ISSUED_BY_OWNER = "code = 1024.*message = session was not issued by the container owner"
INVALID_SESSION_TOKEN_OWNER = "code = 1024.*message = malformed request: invalid session token owner.*"
OBJECT_ACCESS_DENIED = "code = 2048.*message = access to object operation denied"
OBJECT_NOT_FOUND = "code = 2049.*message = object not found"
OBJECT_ALREADY_REMOVED = "code = 2052.*message = object already removed"
Expand All @@ -34,6 +35,7 @@
NOT_SESSION_CONTAINER_OWNER = "session issuer differs with the container owner"
TIMED_OUT = "timed out after \\d+ seconds"
CONTAINER_DELETION_TIMED_OUT = "container deletion: await timeout expired"
CONTAINER_CREATION_TIMED_OUT = "container creation: await timeout expired"

EACL_TIMED_OUT = "eACL setting: await timeout expired"
EACL_TABLE_IS_NOT_SET = "extended ACL table is not set for this container"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from helpers.file_helper import generate_file
from helpers.grpc_responses import (
EXPIRED_SESSION_TOKEN,
INVALID_SESSION_TOKEN_OWNER,
MALFORMED_REQUEST,
OBJECT_ACCESS_DENIED,
OBJECT_NOT_FOUND,
Expand Down Expand Up @@ -352,7 +353,10 @@ def test_static_session_signed_by_other(
temp_directory,
)
signed_token_file = sign_session_token(self.shell, session_token_file, stranger_wallet)
with pytest.raises(Exception, match=OBJECT_ACCESS_DENIED):
expected_error = INVALID_SESSION_TOKEN_OWNER
if self.neofs_env.storage_nodes[0]._get_version() <= "0.43.0":
expected_error = OBJECT_ACCESS_DENIED
with pytest.raises(Exception, match=expected_error):
head_object(
user_wallet.path,
storage_object.cid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from helpers.container import create_container, delete_container, get_container, list_containers
from helpers.file_helper import generate_file
from helpers.grpc_responses import (
CONTAINER_CREATION_TIMED_OUT,
CONTAINER_DELETION_TIMED_OUT,
EACL_TIMED_OUT,
INVALID_EXP,
Expand Down Expand Up @@ -201,10 +202,11 @@ def test_static_session_token_container_create_with_other_wallet(
wait_for_creation=False,
)

@pytest.mark.skip(reason="https://github.com/nspcc-dev/neofs-node/issues/2947")
def test_static_session_token_container_create_signed_with_wrong_wallet(
self, owner_wallet: NodeWallet, user_wallet: NodeWallet, stranger_wallet: NodeWallet, temp_directory: str
):
if self.neofs_env.storage_nodes[0]._get_version() <= "0.43.0":
pytest.skip("This test runs only on post 0.43.0 neofs-node version")
session_token_file = generate_container_session_token(
owner_wallet=user_wallet,
session_wallet=user_wallet,
Expand All @@ -213,7 +215,7 @@ def test_static_session_token_container_create_signed_with_wrong_wallet(
)
container_token = sign_session_token(self.shell, session_token_file, stranger_wallet)

with pytest.raises(RuntimeError):
with pytest.raises(Exception, match=CONTAINER_CREATION_TIMED_OUT):
create_container(
user_wallet.path,
session_token=container_token,
Expand Down

0 comments on commit 3d209c6

Please sign in to comment.