2022-10-27 05:43:20 +00:00
|
|
|
import os
|
|
|
|
import uuid
|
2022-08-25 10:57:55 +00:00
|
|
|
from dataclasses import dataclass
|
|
|
|
from typing import Dict, List, Optional
|
|
|
|
|
|
|
|
import allure
|
|
|
|
import pytest
|
2022-09-28 12:07:16 +00:00
|
|
|
from common import (
|
|
|
|
ASSETS_DIR,
|
|
|
|
IR_WALLET_CONFIG,
|
|
|
|
IR_WALLET_PATH,
|
|
|
|
STORAGE_WALLET_CONFIG,
|
|
|
|
STORAGE_WALLET_PATH,
|
|
|
|
WALLET_CONFIG,
|
2022-10-27 05:43:20 +00:00
|
|
|
WALLET_PASS,
|
2022-09-28 12:07:16 +00:00
|
|
|
)
|
2022-10-11 08:18:08 +00:00
|
|
|
from file_helper import generate_file
|
2022-10-27 05:43:20 +00:00
|
|
|
from neofs_testlib.utils.wallet import init_wallet
|
2022-08-25 10:57:55 +00:00
|
|
|
from python_keywords.acl import EACLRole
|
|
|
|
from python_keywords.container import create_container
|
|
|
|
from python_keywords.neofs_verbs import put_object
|
|
|
|
from wellknown_acl import PUBLIC_ACL
|
|
|
|
|
|
|
|
OBJECT_COUNT = 5
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class Wallet:
|
|
|
|
wallet_path: Optional[str] = None
|
|
|
|
config_path: Optional[str] = None
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class Wallets:
|
|
|
|
wallets: Dict[EACLRole, List[Wallet]]
|
|
|
|
|
|
|
|
def get_wallet(self, role: EACLRole = EACLRole.USER) -> Wallet:
|
|
|
|
return self.wallets[role][0]
|
|
|
|
|
|
|
|
def get_wallets_list(self, role: EACLRole = EACLRole.USER) -> List[Wallet]:
|
|
|
|
return self.wallets[role]
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
|
|
def wallets(prepare_wallet_and_deposit):
|
2022-10-27 05:43:20 +00:00
|
|
|
other_wallets_paths = [
|
|
|
|
os.path.join(os.getcwd(), ASSETS_DIR, f"{str(uuid.uuid4())}.json") for _ in range(2)
|
|
|
|
]
|
|
|
|
for other_wallet_path in other_wallets_paths:
|
|
|
|
init_wallet(other_wallet_path, WALLET_PASS)
|
|
|
|
|
2022-09-05 12:12:56 +00:00
|
|
|
yield Wallets(
|
|
|
|
wallets={
|
|
|
|
EACLRole.USER: [
|
2022-09-28 12:07:16 +00:00
|
|
|
Wallet(wallet_path=prepare_wallet_and_deposit, config_path=WALLET_CONFIG)
|
2022-09-05 12:12:56 +00:00
|
|
|
],
|
|
|
|
EACLRole.OTHERS: [
|
2022-10-27 05:43:20 +00:00
|
|
|
Wallet(wallet_path=other_wallet_path, config_path=WALLET_CONFIG)
|
|
|
|
for other_wallet_path in other_wallets_paths
|
2022-09-05 12:12:56 +00:00
|
|
|
],
|
|
|
|
EACLRole.SYSTEM: [
|
2022-09-19 15:54:00 +00:00
|
|
|
Wallet(wallet_path=IR_WALLET_PATH, config_path=IR_WALLET_CONFIG),
|
2022-09-28 12:07:16 +00:00
|
|
|
Wallet(wallet_path=STORAGE_WALLET_PATH, config_path=STORAGE_WALLET_CONFIG),
|
2022-09-05 12:12:56 +00:00
|
|
|
],
|
|
|
|
}
|
|
|
|
)
|
2022-08-25 10:57:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
|
|
def file_path():
|
|
|
|
yield generate_file()
|
|
|
|
|
|
|
|
|
2022-09-05 12:12:56 +00:00
|
|
|
@pytest.fixture(scope="function")
|
2022-10-13 18:53:44 +00:00
|
|
|
def eacl_container_with_objects(wallets, client_shell, file_path):
|
2022-08-25 10:57:55 +00:00
|
|
|
user_wallet = wallets.get_wallet()
|
2022-09-05 12:12:56 +00:00
|
|
|
with allure.step("Create eACL public container"):
|
2022-10-13 18:53:44 +00:00
|
|
|
cid = create_container(user_wallet.wallet_path, basic_acl=PUBLIC_ACL, shell=client_shell)
|
2022-08-25 10:57:55 +00:00
|
|
|
|
2022-09-05 12:12:56 +00:00
|
|
|
with allure.step("Add test objects to container"):
|
2022-08-25 10:57:55 +00:00
|
|
|
objects_oids = [
|
|
|
|
put_object(
|
2022-09-05 12:12:56 +00:00
|
|
|
user_wallet.wallet_path,
|
|
|
|
file_path,
|
|
|
|
cid,
|
|
|
|
attributes={"key1": "val1", "key": val, "key2": "abc"},
|
2022-10-13 18:53:44 +00:00
|
|
|
shell=client_shell,
|
2022-09-05 12:12:56 +00:00
|
|
|
)
|
|
|
|
for val in range(OBJECT_COUNT)
|
|
|
|
]
|
2022-08-25 10:57:55 +00:00
|
|
|
|
|
|
|
yield cid, objects_oids, file_path
|
|
|
|
|
|
|
|
# with allure.step('Delete eACL public container'):
|
|
|
|
# delete_container(user_wallet, cid)
|