diff --git a/robot/resources/lib/python_keywords/acl.py b/robot/resources/lib/python_keywords/acl.py index f5b62cd..5ffd7b7 100644 --- a/robot/resources/lib/python_keywords/acl.py +++ b/robot/resources/lib/python_keywords/acl.py @@ -10,7 +10,7 @@ from enum import Enum, auto import base58 from cli_helpers import _cmd_run from common import ASSETS_DIR, NEOFS_ENDPOINT, WALLET_CONFIG -from neo3 import wallet +from data_formatters import pub_key_hex from robot.api import logger from robot.api.deco import keyword @@ -174,12 +174,8 @@ def eacl_rules(access: str, verbs: list, user: str): (list): a list of eACL rules """ if user not in ('others', 'user'): - wallet_content = '' - with open(user) as out: - wallet_content = json.load(out) - wallet_from_json = wallet.Wallet.from_json(wallet_content, password="") - pub_key_64 = str(wallet_from_json.accounts[0].public_key) - user = f"pubkey:{pub_key_64}" + pubkey = pub_key_hex(user) + user = f"pubkey:{pubkey}" rules = [] for verb in verbs: diff --git a/robot/resources/lib/python_keywords/data_formatters.py b/robot/resources/lib/python_keywords/data_formatters.py index a9bf66f..54fecb9 100644 --- a/robot/resources/lib/python_keywords/data_formatters.py +++ b/robot/resources/lib/python_keywords/data_formatters.py @@ -1,3 +1,6 @@ +import json +from neo3 import wallet + def dict_to_attrs(attrs: dict) -> str: """ @@ -11,3 +14,13 @@ def dict_to_attrs(attrs: dict) -> str: (str): string in "a=b,c=d" format. """ return ",".join(f"{key}={value}" for key, value in attrs.items()) + + +def pub_key_hex(wallet_path: str, wallet_password=""): + wallet_content = '' + with open(wallet_path) as out: + wallet_content = json.load(out) + wallet_from_json = wallet.Wallet.from_json(wallet_content, password=wallet_password) + pub_key_64 = str(wallet_from_json.accounts[0].public_key) + + return pub_key_64 diff --git a/robot/resources/lib/python_keywords/s3_gate_bucket.py b/robot/resources/lib/python_keywords/s3_gate_bucket.py index 9c40879..ecddd16 100644 --- a/robot/resources/lib/python_keywords/s3_gate_bucket.py +++ b/robot/resources/lib/python_keywords/s3_gate_bucket.py @@ -6,13 +6,14 @@ import uuid from enum import Enum import boto3 +from data_formatters import pub_key_hex from botocore.exceptions import ClientError import urllib3 from robot.api import logger from robot.api.deco import keyword from cli_helpers import _run_with_passwd, log_command_execution -from common import GATE_PUB_KEY, NEOFS_ENDPOINT, S3_GATE +from common import NEOFS_ENDPOINT, S3_GATE, S3_GATE_WALLET_PATH, S3_GATE_WALLET_PASS ########################################################## # Disabling warnings on self-signed certificate which the @@ -33,12 +34,13 @@ class VersioningStatus(Enum): @keyword('Init S3 Credentials') -def init_s3_credentials(wallet, s3_bearer_rules_file: str = None): +def init_s3_credentials(wallet_path, s3_bearer_rules_file: str = None): bucket = str(uuid.uuid4()) s3_bearer_rules = s3_bearer_rules_file or 'robot/resources/files/s3_bearer_rules.json' + gate_pub_key = pub_key_hex(S3_GATE_WALLET_PATH, S3_GATE_WALLET_PASS) cmd = ( f'{NEOFS_EXEC} --debug --with-log --timeout {CREDENTIALS_CREATE_TIMEOUT} ' - f'issue-secret --wallet {wallet} --gate-public-key={GATE_PUB_KEY} ' + f'issue-secret --wallet {wallet_path} --gate-public-key={gate_pub_key} ' f'--peer {NEOFS_ENDPOINT} --container-friendly-name {bucket} ' f'--bearer-rules {s3_bearer_rules}' ) diff --git a/robot/variables/common.py b/robot/variables/common.py index 812ff16..dce27ff 100644 --- a/robot/variables/common.py +++ b/robot/variables/common.py @@ -31,7 +31,6 @@ NEOFS_CONTRACT = os.getenv("NEOFS_IR_CONTRACTS_NEOFS") ASSETS_DIR = os.getenv("ASSETS_DIR", "TemporaryDir/") MORPH_MAGIC = os.getenv("MORPH_MAGIC") -GATE_PUB_KEY = '0313b1ac3a8076e155a7e797b24f0b650cccad5941ea59d7cfd51a024a8b2a06bf' STORAGE_NODE_1 = os.getenv('DATA_NODE_1', 's01.neofs.devenv:8080') STORAGE_NODE_2 = os.getenv('DATA_NODE_2', 's02.neofs.devenv:8080') @@ -69,6 +68,8 @@ IR_WALLET_PATH = f"{DEVENV_SERVICES_PATH}/ir/wallet01.json" IR_WALLET_CONFIG = f"{os.getcwd()}/neofs_cli_configs/one_wallet_password.yml" IR_WALLET_PASS = 'one' STORAGE_WALLET_PATH = f"{DEVENV_SERVICES_PATH}/storage/wallet01.json" +S3_GATE_WALLET_PATH = f"{DEVENV_SERVICES_PATH}/s3_gate/wallet.json" +S3_GATE_WALLET_PASS = 's3' CONTROL_NODE_USER = os.getenv('CONTROL_NODE_USER', 'root') CONTROL_NODE_PWD = os.getenv('CONTROL_NODE_PWD')