add ir pass to storage_group

Signed-off-by: Yulia Kovshova <y.kovshova@yadro.com>
This commit is contained in:
Юлия Ковшова 2022-11-22 15:27:09 +03:00 committed by Julia Kovshova
parent 14316c1fd7
commit bef01eec48
5 changed files with 50 additions and 29 deletions

View file

@ -1,7 +1,11 @@
import os
import time
from typing import Any, Optional
import allure
import yaml
from common import STORAGE_GC_TIME
from neofs_testlib.hosting import Hosting
def parse_time(value: str) -> int:
@ -60,3 +64,16 @@ def wait_for_gc_pass_on_storage_nodes() -> None:
wait_time = parse_time(STORAGE_GC_TIME)
with allure.step(f"Wait {wait_time}s until GC completes on storage nodes"):
time.sleep(wait_time)
def get_wallet_password(hosting: Hosting, service_name: str) -> Optional[str]:
service_config = hosting.get_service_config(service_name)
return service_config.attributes.get("wallet_password")
def create_wallet_config(hosting: Hosting, service_name: str) -> Optional[str]:
password = get_wallet_password(hosting=hosting, service_name=service_name)
wallet_config_path = os.path.join(os.getcwd(), f"{service_name}_wallet_config.yml")
with open(wallet_config_path, "w") as file:
yaml.dump({"password": password}, file)
return wallet_config_path

View file

@ -5,20 +5,14 @@ from typing import Dict, List, Optional
import allure
import pytest
from common import (
ASSETS_DIR,
IR_WALLET_CONFIG,
IR_WALLET_PATH,
STORAGE_WALLET_CONFIG,
STORAGE_WALLET_PATH,
WALLET_CONFIG,
WALLET_PASS,
)
import yaml
from common import ASSETS_DIR, IR_WALLET_PATH, STORAGE_WALLET_PATH, WALLET_CONFIG, WALLET_PASS
from file_helper import generate_file
from neofs_testlib.utils.wallet import init_wallet
from python_keywords.acl import EACLRole
from python_keywords.container import create_container
from python_keywords.neofs_verbs import put_object
from utility import create_wallet_config
from wellknown_acl import PUBLIC_ACL
OBJECT_COUNT = 5
@ -42,13 +36,16 @@ class Wallets:
@pytest.fixture(scope="module")
def wallets(prepare_wallet_and_deposit):
def wallets(prepare_wallet_and_deposit, hosting):
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)
ir_wallet_config = create_wallet_config(hosting, "ir01")
storage_wallet_config = create_wallet_config(hosting, "s01")
yield Wallets(
wallets={
EACLRole.USER: [
@ -59,8 +56,8 @@ def wallets(prepare_wallet_and_deposit):
for other_wallet_path in other_wallets_paths
],
EACLRole.SYSTEM: [
Wallet(wallet_path=IR_WALLET_PATH, config_path=IR_WALLET_CONFIG),
Wallet(wallet_path=STORAGE_WALLET_PATH, config_path=STORAGE_WALLET_CONFIG),
Wallet(wallet_path=IR_WALLET_PATH, config_path=ir_wallet_config),
Wallet(wallet_path=STORAGE_WALLET_PATH, config_path=storage_wallet_config),
],
}
)

View file

