forked from TrueCloudLab/frostfs-testcases
[#184]: session token keywords moved to separate repo; session token
tests slightly refactored Signed-off-by: anastasia prasolova <anastasia@nspcc.ru>
This commit is contained in:
parent
3e31c527d2
commit
e489b43d63
6 changed files with 124 additions and 77 deletions
|
@ -103,53 +103,3 @@ def get_locode():
|
|||
logger.info(f'Random locode chosen: {locode}')
|
||||
|
||||
return locode
|
||||
|
||||
|
||||
@keyword('Generate Session Token')
|
||||
def generate_session_token(owner: str, pub_key: str, cid: str = "", wildcard: bool = False) -> str:
|
||||
|
||||
file_path = f"{os.getcwd()}/{ASSETS_DIR}/{str(uuid.uuid4())}"
|
||||
|
||||
owner_64 = base64.b64encode(base58.b58decode(owner)).decode('utf-8')
|
||||
cid_64 = base64.b64encode(cid.encode('utf-8')).decode('utf-8')
|
||||
pub_key_64 = base64.b64encode(bytes.fromhex(pub_key)).decode('utf-8')
|
||||
id_64 = base64.b64encode(uuid.uuid4().bytes).decode('utf-8')
|
||||
|
||||
session_token = {
|
||||
"body":{
|
||||
"id":f"{id_64}",
|
||||
"ownerID":{
|
||||
"value":f"{owner_64}"
|
||||
},
|
||||
"lifetime":{
|
||||
"exp":"100000000",
|
||||
"nbf":"0",
|
||||
"iat":"0"
|
||||
},
|
||||
"sessionKey":f"{pub_key_64}",
|
||||
"container":{
|
||||
"verb":"PUT",
|
||||
"wildcard": wildcard,
|
||||
**({ "containerID":{"value":f"{cid_64}"} } if not wildcard else {})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logger.info(f"Got this Session Token: {session_token}")
|
||||
|
||||
with open(file_path, 'w', encoding='utf-8') as session_token_file:
|
||||
json.dump(session_token, session_token_file, ensure_ascii=False, indent=4)
|
||||
|
||||
return file_path
|
||||
|
||||
|
||||
@keyword ('Sign Session Token')
|
||||
def sign_session_token(session_token: str, wallet: str, to_file: str=''):
|
||||
if to_file:
|
||||
to_file = f'--to {to_file}'
|
||||
cmd = (
|
||||
f'{NEOFS_CLI_EXEC} util sign session-token --from {session_token} '
|
||||
f'-w {wallet} {to_file} --config {WALLET_PASS}'
|
||||
)
|
||||
logger.info(f"cmd: {cmd}")
|
||||
_cmd_run(cmd)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue