Rename bearer_token to bearer

Signed-off-by: Vladimir Avdeev <v.avdeev@yadro.com>
This commit is contained in:
Vladimir Avdeev 2022-10-18 13:39:39 +03:00 committed by Vladimir Avdeev
parent 7d54641e54
commit 7fcbdb6c34
8 changed files with 53 additions and 53 deletions

View file

@ -165,19 +165,19 @@ class TestStorageGroup:
obj_list: list, obj_list: list,
object_size: int, object_size: int,
shell: Shell, shell: Shell,
bearer_token: Optional[str] = None, bearer: Optional[str] = None,
): ):
""" """
This func verifies if the Object's owner is allowed to This func verifies if the Object's owner is allowed to
Put, List, Get and Delete the Storage Group which contains Put, List, Get and Delete the Storage Group which contains
the Object. the Object.
""" """
storage_group = put_storagegroup(wallet, cid, obj_list, bearer_token) storage_group = put_storagegroup(wallet, cid, obj_list, bearer)
verify_list_storage_group(wallet, cid, storage_group, bearer_token) verify_list_storage_group(wallet, cid, storage_group, bearer)
verify_get_storage_group( verify_get_storage_group(
wallet, cid, storage_group, obj_list, object_size, shell, bearer_token wallet, cid, storage_group, obj_list, object_size, shell, bearer
) )
delete_storagegroup(wallet, cid, storage_group, bearer_token) delete_storagegroup(wallet, cid, storage_group, bearer)
@staticmethod @staticmethod
@allure.step("Run Storage Group Operations And Expect Failure") @allure.step("Run Storage Group Operations And Expect Failure")

View file

