Skip to content

Conversation

@evgeniiz321
Copy link
Contributor

closes #823

@evgeniiz321 evgeniiz321 force-pushed the ezayats/session-tokens-v2 branch 2 times, most recently from 636f984 to 6f719fc Compare January 27, 2026 00:13
@evgeniiz321
Copy link
Contributor Author

Current issues:

  1. Delegation for container operations doesn't work - results in 'invalid container ID field in the response: zero container ID'. Without delegation - works ok.
FAILED pytest_tests/tests/session_token/test_session_token_v2.py::TestSessionTokenV2::test_v2_session_token_container_operations[delegation] - RuntimeError: Command: ./neofs-cli --config /Users/evgeniiz/Projects/neofs-testcases-nspcc/neofs-testcases/wallet_config.yml container create --rpc-endpoint 'localhost:55846' --wallet '/U...

./neofs-cli --config /Users/evgeniiz/Projects/neofs-testcases-nspcc/neofs-testcases/wallet_config.yml container create --rpc-endpoint 'localhost:60812' --wallet '/Users/evgeniiz/Projects/neofs-testcases-nspcc/neofs-testcases/test-run-2026-01-26-23-30-22-007934/wallet-cb920fcc-05ca-4593-8472-610c6df1cb78.json' --await --policy 'REP 2 IN X CBF 1 SELECT 4 FROM * AS X' --session '/Users/evgeniiz/Projects/neofs-testcases-nspcc/neofs-testcases/test-run-2026-01-26-23-30-22-007934/TestFilesDir/72024926-59e2-4a45-8106-8c855cff59bc'
Error:
return code: 1 
Output: Error: put container rpc error: put: invalid container ID field in the response: zero container ID
  1. NNS delegation results in "token issuer is not in this origin token's subjects". Without delegation works ok.
FAILED pytest_tests/tests/session_token/test_session_token_v2.py::TestSessionTokenV2::test_v2_session_token_nns_delegation - RuntimeError: Command: ./neofs-cli --config /Users/evgeniiz/Projects/neofs-testcases-nspcc/neofs-testcases/wallet_config.yml session create-v2 --wallet '/Users/evgeniiz/Projects/neofs-tes...
./neofs-cli --config /Users/evgeniiz/Projects/neofs-testcases-nspcc/neofs-testcases/wallet_config.yml session create-v2 --wallet '/Users/evgeniiz/Projects/neofs-testcases-nspcc/neofs-testcases/test-run-2026-01-26-23-20-57-427457/wallet-08249470-7b21-4175-986e-37974278e5bd.json' --out '/Users/evgeniiz/Projects/neofs-testcases-nspcc/neofs-testcases/test-run-2026-01-26-23-20-57-427457/TestFilesDir/53512b14-aba5-4c23-880c-11b629c8ab28' --rpc-endpoint 'localhost:55846' --lifetime 900 --address 'Nama9A8UQfKm3xHf57CStCxKhUSn7sADNB' --json --subject-nns 'subjectdomain.neofs' --context 'EmJ6jtwCbxy8JUkUwWUsV6hYphYebfvM85mDyhUiNTHy:GET,HEAD' --origin '/Users/evgeniiz/Projects/neofs-testcases-nspcc/neofs-testcases/test-run-2026-01-26-23-20-57-427457/TestFilesDir/9b0a99a4-b26a-4f87-93b0-a8ffcb7c32d1'
Error:
return code: 1 
Output: Error: created token validation failed: depth 0: token issuer is not in this origin token's subjects
  1. Tests with expiration don't get error messages about expired token, although they expect one:
FAILED pytest_tests/tests/session_token/test_session_token_v2.py::TestSessionTokenV2::test_v2_session_token_expiration[owner-direct] - Failed: DID NOT RAISE <class 'RuntimeError'>
FAILED pytest_tests/tests/session_token/test_session_token_v2.py::TestSessionTokenV2::test_v2_session_token_expiration[delegation] - Failed: DID NOT RAISE <class 'RuntimeError'>

All tests can be run from the current PR, no special configurations are needed, just the node binary from the session tokens PR.

Copy link
Member

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wildcard container tokens can be extended with tokens for specific container only, this needs to be checked. I'd also like to see more negative scenarios (like trying to extend cid-specific token with wildcard or using more verbs in delegated token than allowed by original, etc).

rpc_endpoint=f"http://{neofs_env.fschain_rpc}",
wallet_config=neo_go_wallet_config,
method="addRecord",
arguments=f"{domain} 16 string:{wallet.address}",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expected to see Neo (100) type here (and AddNeoRecord call). @End-rey?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, works with 100 and AddNeoRecord as well

subjects: List of subject user IDs authorized to use the token.
subject_nns: List of subject NNS names authorized to use the token.
contexts: List of context specs in format: containerID:verbs[:objectID1,objectID2,...].
Use '0' for wildcard container. Contexts and verbs should be sorted.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorting in done CLI-side now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, also changed tests to use non-sorted verbs

with allure.step("Create V2 Session Token with container operations"):
contexts = ["0:CONTAINERDELETE,CONTAINERPUT"]

if use_delegation:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This chunk can probably be moved out, same as in previous test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

)

with allure.step("Create delegated token for user to perform operations"):
with pytest.raises(Exception, match=".*final token cannot be used as origin.*"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be also forced to create this invalid token and then check that requests fail with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

force is not yet implemented

@evgeniiz321 evgeniiz321 force-pushed the ezayats/session-tokens-v2 branch 3 times, most recently from 4d7fccd to 34d0cdf Compare January 28, 2026 01:31
closes #823

Signed-off-by: Evgeniy Zayats <[email protected]>
@evgeniiz321 evgeniiz321 force-pushed the ezayats/session-tokens-v2 branch from 34d0cdf to c418e7d Compare January 28, 2026 01:39
contracts_hashes["nns"],
rpc_endpoint=f"http://{neofs_env.fschain_rpc}",
wallet_config=neo_go_wallet_config,
method="AddNeoRecord",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
method="AddNeoRecord",
method="addNeoRecord",

rpc_endpoint=f"http://{neofs_env.fschain_rpc}",
wallet_config=neo_go_wallet_config,
method="AddNeoRecord",
arguments=f"{domain} 100 string:{wallet.address}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method works with a specific type Neo, so there is no need to write 100. Also, use Uint160 script hash instead of a string. There should be only 2 arguments: domain and hash of address.

1. Register NNS domain name for owner wallet
2. Add NNS record for the domain
3. Create V2 session token with NNS subject for owner
4. Verify owner can perform operations using the token
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, this test does not verify the correctness of the claim. In this case, all requests will go through an ephemeral key, so it does not matter what other subjects are in the token. What can be verified here is that if the node key is placed in nns and then this node is requested (it must be a different node from the one used to create the token), then everything should work. In this case, the object must be created with the node key, not the ephemeral key. You can also try adding several nodes to one nns and check that requests can be made from all nodes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cover new session token functionality

4 participants