2022-09-19 14:22:10 +00:00
|
|
|
import os
|
|
|
|
|
|
|
|
import allure
|
|
|
|
import pytest
|
|
|
|
from python_keywords.container import list_containers
|
2022-09-28 12:07:16 +00:00
|
|
|
|
2022-09-19 14:22:10 +00:00
|
|
|
from steps import s3_gate_bucket
|
|
|
|
from steps.aws_cli_client import AwsCliClient
|
|
|
|
|
|
|
|
|
|
|
|
class TestS3GateBase:
|
|
|
|
s3_client = None
|
|
|
|
|
2022-09-28 12:07:16 +00:00
|
|
|
@pytest.fixture(scope="class", autouse=True)
|
|
|
|
@allure.title("[Class/Autouse]: Create S3 client")
|
2022-09-19 14:22:10 +00:00
|
|
|
def s3_client(self, prepare_wallet_and_deposit, request):
|
|
|
|
wallet = prepare_wallet_and_deposit
|
|
|
|
s3_bearer_rules_file = f"{os.getcwd()}/robot/resources/files/s3_bearer_rules.json"
|
|
|
|
|
2022-09-28 12:07:16 +00:00
|
|
|
(
|
|
|
|
cid,
|
|
|
|
bucket,
|
|
|
|
access_key_id,
|
|
|
|
secret_access_key,
|
|
|
|
owner_private_key,
|
|
|
|
) = s3_gate_bucket.init_s3_credentials(wallet, s3_bearer_rules_file=s3_bearer_rules_file)
|
2022-09-19 14:22:10 +00:00
|
|
|
containers_list = list_containers(wallet)
|
2022-09-28 12:07:16 +00:00
|
|
|
assert cid in containers_list, f"Expected cid {cid} in {containers_list}"
|
2022-09-19 14:22:10 +00:00
|
|
|
|
2022-09-28 12:07:16 +00:00
|
|
|
if request.param == "aws cli":
|
2022-09-19 14:22:10 +00:00
|
|
|
try:
|
|
|
|
client = AwsCliClient(access_key_id, secret_access_key)
|
|
|
|
except Exception as err:
|
2022-09-28 12:07:16 +00:00
|
|
|
if "command was not found or was not executable" in str(err):
|
|
|
|
pytest.skip("AWS CLI was not found")
|
2022-09-19 14:22:10 +00:00
|
|
|
else:
|
2022-09-28 12:07:16 +00:00
|
|
|
raise RuntimeError("Error on creating instance for AwsCliClient") from err
|
2022-09-19 14:22:10 +00:00
|
|
|
else:
|
2022-09-28 12:07:16 +00:00
|
|
|
client = s3_gate_bucket.config_s3_client(access_key_id, secret_access_key)
|
2022-09-19 14:22:10 +00:00
|
|
|
TestS3GateBase.s3_client = client
|
|
|
|
TestS3GateBase.wallet = wallet
|