From dd98eb3d9d309d69666a79af88e0d867c8ced2bf Mon Sep 17 00:00:00 2001 From: anastasia prasolova Date: Wed, 3 Aug 2022 15:20:29 +0300 Subject: [PATCH] [#271] fixed key for eacl filter test Signed-off-by: anastasia prasolova --- robot/resources/lib/python_keywords/acl.py | 4 ++ .../lib/python_keywords/cli_helpers.py | 4 +- .../resources/lib/robot/setup_teardown.robot | 18 ----- ...l_bearer_request_filter_xheader_deny.robot | 35 ++++++---- .../acl/acl_extended_filters.robot | 65 +++++++++---------- 5 files changed, 60 insertions(+), 66 deletions(-) delete mode 100644 robot/resources/lib/robot/setup_teardown.robot diff --git a/robot/resources/lib/python_keywords/acl.py b/robot/resources/lib/python_keywords/acl.py index 5ffd7b7..db891a0 100644 --- a/robot/resources/lib/python_keywords/acl.py +++ b/robot/resources/lib/python_keywords/acl.py @@ -80,6 +80,10 @@ def create_eacl(cid: str, rules_list: list): ) _cmd_run(cmd) + with open(table, 'r') as fout: + table_data = fout.read() + logger.info(f"Generated eACL:\n{table_data}") + return table diff --git a/robot/resources/lib/python_keywords/cli_helpers.py b/robot/resources/lib/python_keywords/cli_helpers.py index fe28191..0373398 100644 --- a/robot/resources/lib/python_keywords/cli_helpers.py +++ b/robot/resources/lib/python_keywords/cli_helpers.py @@ -88,7 +88,7 @@ def _configure_aws_cli(cmd: str, key_id: str, access_key: str, out_format: str = def _attach_allure_log(cmd: str, output: str, return_code: int, start_time: datetime, end_time: datetime) -> None: - if 'allure' in sys.modules: + if 'robot' not in sys.modules: command_attachment = ( f"COMMAND: '{cmd}'\n" f'OUTPUT:\n {output}\n' @@ -101,7 +101,7 @@ def _attach_allure_log(cmd: str, output: str, return_code: int, start_time: date def log_command_execution(cmd: str, output: Union[str, dict]) -> None: logger.info(f'{cmd}: {output}') - if 'allure' in sys.modules: + if 'robot' not in sys.modules: with suppress(Exception): json_output = json.dumps(output, indent=4, sort_keys=True) output = json_output diff --git a/robot/resources/lib/robot/setup_teardown.robot b/robot/resources/lib/robot/setup_teardown.robot deleted file mode 100644 index 7ee9529..0000000 --- a/robot/resources/lib/robot/setup_teardown.robot +++ /dev/null @@ -1,18 +0,0 @@ -*** Settings *** -Variables common.py - -Library OperatingSystem -Library utility_keywords.py - -*** Keywords *** - -Setup - [Arguments] - Make Up - Create Directory ${ASSETS_DIR} - -Teardown - [Arguments] ${LOGFILE} - Remove Directory ${ASSETS_DIR} True - Get Docker Logs ${LOGFILE} - Make Down diff --git a/robot/testsuites/integration/acl/acl_bearer_request_filter_xheader_deny.robot b/robot/testsuites/integration/acl/acl_bearer_request_filter_xheader_deny.robot index 23d5463..e62597f 100644 --- a/robot/testsuites/integration/acl/acl_bearer_request_filter_xheader_deny.robot +++ b/robot/testsuites/integration/acl/acl_bearer_request_filter_xheader_deny.robot @@ -14,12 +14,13 @@ Resource payment_operations.robot &{USER_HEADER} = key1=1 key2=abc &{USER_HEADER_DEL} = key1=del key2=del &{ANOTHER_HEADER} = key1=oth key2=oth +${ERROR} = code = 2048 message = access to object operation denied *** Test cases *** BearerToken Operations [Documentation] Testcase to validate NeoFS operations with BearerToken. [Tags] ACL BearerToken - [Timeout] 20 min + [Timeout] 1 min ${WALLET} ${_} ${_} = Prepare Wallet And Deposit @@ -62,23 +63,31 @@ Check eACL Allow All Bearer Filter Requst Equal Deny Put object ${WALLET} ${FILE_S} ${CID} bearer=${EACL_TOKEN} user_headers=${ANOTHER_HEADER} options=--xhdr a=2 Get object ${WALLET} ${CID} ${S_OID_USER} ${EACL_TOKEN} local_file_eacl ${EMPTY} --xhdr a=2 - Search object ${WALLET} ${CID} ${EMPTY} ${EACL_TOKEN} ${USER_HEADER} ${S_OBJ_H} options=--xhdr a=2 + Search object ${WALLET} ${CID} bearer=${EACL_TOKEN} filters=${USER_HEADER} + ... expected_objects_list=${S_OBJ_H} options=--xhdr a=2 Head object ${WALLET} ${CID} ${S_OID_USER} bearer_token=${EACL_TOKEN} options=--xhdr a=2 - Get Range ${WALLET} ${CID} ${S_OID_USER} 0:256 bearer=${EACL_TOKEN} options=--xhdr a=2 + Get Range ${WALLET} ${CID} ${S_OID_USER} 0:256 bearer=${EACL_TOKEN} options=--xhdr a=2 Get Range Hash ${WALLET} ${CID} ${S_OID_USER} ${EACL_TOKEN} 0:256 options=--xhdr a=2 Delete object ${WALLET} ${CID} ${D_OID_USER} bearer=${EACL_TOKEN} options=--xhdr a=2 - Run Keyword And Expect Error * + ${ERR} = Run Keyword And Expect Error * ... Put object ${WALLET} ${FILE_S} ${CID} bearer=${EACL_TOKEN} user_headers=${USER_HEADER} options=--xhdr a=256 - Run Keyword And Expect Error * + Should Contain ${ERR} ${ERROR} + ${ERR} = Run Keyword And Expect Error * ... Get object ${WALLET} ${CID} ${S_OID_USER} ${EACL_TOKEN} local_file_eacl ${EMPTY} --xhdr a=256 - Run Keyword And Expect Error * - ... Search object ${WALLET} ${CID} ${EMPTY} ${EACL_TOKEN} ${USER_HEADER} ${EMPTY} --xhdr a=256 - Run Keyword And Expect Error * + Should Contain ${ERR} ${ERROR} + ${ERR} = Run Keyword And Expect Error * + ... Search object ${WALLET} ${CID} bearer=${EACL_TOKEN} filters=${USER_HEADER} options=--xhdr a=256 + Should Contain ${ERR} ${ERROR} + ${ERR} = Run Keyword And Expect Error * ... Head object ${WALLET} ${CID} ${S_OID_USER} bearer_token=${EACL_TOKEN} options=--xhdr a=256 - Run Keyword And Expect Error * - ... Get Range ${WALLET} ${CID} ${S_OID_USER} 0:256 bearer=${EACL_TOKEN} options=--xhdr a=256 - Run Keyword And Expect Error * - ... Get Range Hash ${WALLET} ${CID} ${S_OID_USER} ${EACL_TOKEN} 0:256 --xhdr a=256 - Run Keyword And Expect Error * + Should Contain ${ERR} ${ERROR} + ${ERR} = Run Keyword And Expect Error * + ... Get Range ${WALLET} ${CID} ${S_OID_USER} 0:256 bearer=${EACL_TOKEN} options=--xhdr a=256 + Should Contain ${ERR} ${ERROR} + ${ERR} = Run Keyword And Expect Error * + ... Get Range Hash ${WALLET} ${CID} ${S_OID_USER} ${EACL_TOKEN} 0:256 options=--xhdr a=256 + Should Contain ${ERR} ${ERROR} + ${ERR} = Run Keyword And Expect Error * ... Delete object ${WALLET} ${CID} ${S_OID_USER} bearer=${EACL_TOKEN} options=--xhdr a=256 + Should Contain ${ERR} ${ERROR} diff --git a/robot/testsuites/integration/acl/acl_extended_filters.robot b/robot/testsuites/integration/acl/acl_extended_filters.robot index d4be400..8a53262 100644 --- a/robot/testsuites/integration/acl/acl_extended_filters.robot +++ b/robot/testsuites/integration/acl/acl_extended_filters.robot @@ -11,17 +11,16 @@ Resource payment_operations.robot Resource eacl_tables.robot *** Variables *** -${PATH} = testfile &{USER_HEADER} = key1=1 key2=abc &{ANOTHER_HEADER} = key1=oth key2=oth ${ID_FILTER} = $Object:objectID -${CUSTOM_FILTER} = $Object:key1 +${CUSTOM_FILTER} = key1 *** Test cases *** Extended ACL Operations [Documentation] Testcase to validate NeoFS operations with extended ACL. [Tags] ACL eACL - [Timeout] 2 min + [Timeout] 3 min Check Filters Simple @@ -51,7 +50,7 @@ Check eACL MatchType String Equal Request Deny [Arguments] ${USER_WALLET} ${OTHER_WALLET} ${FILE_S} ${CID} = Create Container ${USER_WALLET} basic_acl=eacl-public-read-write ${S_OID_USER} = Put object ${USER_WALLET} ${FILE_S} ${CID} user_headers=${USER_HEADER} - Get object ${USER_WALLET} ${CID} ${S_OID_USER} ${EMPTY} ${PATH} + Get object ${USER_WALLET} ${CID} ${S_OID_USER} Set eACL ${USER_WALLET} ${CID} ${EACL_XHEADER_DENY_ALL} @@ -59,30 +58,30 @@ Check eACL MatchType String Equal Request Deny Sleep ${NEOFS_CONTRACT_CACHE_TIMEOUT} Run Keyword And Expect Error * - ... Get object ${OTHER_WALLET} ${CID} ${S_OID_USER} ${EMPTY} ${PATH} ${EMPTY} --xhdr a=2 - Get object ${OTHER_WALLET} ${CID} ${S_OID_USER} ${EMPTY} ${PATH} ${EMPTY} --xhdr a=256 + ... Get object ${OTHER_WALLET} ${CID} ${S_OID_USER} options=--xhdr a=2 + Get object ${OTHER_WALLET} ${CID} ${S_OID_USER} options=--xhdr a=256 Run Keyword And Expect Error * ... Put object ${OTHER_WALLET} ${FILE_S} ${CID} user_headers=${ANOTHER_HEADER} options=--xhdr a=2 Run Keyword And Expect Error * - ... Get object ${OTHER_WALLET} ${CID} ${S_OID_USER} ${EMPTY} ${PATH} ${EMPTY} --xhdr a=2 + ... Get object ${OTHER_WALLET} ${CID} ${S_OID_USER} options=--xhdr a=2 Run Keyword And Expect Error * - ... Search object ${OTHER_WALLET} ${CID} ${EMPTY} ${EMPTY} ${USER_HEADER} ${EMPTY} --xhdr a=2 + ... Search object ${OTHER_WALLET} ${CID} filters=${USER_HEADER} options=--xhdr a=2 Run Keyword And Expect Error * ... Head object ${OTHER_WALLET} ${CID} ${S_OID_USER} options=--xhdr a=2 Run Keyword And Expect Error * ... Get Range ${OTHER_WALLET} ${CID} ${S_OID_USER} 0:256 options=--xhdr a="2" Run Keyword And Expect Error * - ... Get Range Hash ${OTHER_WALLET} ${CID} ${S_OID_USER} ${EMPTY} 0:256 --xhdr a=2 + ... Get Range Hash ${OTHER_WALLET} ${CID} ${S_OID_USER} bearer_token=${EMPTY} range_cut=0:256 options=--xhdr a=2 Run Keyword And Expect Error * - ... Delete object ${OTHER_WALLET} ${CID} ${S_OID_USER} ${EMPTY} --xhdr a=2 + ... Delete object ${OTHER_WALLET} ${CID} ${S_OID_USER} options=--xhdr a=2 Put object ${OTHER_WALLET} ${FILE_S} ${CID} user_headers=${ANOTHER_HEADER} options=--xhdr a=256 - Get object ${OTHER_WALLET} ${CID} ${S_OID_USER} ${EMPTY} ${PATH} ${EMPTY} --xhdr a=* - Search object ${OTHER_WALLET} ${CID} ${EMPTY} ${EMPTY} ${USER_HEADER} ${EMPTY} --xhdr a= + Get object ${OTHER_WALLET} ${CID} ${S_OID_USER} options=--xhdr a=* + Search object ${OTHER_WALLET} ${CID} filters=${USER_HEADER} options=--xhdr a= Head object ${OTHER_WALLET} ${CID} ${S_OID_USER} options=--xhdr a=.* Get Range ${OTHER_WALLET} ${CID} ${S_OID_USER} 0:256 options=--xhdr a="2 2" - Get Range Hash ${OTHER_WALLET} ${CID} ${S_OID_USER} ${EMPTY} 0:256 --xhdr a=256 + Get Range Hash ${OTHER_WALLET} ${CID} ${S_OID_USER} bearer_token=${EMPTY} range_cut=0:256 options=--xhdr a=256 Delete object ${OTHER_WALLET} ${CID} ${S_OID_USER} options=--xhdr a=22 @@ -91,7 +90,7 @@ Check eACL MatchType String Equal Request Allow ${CID} = Create Container ${USER_WALLET} basic_acl=eacl-public-read-write ${S_OID_USER} = Put Object ${USER_WALLET} ${FILE_S} ${CID} - Get Object ${OTHER_WALLET} ${CID} ${S_OID_USER} ${EMPTY} ${PATH} + Get Object ${OTHER_WALLET} ${CID} ${S_OID_USER} Set eACL ${USER_WALLET} ${CID} ${EACL_XHEADER_ALLOW_ALL} @@ -101,28 +100,28 @@ Check eACL MatchType String Equal Request Allow Get eACL ${USER_WALLET} ${CID} Run Keyword And Expect Error * - ... Get object ${OTHER_WALLET} ${CID} ${S_OID_USER} ${EMPTY} ${PATH} ${EMPTY} + ... Get object ${OTHER_WALLET} ${CID} ${S_OID_USER} Run Keyword And Expect Error * ... Put object ${OTHER_WALLET} ${FILE_S} ${CID} Run Keyword And Expect Error * - ... Get object ${OTHER_WALLET} ${CID} ${S_OID_USER} ${EMPTY} ${PATH} ${EMPTY} + ... Get object ${OTHER_WALLET} ${CID} ${S_OID_USER} Run Keyword And Expect Error * - ... Search object ${OTHER_WALLET} ${CID} ${EMPTY} ${EMPTY} ${USER_HEADER} ${EMPTY} + ... Search object ${OTHER_WALLET} ${CID} filters=${USER_HEADER} Run Keyword And Expect Error * ... Head object ${OTHER_WALLET} ${CID} ${S_OID_USER} Run Keyword And Expect Error * ... Get Range ${OTHER_WALLET} ${CID} ${S_OID_USER} 0:256 Run Keyword And Expect Error * - ... Get Range Hash ${OTHER_WALLET} ${CID} ${S_OID_USER} ${EMPTY} 0:256 + ... Get Range Hash ${OTHER_WALLET} ${CID} ${S_OID_USER} bearer_token=${EMPTY} range_cut=0:256 Run Keyword And Expect Error * ... Delete object ${OTHER_WALLET} ${CID} ${S_OID_USER} Put object ${OTHER_WALLET} ${FILE_S} ${CID} options=--xhdr a=2 - Get object ${OTHER_WALLET} ${CID} ${S_OID_USER} ${EMPTY} ${PATH} ${EMPTY} --xhdr a=2 - Search object ${OTHER_WALLET} ${CID} ${EMPTY} ${EMPTY} ${USER_HEADER} ${EMPTY} --xhdr a=2 + Get object ${OTHER_WALLET} ${CID} ${S_OID_USER} options=--xhdr a=2 + Search object ${OTHER_WALLET} ${CID} filters=${USER_HEADER} options=--xhdr a=2 Head object ${OTHER_WALLET} ${CID} ${S_OID_USER} options=--xhdr a=2 Get Range ${OTHER_WALLET} ${CID} ${S_OID_USER} 0:256 options=--xhdr a=2 - Get Range Hash ${OTHER_WALLET} ${CID} ${S_OID_USER} ${EMPTY} 0:256 --xhdr a=2 + Get Range Hash ${OTHER_WALLET} ${CID} ${S_OID_USER} bearer_token=${EMPTY} range_cut=0:256 options=--xhdr a=2 Delete object ${OTHER_WALLET} ${CID} ${S_OID_USER} options=--xhdr a=2 @@ -131,7 +130,7 @@ Check eACL MatchType String Equal Object ${CID} = Create Container ${USER_WALLET} basic_acl=eacl-public-read-write ${S_OID_USER} = Put Object ${USER_WALLET} ${FILE_S} ${CID} user_headers=${USER_HEADER} - Get Object ${OTHER_WALLET} ${CID} ${S_OID_USER} ${EMPTY} ${PATH} + Get Object ${OTHER_WALLET} ${CID} ${S_OID_USER} Log Set eACL for Deny GET operation with StringEqual Object ID @@ -144,7 +143,7 @@ Check eACL MatchType String Equal Object ${EACL_CUSTOM} = Create eACL ${CID} ${eACL_gen} Set eACL ${USER_WALLET} ${CID} ${EACL_CUSTOM} Run Keyword And Expect Error * - ... Get object ${OTHER_WALLET} ${CID} ${S_OID_USER} ${EMPTY} ${PATH} + ... Get object ${OTHER_WALLET} ${CID} ${S_OID_USER} Log Set eACL for Deny GET operation with StringEqual Object Extended User Header @@ -157,8 +156,8 @@ Check eACL MatchType String Equal Object Set eACL ${USER_WALLET} ${CID} ${EACL_CUSTOM} Run Keyword And Expect Error * - ... Get object ${OTHER_WALLET} ${CID} ${S_OID_USER} ${EMPTY} ${PATH} - Get object ${OTHER_WALLET} ${CID} ${S_OID_USER_OTH} ${EMPTY} ${PATH} + ... Get object ${OTHER_WALLET} ${CID} ${S_OID_USER} + Get object ${OTHER_WALLET} ${CID} ${S_OID_USER_OTH} Check eACL MatchType String Not Equal Object @@ -166,10 +165,10 @@ Check eACL MatchType String Not Equal Object ${CID} = Create Container ${USER_WALLET} basic_acl=eacl-public-read-write - ${S_OID_USER} = Put object ${USER_WALLET} ${FILE_S} ${CID} user_headers=${USER_HEADER} - ${S_OID_OTHER} = Put object ${OTHER_WALLET} ${FILE_S} ${CID} user_headers=${ANOTHER_HEADER} - Get object ${OTHER_WALLET} ${CID} ${S_OID_USER} ${EMPTY} ${PATH} - Get object ${OTHER_WALLET} ${CID} ${S_OID_OTHER} ${EMPTY} ${PATH} + ${S_OID_USER} = Put object ${USER_WALLET} ${FILE_S} ${CID} + ${S_OID_OTHER} = Put object ${OTHER_WALLET} ${FILE_S} ${CID} + Get object ${OTHER_WALLET} ${CID} ${S_OID_USER} + Get object ${OTHER_WALLET} ${CID} ${S_OID_OTHER} Log Set eACL for Deny GET operation with StringNotEqual Object ID @@ -183,8 +182,8 @@ Check eACL MatchType String Not Equal Object Set eACL ${USER_WALLET} ${CID} ${EACL_CUSTOM} Run Keyword And Expect Error * - ... Get object ${OTHER_WALLET} ${CID} ${S_OID_OTHER} ${EMPTY} ${PATH} - Get object ${OTHER_WALLET} ${CID} ${S_OID_USER} ${EMPTY} ${PATH} + ... Get object ${OTHER_WALLET} ${CID} ${S_OID_OTHER} + Get object ${OTHER_WALLET} ${CID} ${S_OID_USER} Log Set eACL for Deny GET operation with StringEqual Object Extended User Header @@ -196,5 +195,5 @@ Check eACL MatchType String Not Equal Object Set eACL ${USER_WALLET} ${CID} ${EACL_CUSTOM} Run Keyword And Expect Error * - ... Get object ${OTHER_WALLET} ${CID} ${S_OID_USER_OTH} ${EMPTY} ${PATH} - Get object ${OTHER_WALLET} ${CID} ${S_OID_USER} ${EMPTY} ${PATH} + ... Get object ${OTHER_WALLET} ${CID} ${S_OID_USER_OTH} + Get object ${OTHER_WALLET} ${CID} ${S_OID_USER}