manashsarma | 579d825 | 2020-05-28 08:10:51 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | |
| 3 | |
| 4 | Documentation Utilities for Redfishtool testing. |
| 5 | |
| 6 | Resource resource.robot |
| 7 | Resource bmc_redfish_resource.robot |
| 8 | Library OperatingSystem |
| 9 | Library String |
| 10 | Library Collections |
| 11 | |
| 12 | |
| 13 | *** Keywords *** |
| 14 | |
| 15 | Redfishtool Get |
| 16 | [Documentation] Execute redfishtool for GET operation. |
| 17 | [Arguments] ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}=200 |
| 18 | |
| 19 | # Description of argument(s): |
| 20 | # uri URI for GET operation (e.g. /redfish/v1/AccountService/Accounts/). |
| 21 | # cmd_args Commandline arguments. |
| 22 | # expected_error Expected error optionally provided in testcase (e.g. 401 / |
| 23 | # authentication error, etc. ). |
| 24 | |
| 25 | ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} GET ${uri} |
| 26 | Run Keyword If ${rc} == 0 |
| 27 | ... Should Be True ${expected_error} == 200 |
| 28 | ... ELSE |
| 29 | ... Is HTTP error Expected ${cmd_output} ${expected_error} |
| 30 | |
| 31 | [Return] ${cmd_output} |
| 32 | |
| 33 | |
| 34 | Redfishtool Patch |
| 35 | [Documentation] Execute redfishtool for Patch operation. |
| 36 | [Arguments] ${payload} ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}=200 |
| 37 | |
| 38 | # Description of argument(s): |
| 39 | # payload Payload with POST operation (e.g. data for user name, role, etc. ). |
| 40 | # uri URI for PATCH operation (e.g. /redfish/v1/AccountService/Accounts/ ). |
| 41 | # cmd_args Commandline arguments. |
| 42 | # expected_error Expected error optionally provided in testcase (e.g. 401 / |
| 43 | # authentication error, etc. ). |
| 44 | |
| 45 | ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} PATCH ${uri} --data=${payload} |
| 46 | Run Keyword If ${rc} == 0 |
| 47 | ... Should Be True ${expected_error} == 200 |
| 48 | ... ELSE |
| 49 | ... Is HTTP error Expected ${cmd_output} ${expected_error} |
| 50 | |
| 51 | [Return] ${cmd_output} |
| 52 | |
| 53 | |
| 54 | Redfishtool Post |
| 55 | [Documentation] Execute redfishtool for Post operation. |
| 56 | [Arguments] ${payload} ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}=200 |
| 57 | |
| 58 | # Description of argument(s): |
| 59 | # payload Payload with POST operation (e.g. data for user name, password, role, |
| 60 | # enabled attribute) |
| 61 | # uri URI for POST operation (e.g. /redfish/v1/AccountService/Accounts/). |
| 62 | # cmd_args Commandline arguments. |
| 63 | # expected_error Expected error optionally provided in testcase (e.g. 401 / |
| 64 | # authentication error, etc. ). |
| 65 | |
| 66 | ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} POST ${uri} --data=${payload} |
| 67 | Run Keyword If ${rc} == 0 |
| 68 | ... Should Be True ${expected_error} == 200 |
| 69 | ... ELSE |
| 70 | ... Is HTTP error Expected ${cmd_output} ${expected_error} |
| 71 | |
| 72 | [Return] ${cmd_output} |
| 73 | |
| 74 | |
| 75 | Redfishtool Delete |
| 76 | [Documentation] Execute redfishtool for Post operation. |
| 77 | [Arguments] ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}=200 |
| 78 | |
| 79 | # Description of argument(s): |
| 80 | # uri URI for DELETE operation. |
| 81 | # cmd_args Commandline arguments. |
| 82 | # expected_error Expected error optionally provided in testcase (e.g. 401 / |
| 83 | # authentication error, etc. ). |
| 84 | |
| 85 | ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} DELETE ${uri} |
| 86 | Run Keyword If ${rc} == 0 |
| 87 | ... Should Be True ${expected_error} == 200 |
| 88 | ... ELSE |
| 89 | ... Is HTTP error Expected ${cmd_output} ${expected_error} |
| 90 | |
| 91 | [Return] ${cmd_output} |
| 92 | |
| 93 | |
| 94 | Is HTTP error Expected |
| 95 | [Documentation] Check if the HTTP error is expected. |
| 96 | [Arguments] ${cmd_output} ${error_expected} |
| 97 | |
| 98 | # Description of argument(s): |
| 99 | # cmd_output Output of an HTTP operation. |
| 100 | # error_expected Expected error. |
| 101 | |
| 102 | Should Be True ${error_expected} != 200 |
| 103 | @{words} = Split String ${error_expected} , |
| 104 | @{errorString}= Split String ${cmd_output} ${SPACE} |
| 105 | Should Contain Any ${errorString} @{words} |