@ -49,7 +49,7 @@ class TestACLBearer:
wait_for_cache_expired() wait_for_cache_expired()
with allure.step(f"Create bearer token for {role.value} with all operations allowed"): with allure.step(f"Create bearer token for {role.value} with all operations allowed"):
bearer_token = form_bearertoken_file( bearer = form_bearertoken_file(
user_wallet.wallet_path, user_wallet.wallet_path,
cid, cid,
[ [
@ -79,7 +79,7 @@ class TestACLBearer:
cid, cid,
objects_oids.pop(), objects_oids.pop(),
file_path, file_path,
bearer=bearer_token, bearer=bearer,
wallet_config=deny_wallet.config_path, wallet_config=deny_wallet.config_path,
shell=client_shell, shell=client_shell,
) )
@ -179,7 +179,7 @@ class TestACLBearer:
) )
with allure.step("Check rule consistency using bearer token"): with allure.step("Check rule consistency using bearer token"):
bearer_token_user = form_bearertoken_file( bearer_user = form_bearertoken_file(
user_wallet.wallet_path, user_wallet.wallet_path,
cid, cid,
[ [
@ -189,7 +189,7 @@ class TestACLBearer:
shell=client_shell, shell=client_shell,
) )
bearer_token_other = form_bearertoken_file( bearer_other = form_bearertoken_file(
user_wallet.wallet_path, user_wallet.wallet_path,
cid, cid,
[ [
@ -205,7 +205,7 @@ class TestACLBearer:
objects_oids.pop(), objects_oids.pop(),
file_path, file_path,
deny_operations=deny_map_with_bearer[EACLRole.USER], deny_operations=deny_map_with_bearer[EACLRole.USER],
bearer=bearer_token_user, bearer=bearer_user,
wallet_config=user_wallet.config_path, wallet_config=user_wallet.config_path,
shell=client_shell, shell=client_shell,
) )
@ -215,7 +215,7 @@ class TestACLBearer:
objects_oids.pop(), objects_oids.pop(),
file_path, file_path,
deny_operations=deny_map_with_bearer[EACLRole.OTHERS], deny_operations=deny_map_with_bearer[EACLRole.OTHERS],
bearer=bearer_token_other, bearer=bearer_other,
wallet_config=other_wallet.config_path, wallet_config=other_wallet.config_path,
shell=client_shell, shell=client_shell,
) )

View file

@ -193,7 +193,7 @@ class TestEACLFilters:
"Check other has full access when sending request " "Check other has full access when sending request "
"with denied headers and using bearer token" "with denied headers and using bearer token"
): ):
bearer_token_other = form_bearertoken_file( bearer_other = form_bearertoken_file(
user_wallet.wallet_path, user_wallet.wallet_path,
cid, cid,
[ [
@ -209,7 +209,7 @@ class TestEACLFilters:
file_path, file_path,
shell=client_shell, shell=client_shell,
xhdr=deny_headers, xhdr=deny_headers,
bearer=bearer_token_other, bearer=bearer_other,
) )
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -308,7 +308,7 @@ class TestEACLFilters:
with allure.step( with allure.step(
"Check other have access to objects with deny attribute and using bearer token" "Check other have access to objects with deny attribute and using bearer token"
): ):
bearer_token_other = form_bearertoken_file( bearer_other = form_bearertoken_file(
user_wallet.wallet_path, user_wallet.wallet_path,
cid, cid,
[ [
@ -328,7 +328,7 @@ class TestEACLFilters:
file_path, file_path,
shell=client_shell, shell=client_shell,
xhdr=xhdr, xhdr=xhdr,
bearer=bearer_token_other, bearer=bearer_other,
) )
allow_attribute = ( allow_attribute = (
@ -360,7 +360,7 @@ class TestEACLFilters:
with allure.step( with allure.step(
"Check other can PUT objects with denied attribute and using bearer token" "Check other can PUT objects with denied attribute and using bearer token"
): ):
bearer_token_other_for_put = form_bearertoken_file( bearer_other_for_put = form_bearertoken_file(
user_wallet.wallet_path, user_wallet.wallet_path,
cid, cid,
[ [
@ -378,7 +378,7 @@ class TestEACLFilters:
file_path, file_path,
shell=client_shell, shell=client_shell,
attributes=deny_attribute, attributes=deny_attribute,
bearer=bearer_token_other_for_put, bearer=bearer_other_for_put,
) )
@pytest.mark.parametrize( @pytest.mark.parametrize(
@ -451,7 +451,7 @@ class TestEACLFilters:
with allure.step( with allure.step(
"Check other can get and put objects without attributes and using bearer token" "Check other can get and put objects without attributes and using bearer token"
): ):
bearer_token_other = form_bearertoken_file( bearer_other = form_bearertoken_file(
user_wallet.wallet_path, user_wallet.wallet_path,
cid, cid,
[ [
@ -469,7 +469,7 @@ class TestEACLFilters:
cid, cid,
objects_without_header[0], objects_without_header[0],
shell=client_shell, shell=client_shell,
bearer=bearer_token_other, bearer=bearer_other,
) )
assert can_get_object( assert can_get_object(
other_wallet.wallet_path, other_wallet.wallet_path,
@ -477,14 +477,14 @@ class TestEACLFilters:
objects_without_header[0], objects_without_header[0],
file_path, file_path,
shell=client_shell, shell=client_shell,
bearer=bearer_token_other, bearer=bearer_other,
) )
assert can_put_object( assert can_put_object(
other_wallet.wallet_path, other_wallet.wallet_path,
cid, cid,
file_path, file_path,
shell=client_shell, shell=client_shell,
bearer=bearer_token_other, bearer=bearer_other,
) )
with allure.step(f"Check other can get objects with attributes matching the filter"): with allure.step(f"Check other can get objects with attributes matching the filter"):
@ -523,7 +523,7 @@ class TestEACLFilters:
): ):
oid = deny_objects.pop() oid = deny_objects.pop()
assert can_get_head_object( assert can_get_head_object(
other_wallet.wallet_path, cid, oid, shell=client_shell, bearer=bearer_token_other other_wallet.wallet_path, cid, oid, shell=client_shell, bearer=bearer_other
) )
assert can_get_object( assert can_get_object(
other_wallet.wallet_path, other_wallet.wallet_path,
@ -531,7 +531,7 @@ class TestEACLFilters:
oid, oid,
file_path, file_path,
shell=client_shell, shell=client_shell,
bearer=bearer_token_other, bearer=bearer_other,
) )
assert can_put_object( assert can_put_object(
other_wallet.wallet_path, other_wallet.wallet_path,
@ -539,5 +539,5 @@ class TestEACLFilters:
file_path, file_path,
shell=client_shell, shell=client_shell,
attributes=deny_attribute, attributes=deny_attribute,
bearer=bearer_token_other, bearer=bearer_other,
) )

View file

@ -208,7 +208,7 @@ def form_bearertoken_file(
json.dump(eacl_result, eacl_file, ensure_ascii=False, indent=4) json.dump(eacl_result, eacl_file, ensure_ascii=False, indent=4)
logger.info(f"Got these extended ACL records: {eacl_result}") logger.info(f"Got these extended ACL records: {eacl_result}")
sign_bearer_token(wif, file_path) sign_bearer(wif, file_path)
return file_path return file_path
@ -235,7 +235,7 @@ def eacl_rules(access: str, verbs: list, user: str) -> list[str]:
return rules return rules
def sign_bearer_token(wallet_path: str, eacl_rules_file: str) -> None: def sign_bearer(wallet_path: str, eacl_rules_file: str) -> None:
cmd = ( cmd = (
f"{NEOFS_CLI_EXEC} util sign bearer-token --from {eacl_rules_file} " f"{NEOFS_CLI_EXEC} util sign bearer-token --from {eacl_rules_file} "
f"--to {eacl_rules_file} --wallet {wallet_path} --config {WALLET_CONFIG} --json" f"--to {eacl_rules_file} --wallet {wallet_path} --config {WALLET_CONFIG} --json"

View file

@ -27,7 +27,7 @@ def get_link_object(
cid: str, cid: str,
oid: str, oid: str,
shell: Shell, shell: Shell,
bearer_token: str = "", bearer: str = "",
wallet_config: str = WALLET_CONFIG, wallet_config: str = WALLET_CONFIG,
): ):
""" """
@ -37,7 +37,7 @@ def get_link_object(
cid (str): Container ID which stores the Large Object cid (str): Container ID which stores the Large Object
oid (str): Large Object ID oid (str): Large Object ID
shell: executor for cli command shell: executor for cli command
bearer_token (optional, str): path to Bearer token file bearer (optional, str): path to Bearer token file
wallet_config (optional, str): path to the neofs-cli config file wallet_config (optional, str): path to the neofs-cli config file
Returns: Returns:
(str): Link Object ID (str): Link Object ID
@ -54,7 +54,7 @@ def get_link_object(
endpoint=node, endpoint=node,
is_raw=True, is_raw=True,
is_direct=True, is_direct=True,
bearer_token=bearer_token, bearer=bearer,
wallet_config=wallet_config, wallet_config=wallet_config,
) )
if resp["link"]: if resp["link"]:

View file

@ -26,7 +26,7 @@ def get_object(
cid: str, cid: str,
oid: str, oid: str,
shell: Shell, shell: Shell,
bearer_token: Optional[str] = None, bearer: Optional[str] = None,
write_object: str = "", write_object: str = "",
endpoint: str = "", endpoint: str = "",
xhdr: Optional[dict] = None, xhdr: Optional[dict] = None,
@ -42,7 +42,7 @@ def get_object(
cid (str): ID of Container where we get the Object from cid (str): ID of Container where we get the Object from
oid (str): Object ID oid (str): Object ID
shell: executor for cli command shell: executor for cli command
bearer_token (optional, str): path to Bearer Token file, appends to `--bearer` key bearer (optional, str): path to Bearer Token file, appends to `--bearer` key
write_object (optional, str): path to downloaded file, appends to `--file` key write_object (optional, str): path to downloaded file, appends to `--file` key
endpoint (optional, str): NeoFS endpoint to send request to, appends to `--rpc-endpoint` key endpoint (optional, str): NeoFS endpoint to send request to, appends to `--rpc-endpoint` key
wallet_config(optional, str): path to the wallet config wallet_config(optional, str): path to the wallet config
@ -67,7 +67,7 @@ def get_object(
cid=cid, cid=cid,
oid=oid, oid=oid,
file=file_path, file=file_path,
bearer=bearer_token, bearer=bearer,
no_progress=no_progress, no_progress=no_progress,
xhdr=xhdr, xhdr=xhdr,
session=session, session=session,
@ -83,7 +83,7 @@ def get_range_hash(
oid: str, oid: str,
range_cut: str, range_cut: str,
shell: Shell, shell: Shell,
bearer_token: Optional[str] = None, bearer: Optional[str] = None,
endpoint: Optional[str] = None, endpoint: Optional[str] = None,
wallet_config: Optional[str] = None, wallet_config: Optional[str] = None,
xhdr: Optional[dict] = None, xhdr: Optional[dict] = None,
@ -96,7 +96,7 @@ def get_range_hash(
cid (str): ID of Container where we get the Object from cid (str): ID of Container where we get the Object from
oid (str): Object ID oid (str): Object ID
shell: executor for cli command shell: executor for cli command
bearer_token (optional, str): path to Bearer Token file, appends to `--bearer` key bearer (optional, str): path to Bearer Token file, appends to `--bearer` key
range_cut (str): Range to take hash from in the form offset1:length1,..., range_cut (str): Range to take hash from in the form offset1:length1,...,
value to pass to the `--range` parameter value to pass to the `--range` parameter
endpoint (optional, str): NeoFS endpoint to send request to, appends to `--rpc-endpoint` key endpoint (optional, str): NeoFS endpoint to send request to, appends to `--rpc-endpoint` key
@ -113,7 +113,7 @@ def get_range_hash(
cid=cid, cid=cid,
oid=oid, oid=oid,
range=range_cut, range=range_cut,
bearer=bearer_token, bearer=bearer,
xhdr=xhdr, xhdr=xhdr,
) )

View file

@ -33,7 +33,7 @@ def can_get_object(
wallet, wallet,
cid, cid,
oid, oid,
bearer_token=bearer, bearer=bearer,
wallet_config=wallet_config, wallet_config=wallet_config,
xhdr=xhdr, xhdr=xhdr,
shell=shell, shell=shell,
@ -171,7 +171,7 @@ def can_get_range_hash_of_object(
wallet, wallet,
cid, cid,
oid, oid,
bearer_token=bearer, bearer=bearer,
range_cut="0:10", range_cut="0:10",
wallet_config=wallet_config, wallet_config=wallet_config,
xhdr=xhdr, xhdr=xhdr,

View file

@ -19,7 +19,7 @@ def put_storagegroup(
wallet: str, wallet: str,
cid: str, cid: str,
objects: list, objects: list,
bearer_token: str = "", bearer: str = "",
wallet_config: str = WALLET_CONFIG, wallet_config: str = WALLET_CONFIG,
lifetime: str = "10", lifetime: str = "10",
): ):
@ -31,7 +31,7 @@ def put_storagegroup(
wallet (str): path to wallet on whose behalf the SG is created wallet (str): path to wallet on whose behalf the SG is created
cid (str): ID of Container to put SG to cid (str): ID of Container to put SG to
objects (list): list of Object IDs to include into the SG objects (list): list of Object IDs to include into the SG
bearer_token (optional, str): path to Bearer token file bearer (optional, str): path to Bearer token file
wallet_config (optional, str): path to neofs-cli config file wallet_config (optional, str): path to neofs-cli config file
Returns: Returns:
(str): Object ID of created Storage Group (str): Object ID of created Storage Group
@ -41,7 +41,7 @@ def put_storagegroup(
f"--wallet {wallet} --config {wallet_config} " f"--wallet {wallet} --config {wallet_config} "
f"storagegroup put --cid {cid} --lifetime {lifetime} " f"storagegroup put --cid {cid} --lifetime {lifetime} "
f'--members {",".join(objects)} ' f'--members {",".join(objects)} '
f'{"--bearer " + bearer_token if bearer_token else ""}' f'{"--bearer " + bearer if bearer else ""}'
) )
output = _cmd_run(cmd) output = _cmd_run(cmd)
oid = output.split("\n")[1].split(": ")[1] oid = output.split("\n")[1].split(": ")[1]
@ -50,7 +50,7 @@ def put_storagegroup(
@allure.step("List Storagegroup") @allure.step("List Storagegroup")
def list_storagegroup( def list_storagegroup(
wallet: str, cid: str, bearer_token: str = "", wallet_config: str = WALLET_CONFIG wallet: str, cid: str, bearer: str = "", wallet_config: str = WALLET_CONFIG
): ):
""" """
Wrapper for `neofs-cli storagegroup list`. This operation Wrapper for `neofs-cli storagegroup list`. This operation
@ -59,7 +59,7 @@ def list_storagegroup(
wallet (str): path to wallet on whose behalf the SGs are wallet (str): path to wallet on whose behalf the SGs are
listed in the container listed in the container
cid (str): ID of Container to list cid (str): ID of Container to list
bearer_token (optional, str): path to Bearer token file bearer (optional, str): path to Bearer token file
wallet_config (optional, str): path to neofs-cli config file wallet_config (optional, str): path to neofs-cli config file
Returns: Returns:
(list): Object IDs of found Storage Groups (list): Object IDs of found Storage Groups
@ -67,7 +67,7 @@ def list_storagegroup(
cmd = ( cmd = (
f"{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} " f"{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} "
f"--wallet {wallet} --config {wallet_config} storagegroup list " f"--wallet {wallet} --config {wallet_config} storagegroup list "
f'--cid {cid} {"--bearer " + bearer_token if bearer_token else ""}' f'--cid {cid} {"--bearer " + bearer if bearer else ""}'
) )
output = _cmd_run(cmd) output = _cmd_run(cmd)
# throwing off the first string of output # throwing off the first string of output
@ -80,7 +80,7 @@ def get_storagegroup(
wallet: str, wallet: str,
cid: str, cid: str,
oid: str, oid: str,
bearer_token: str = "", bearer: str = "",
wallet_config: str = WALLET_CONFIG, wallet_config: str = WALLET_CONFIG,
): ):
""" """
@ -89,7 +89,7 @@ def get_storagegroup(
wallet (str): path to wallet on whose behalf the SG is got wallet (str): path to wallet on whose behalf the SG is got
cid (str): ID of Container where SG is stored cid (str): ID of Container where SG is stored
oid (str): ID of the Storage Group oid (str): ID of the Storage Group
bearer_token (optional, str): path to Bearer token file bearer (optional, str): path to Bearer token file
wallet_config (optional, str): path to neofs-cli config file wallet_config (optional, str): path to neofs-cli config file
Returns: Returns:
(dict): detailed information on the Storage Group (dict): detailed information on the Storage Group
@ -99,7 +99,7 @@ def get_storagegroup(
f"{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} " f"{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} "
f"--wallet {wallet} --config {wallet_config} " f"--wallet {wallet} --config {wallet_config} "
f"storagegroup get --cid {cid} --id {oid} " f"storagegroup get --cid {cid} --id {oid} "
f'{"--bearer " + bearer_token if bearer_token else ""}' f'{"--bearer " + bearer if bearer else ""}'
) )
output = _cmd_run(cmd) output = _cmd_run(cmd)
@ -126,7 +126,7 @@ def delete_storagegroup(
wallet: str, wallet: str,
cid: str, cid: str,
oid: str, oid: str,
bearer_token: str = "", bearer: str = "",
wallet_config: str = WALLET_CONFIG, wallet_config: str = WALLET_CONFIG,
): ):
""" """
@ -135,7 +135,7 @@ def delete_storagegroup(
wallet (str): path to wallet on whose behalf the SG is deleted wallet (str): path to wallet on whose behalf the SG is deleted
cid (str): ID of Container where SG is stored cid (str): ID of Container where SG is stored
oid (str): ID of the Storage Group oid (str): ID of the Storage Group
bearer_token (optional, str): path to Bearer token file bearer (optional, str): path to Bearer token file
wallet_config (optional, str): path to neofs-cli config file wallet_config (optional, str): path to neofs-cli config file
Returns: Returns:
(str): Tombstone ID of the deleted Storage Group (str): Tombstone ID of the deleted Storage Group
@ -145,7 +145,7 @@ def delete_storagegroup(
f"{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} " f"{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} "
f"--wallet {wallet} --config {wallet_config} " f"--wallet {wallet} --config {wallet_config} "
f"storagegroup delete --cid {cid} --id {oid} " f"storagegroup delete --cid {cid} --id {oid} "
f'{"--bearer " + bearer_token if bearer_token else ""}' f'{"--bearer " + bearer if bearer else ""}'
) )
output = _cmd_run(cmd) output = _cmd_run(cmd)
tombstone_id = output.strip().split("\n")[1].split(": ")[1] tombstone_id = output.strip().split("\n")[1].split(": ")[1]
@ -161,7 +161,7 @@ def verify_list_storage_group(
wallet_config: str = WALLET_CONFIG, wallet_config: str = WALLET_CONFIG,
): ):
storage_groups = list_storagegroup( storage_groups = list_storagegroup(
wallet, cid, bearer_token=bearer, wallet_config=wallet_config wallet, cid, bearer=bearer, wallet_config=wallet_config
) )
assert storagegroup in storage_groups assert storagegroup in storage_groups
@ -181,21 +181,21 @@ def verify_get_storage_group(
if object_size == COMPLEX_OBJ_SIZE: if object_size == COMPLEX_OBJ_SIZE:
for obj in obj_list: for obj in obj_list:
link_oid = get_link_object( link_oid = get_link_object(
wallet, cid, obj, shell=shell, bearer_token=bearer, wallet_config=wallet_config wallet, cid, obj, shell=shell, bearer=bearer, wallet_config=wallet_config
) )
obj_head = head_object( obj_head = head_object(
wallet, wallet,
cid, cid,
link_oid, link_oid,
is_raw=True, is_raw=True,
bearer_token=bearer, bearer=bearer,
wallet_config=wallet_config, wallet_config=wallet_config,
) )
obj_parts = obj_head["header"]["split"]["children"] obj_parts = obj_head["header"]["split"]["children"]
obj_num = len(obj_list) obj_num = len(obj_list)
storagegroup_data = get_storagegroup( storagegroup_data = get_storagegroup(
wallet, cid, storagegroup, bearer_token=bearer, wallet_config=wallet_config wallet, cid, storagegroup, bearer=bearer, wallet_config=wallet_config
) )
if object_size == SIMPLE_OBJ_SIZE: if object_size == SIMPLE_OBJ_SIZE:
exp_size = SIMPLE_OBJ_SIZE * obj_num exp_size = SIMPLE_OBJ_SIZE * obj_num