@ -5,12 +5,11 @@ from typing import Optional
import allure
import pytest
import yaml
from common import (
ASSETS_DIR,
COMPLEX_OBJ_SIZE,
FREE_STORAGE,
IR_WALLET_CONFIG,
IR_WALLET_PASS,
IR_WALLET_PATH,
SIMPLE_OBJ_SIZE,
WALLET_PASS,
@ -18,6 +17,7 @@ from common import (
from epoch import tick_epoch
from file_helper import generate_file
from grpc_responses import OBJECT_ACCESS_DENIED, OBJECT_NOT_FOUND
from neofs_testlib.hosting import Hosting
from neofs_testlib.shell import Shell
from neofs_testlib.utils.wallet import init_wallet
from python_keywords.acl import (
@ -40,6 +40,7 @@ from python_keywords.storage_group import (
verify_get_storage_group,
verify_list_storage_group,
)
from utility import get_wallet_password
logger = logging.getLogger("NeoLogger")
deposit = 30
@ -73,9 +74,10 @@ class TestStorageGroup:
)
@allure.title("Test Storage Group in Private Container")
def test_storagegroup_basic_private_container(self, client_shell, object_size):
def test_storagegroup_basic_private_container(self, client_shell, object_size, hosting):
cid = create_container(self.main_wallet, shell=client_shell)
file_path = generate_file(object_size)
password = get_wallet_password(hosting=hosting, service_name="ir01")
oid = put_object(self.main_wallet, file_path, cid, shell=client_shell)
objects = [oid]
storage_group = put_storagegroup(
@ -102,10 +104,11 @@ class TestStorageGroup:
cid=cid,
obj_list=objects,
object_size=object_size,
hosting=hosting,
)
@allure.title("Test Storage Group in Public Container")
def test_storagegroup_basic_public_container(self, client_shell, object_size):
def test_storagegroup_basic_public_container(self, client_shell, object_size, hosting):
cid = create_container(self.main_wallet, basic_acl="public-read-write", shell=client_shell)
file_path = generate_file(object_size)
oid = put_object(self.main_wallet, file_path, cid, shell=client_shell)
@ -130,10 +133,11 @@ class TestStorageGroup:
cid=cid,
obj_list=objects,
object_size=object_size,
hosting=hosting,
)
@allure.title("Test Storage Group in Read-Only Container")
def test_storagegroup_basic_ro_container(self, client_shell, object_size):
def test_storagegroup_basic_ro_container(self, client_shell, object_size, hosting):
cid = create_container(self.main_wallet, basic_acl="public-read", shell=client_shell)
file_path = generate_file(object_size)
oid = put_object(self.main_wallet, file_path, cid, shell=client_shell)
@ -159,6 +163,7 @@ class TestStorageGroup:
cid=cid,
obj_list=objects,
object_size=object_size,
hosting=hosting,
)
@allure.title("Test Storage Group with Bearer Allow")
@ -302,26 +307,30 @@ class TestStorageGroup:
@staticmethod
@allure.step("Run Storage Group Operations On Systems's Behalf In RO Container")
def storagegroup_operations_by_system_ro_container(
shell: Shell, wallet: str, cid: str, obj_list: list, object_size: int
shell: Shell, wallet: str, cid: str, obj_list: list, object_size: int, hosting: Hosting
):
"""
In this func we create a Storage Group on Inner Ring's key behalf
and include an Object created on behalf of some user. We expect
that System key is granted to make all operations except PUT and DELETE.
"""
password = get_wallet_password(hosting=hosting, service_name="ir01")
ir_wallet_config = os.path.join(os.getcwd(), "ir_wallet_config.yml")
with open(ir_wallet_config, "w") as file:
yaml.dump({"password": password}, file)
if not FREE_STORAGE:
deposit = 30
transfer_gas(
shell=shell,
amount=deposit + 1,
wallet_to_path=IR_WALLET_PATH,
wallet_to_password=IR_WALLET_PASS,
wallet_to_password=password,
)
deposit_gas(
shell=shell,
amount=deposit,
wallet_from_path=IR_WALLET_PATH,
wallet_from_password=IR_WALLET_PASS,
wallet_from_password=password,
)
storage_group = put_storagegroup(shell, wallet, cid, obj_list)
with pytest.raises(Exception, match=OBJECT_ACCESS_DENIED):
@ -330,14 +339,14 @@ class TestStorageGroup:
wallet=IR_WALLET_PATH,
cid=cid,
objects=obj_list,
wallet_config=IR_WALLET_CONFIG,
wallet_config=ir_wallet_config,
)
verify_list_storage_group(
shell=shell,
wallet=IR_WALLET_PATH,
cid=cid,
gid=storage_group,
wallet_config=IR_WALLET_CONFIG,
wallet_config=ir_wallet_config,
)
verify_get_storage_group(
@ -347,7 +356,7 @@ class TestStorageGroup:
gid=storage_group,
obj_list=obj_list,
object_size=object_size,
wallet_config=IR_WALLET_CONFIG,
wallet_config=ir_wallet_config,
)
with pytest.raises(Exception, match=OBJECT_ACCESS_DENIED):
delete_storagegroup(
@ -355,5 +364,5 @@ class TestStorageGroup:
wallet=IR_WALLET_PATH,
cid=cid,
gid=storage_group,
wallet_config=IR_WALLET_CONFIG,
wallet_config=ir_wallet_config,
)

View file

@ -236,7 +236,9 @@ class TestEACLContainer:
)
@allure.title("Testcase to validate NeoFS system operations with extended ACL")
def test_extended_actions_system(self, wallets, client_shell, eacl_container_with_objects):
def test_extended_actions_system(
self, wallets, client_shell, eacl_container_with_objects, hosting
):
user_wallet = wallets.get_wallet()
ir_wallet, storage_wallet = wallets.get_wallets_list(role=EACLRole.SYSTEM)[:2]

View file

@ -138,7 +138,3 @@ with open(STORAGE_WALLET_CONFIG, "w") as file:
MAINNET_WALLET_CONFIG = os.path.join(os.getcwd(), "mainnet_wallet_config.yml")
with open(MAINNET_WALLET_CONFIG, "w") as file:
yaml.dump({"password": MAINNET_WALLET_PASS}, file)
IR_WALLET_CONFIG = os.path.join(os.getcwd(), "ir_wallet_config.yml")
with open(IR_WALLET_CONFIG, "w") as file:
yaml.dump({"password": IR_WALLET_PASS}, file)