frostfs-testlib/src/neofs_testlib/cli/neofs_cli/util.py
Vladimir Avdeev 9af8f89305 Add storagegroup, session and sign in neofs_cli lib
Signed-off-by: Vladimir Avdeev <v.avdeev@yadro.com>
2022-10-31 14:10:11 +03:00

56 lines
1.8 KiB
Python

from typing import Optional
from neofs_testlib.cli.cli_command import CliCommand
from neofs_testlib.shell import CommandResult
class NeofsCliUtil(CliCommand):
def sign_bearer_token(
self,
wallet: str,
from_file: str,
to_file: str,
address: Optional[str] = None,
json: Optional[bool] = False,
) -> CommandResult:
"""
Sign bearer token to use it in requests.
Args:
address: Address of wallet account.
from_file: File with JSON or binary encoded bearer token to sign.
to_file: File to dump signed bearer token (default: binary encoded).
json: Dump bearer token in JSON encoding.
wallet: WIF (NEP-2) string or path to the wallet or binary key.
Returns:
Command's result.
"""
return self._execute(
"util sign bearer-token",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
def sign_session_token(
self,
wallet: str,
from_file: str,
to_file: str,
address: Optional[str] = None,
) -> CommandResult:
"""
Sign session token to use it in requests.
Args:
address: Address of wallet account.
from_file: File with JSON encoded session token to sign.
to_file: File to dump signed bearer token (default: binary encoded).
wallet: WIF (NEP-2) string or path to the wallet or binary key.
Returns:
Command's result.
"""
return self._execute(
"util sign session-token",
**{param: value for param, value in locals().items() if param not in ["self"]},
)