forked from TrueCloudLab/frostfs-testcases
Add ACL and eACL PyTest tests
Signed-off-by: Vladimir Avdeev <v.avdeev@yadro.com>
This commit is contained in:
parent
590a5cfb0e
commit
6d040c6834
36 changed files with 979 additions and 1318 deletions
|
@ -21,8 +21,8 @@ ROBOT_AUTO_KEYWORDS = False
|
|||
|
||||
@keyword('Get object')
|
||||
def get_object(wallet: str, cid: str, oid: str, bearer_token: Optional[str] = None, write_object: str = "",
|
||||
endpoint: str = "", options: Optional[dict] = None, wallet_config: str = WALLET_CONFIG,
|
||||
no_progress: bool = True):
|
||||
endpoint: str = "", xhdr: Optional[dict] = None, wallet_config: Optional[str] = None,
|
||||
no_progress: bool = True) -> str:
|
||||
"""
|
||||
GET from NeoFS.
|
||||
|
||||
|
@ -35,11 +35,12 @@ def get_object(wallet: str, cid: str, oid: str, bearer_token: Optional[str] = No
|
|||
endpoint (optional, str): NeoFS endpoint to send request to, appends to `--rpc-endpoint` key
|
||||
wallet_config(optional, str): path to the wallet config
|
||||
no_progress(optional, bool): do not show progress bar
|
||||
options (optional, str): any options which `neofs-cli object get` accepts
|
||||
xhdr (optional, dict): Request X-Headers in form of Key=Value
|
||||
Returns:
|
||||
(str): path to downloaded file
|
||||
"""
|
||||
|
||||
wallet_config = wallet_config or WALLET_CONFIG
|
||||
if not write_object:
|
||||
write_object = str(uuid.uuid4())
|
||||
file_path = f"{ASSETS_DIR}/{write_object}"
|
||||
|
@ -49,7 +50,7 @@ def get_object(wallet: str, cid: str, oid: str, bearer_token: Optional[str] = No
|
|||
|
||||
cli = NeofsCli(config=wallet_config)
|
||||
cli.object.get(rpc_endpoint=endpoint, wallet=wallet, cid=cid, oid=oid, file=file_path,
|
||||
bearer=bearer_token, no_progress=no_progress, **options or {})
|
||||
bearer=bearer_token, no_progress=no_progress, xhdr=xhdr)
|
||||
|
||||
return file_path
|
||||
|
||||
|
@ -57,7 +58,7 @@ def get_object(wallet: str, cid: str, oid: str, bearer_token: Optional[str] = No
|
|||
# TODO: make `bearer_token` optional
|
||||
@keyword('Get Range Hash')
|
||||
def get_range_hash(wallet: str, cid: str, oid: str, bearer_token: str, range_cut: str,
|
||||
wallet_config: str = WALLET_CONFIG, options: Optional[dict] = None):
|
||||
wallet_config: Optional[str] = None, xhdr: Optional[dict] = None):
|
||||
"""
|
||||
GETRANGEHASH of given Object.
|
||||
|
||||
|
@ -69,23 +70,24 @@ def get_range_hash(wallet: str, cid: str, oid: str, bearer_token: str, range_cut
|
|||
value to pass to the `--range` parameter
|
||||
bearer_token (optional, str): path to Bearer Token file, appends to `--bearer` key
|
||||
wallet_config(optional, str): path to the wallet config
|
||||
options (optional, str): any options which `neofs-cli object hash` accepts
|
||||
xhdr (optional, dict): Request X-Headers in form of Key=Value
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
|
||||
wallet_config = wallet_config or WALLET_CONFIG
|
||||
cli = NeofsCli(config=wallet_config)
|
||||
output = cli.object.hash(rpc_endpoint=NEOFS_ENDPOINT, wallet=wallet, cid=cid, oid=oid, range=range_cut,
|
||||
bearer=bearer_token, **options or {})
|
||||
bearer=bearer_token, xhdr=xhdr)
|
||||
|
||||
# cutting off output about range offset and length
|
||||
return output.split(':')[1].strip()
|
||||
|
||||
|
||||
@keyword('Put object')
|
||||
def put_object(wallet: str, path: str, cid: str, bearer: str = "", user_headers: Optional[dict] = None,
|
||||
endpoint: str = "", wallet_config: str = WALLET_CONFIG, expire_at: Optional[int] = None,
|
||||
no_progress: bool = True, options: Optional[dict] = None):
|
||||
def put_object(wallet: str, path: str, cid: str, bearer: str = "", attributes: Optional[dict] = None,
|
||||
xhdr: Optional[dict] = None, endpoint: str = "", wallet_config: Optional[str] = None,
|
||||
expire_at: Optional[int] = None, no_progress: bool = True):
|
||||
"""
|
||||
PUT of given file.
|
||||
|
||||
|
@ -94,24 +96,24 @@ def put_object(wallet: str, path: str, cid: str, bearer: str = "", user_headers:
|
|||
path (str): path to file to be PUT
|
||||
cid (str): ID of Container where we get the Object from
|
||||
bearer (optional, str): path to Bearer Token file, appends to `--bearer` key
|
||||
user_headers (optional, dict): Object attributes, append to `--attributes` key
|
||||
attributes (optional, str): User attributes in form of Key1=Value1,Key2=Value2
|
||||
endpoint(optional, str): NeoFS endpoint to send request to
|
||||
wallet_config(optional, str): path to the wallet config
|
||||
no_progress(optional, bool): do not show progress bar
|
||||
options (optional, str): any options which `neofs-cli object put` accepts
|
||||
expire_at (optional, int): Last epoch in the life of the object
|
||||
xhdr (optional, dict): Request X-Headers in form of Key=Value
|
||||
Returns:
|
||||
(str): ID of uploaded Object
|
||||
"""
|
||||
wallet_config = wallet_config or WALLET_CONFIG
|
||||
if not endpoint:
|
||||
endpoint = random.sample(NEOFS_NETMAP, 1)[0]
|
||||
if not endpoint:
|
||||
logger.info(f'---DEB:\n{NEOFS_NETMAP}')
|
||||
|
||||
cli = NeofsCli(config=wallet_config)
|
||||
output = cli.object.put(rpc_endpoint=endpoint, wallet=wallet, file=path, cid=cid, bearer=bearer,
|
||||
expire_at=expire_at, no_progress=no_progress,
|
||||
attributes=user_headers or {}, **options or {})
|
||||
output = cli.object.put(rpc_endpoint=endpoint, wallet=wallet, file=path, cid=cid, attributes=attributes,
|
||||
bearer=bearer, expire_at=expire_at, no_progress=no_progress, xhdr=xhdr)
|
||||
|
||||
# splitting CLI output to lines and taking the penultimate line
|
||||
id_str = output.strip().split('\n')[-2]
|
||||
|
@ -120,8 +122,8 @@ def put_object(wallet: str, path: str, cid: str, bearer: str = "", user_headers:
|
|||
|
||||
|
||||
@keyword('Delete object')
|
||||
def delete_object(wallet: str, cid: str, oid: str, bearer: str = "", wallet_config: str = WALLET_CONFIG,
|
||||
options: Optional[dict] = None):
|
||||
def delete_object(wallet: str, cid: str, oid: str, bearer: str = "", wallet_config: Optional[str] = None,
|
||||
xhdr: Optional[dict] = None):
|
||||
"""
|
||||
DELETE an Object.
|
||||
|
||||
|
@ -131,14 +133,15 @@ def delete_object(wallet: str, cid: str, oid: str, bearer: str = "", wallet_conf
|
|||
oid (str): ID of Object we are going to delete
|
||||
bearer (optional, str): path to Bearer Token file, appends to `--bearer` key
|
||||
wallet_config(optional, str): path to the wallet config
|
||||
options (optional, dict): any options which `neofs-cli object delete` accepts
|
||||
xhdr (optional, dict): Request X-Headers in form of Key=Value
|
||||
Returns:
|
||||
(str): Tombstone ID
|
||||
"""
|
||||
|
||||
wallet_config = wallet_config or WALLET_CONFIG
|
||||
cli = NeofsCli(config=wallet_config)
|
||||
output = cli.object.delete(rpc_endpoint=NEOFS_ENDPOINT, wallet=wallet, cid=cid, oid=oid, bearer=bearer,
|
||||
**options or {})
|
||||
xhdr=xhdr)
|
||||
|
||||
id_str = output.split('\n')[1]
|
||||
tombstone = id_str.split(':')[1]
|
||||
|
@ -146,8 +149,8 @@ def delete_object(wallet: str, cid: str, oid: str, bearer: str = "", wallet_conf
|
|||
|
||||
|
||||
@keyword('Get Range')
|
||||
def get_range(wallet: str, cid: str, oid: str, range_cut: str, wallet_config: str = WALLET_CONFIG,
|
||||
bearer: str = "", options: Optional[dict] = None):
|
||||
def get_range(wallet: str, cid: str, oid: str, range_cut: str, wallet_config: Optional[str] = None,
|
||||
bearer: str = "", xhdr: Optional[dict] = None):
|
||||
"""
|
||||
GETRANGE an Object.
|
||||
|
||||
|
@ -158,15 +161,16 @@ def get_range(wallet: str, cid: str, oid: str, range_cut: str, wallet_config: st
|
|||
range_cut (str): range to take data from in the form offset:length
|
||||
bearer (optional, str): path to Bearer Token file, appends to `--bearer` key
|
||||
wallet_config(optional, str): path to the wallet config
|
||||
options (optional, dict): any options which `neofs-cli object range` accepts
|
||||
xhdr (optional, dict): Request X-Headers in form of Key=Value
|
||||
Returns:
|
||||
(str, bytes) - path to the file with range content and content of this file as bytes
|
||||
"""
|
||||
wallet_config = wallet_config or WALLET_CONFIG
|
||||
range_file = f"{ASSETS_DIR}/{uuid.uuid4()}"
|
||||
|
||||
cli = NeofsCli(config=wallet_config)
|
||||
cli.object.range(rpc_endpoint=NEOFS_ENDPOINT, wallet=wallet, cid=cid, oid=oid, range=range_cut, file=range_file,
|
||||
bearer=bearer, **options or {})
|
||||
bearer=bearer, xhdr=xhdr)
|
||||
|
||||
with open(range_file, 'rb') as fout:
|
||||
content = fout.read()
|
||||
|
@ -175,8 +179,8 @@ def get_range(wallet: str, cid: str, oid: str, range_cut: str, wallet_config: st
|
|||
|
||||
@keyword('Search object')
|
||||
def search_object(wallet: str, cid: str, bearer: str = "", filters: Optional[dict] = None,
|
||||
expected_objects_list: Optional[list] = None, wallet_config: str = WALLET_CONFIG,
|
||||
options: Optional[dict] = None):
|
||||
expected_objects_list: Optional[list] = None, wallet_config: Optional[str] = None,
|
||||
xhdr: Optional[dict] = None) -> list:
|
||||
"""
|
||||
SEARCH an Object.
|
||||
|
||||
|
@ -187,16 +191,16 @@ def search_object(wallet: str, cid: str, bearer: str = "", filters: Optional[dic
|
|||
filters (optional, dict): key=value pairs to filter Objects
|
||||
expected_objects_list (optional, list): a list of ObjectIDs to compare found Objects with
|
||||
wallet_config(optional, str): path to the wallet config
|
||||
options(optional, str): any other options which `neofs-cli object search` might accept
|
||||
xhdr (optional, dict): Request X-Headers in form of Key=Value
|
||||
Returns:
|
||||
(list): list of found ObjectIDs
|
||||
"""
|
||||
|
||||
wallet_config = wallet_config or WALLET_CONFIG
|
||||
cli = NeofsCli(config=wallet_config)
|
||||
output = cli.object.search(
|
||||
rpc_endpoint=NEOFS_ENDPOINT, wallet=wallet, cid=cid, bearer=bearer,
|
||||
filters=[f'{filter_key} EQ {filter_val}' for filter_key, filter_val in filters.items()] if filters else None,
|
||||
**options or {})
|
||||
rpc_endpoint=NEOFS_ENDPOINT, wallet=wallet, cid=cid, bearer=bearer, xhdr=xhdr,
|
||||
filters=[f'{filter_key} EQ {filter_val}' for filter_key, filter_val in filters.items()] if filters else None)
|
||||
|
||||
found_objects = re.findall(r'(\w{43,44})', output)
|
||||
|
||||
|
@ -213,8 +217,8 @@ def search_object(wallet: str, cid: str, bearer: str = "", filters: Optional[dic
|
|||
|
||||
@keyword('Head object')
|
||||
def head_object(wallet: str, cid: str, oid: str, bearer_token: str = "",
|
||||
options: Optional[dict] = None, endpoint: str = None, json_output: bool = True,
|
||||
is_raw: bool = False, is_direct: bool = False, wallet_config: str = WALLET_CONFIG):
|
||||
xhdr: Optional[dict] = None, endpoint: str = None, json_output: bool = True,
|
||||
is_raw: bool = False, is_direct: bool = False, wallet_config: Optional[str] = None):
|
||||
"""
|
||||
HEAD an Object.
|
||||
|
||||
|
@ -223,7 +227,6 @@ def head_object(wallet: str, cid: str, oid: str, bearer_token: str = "",
|
|||
cid (str): ID of Container where we get the Object from
|
||||
oid (str): ObjectID to HEAD
|
||||
bearer_token (optional, str): path to Bearer Token file, appends to `--bearer` key
|
||||
options (optional, str): any options which `neofs-cli object head` accepts
|
||||
endpoint(optional, str): NeoFS endpoint to send request to
|
||||
json_output(optional, bool): return reponse in JSON format or not; this flag
|
||||
turns into `--json` key
|
||||
|
@ -232,6 +235,7 @@ def head_object(wallet: str, cid: str, oid: str, bearer_token: str = "",
|
|||
is_direct(optional, bool): send request directly to the node or not; this flag
|
||||
turns into `--ttl 1` key
|
||||
wallet_config(optional, str): path to the wallet config
|
||||
xhdr (optional, dict): Request X-Headers in form of Key=Value
|
||||
Returns:
|
||||
depending on the `json_output` parameter value, the function returns
|
||||
(dict): HEAD response in JSON format
|
||||
|
@ -239,10 +243,11 @@ def head_object(wallet: str, cid: str, oid: str, bearer_token: str = "",
|
|||
(str): HEAD response as a plain text
|
||||
"""
|
||||
|
||||
wallet_config = wallet_config or WALLET_CONFIG
|
||||
cli = NeofsCli(config=wallet_config)
|
||||
output = cli.object.head(rpc_endpoint=endpoint or NEOFS_ENDPOINT, wallet=wallet, cid=cid, oid=oid,
|
||||
bearer=bearer_token, json_mode=json_output, raw=is_raw,
|
||||
ttl=1 if is_direct else None, **options or {})
|
||||
ttl=1 if is_direct else None, xhdr=xhdr)
|
||||
|
||||
if not json_output:
|
||||
return output
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue