1*** Settings *** 2Documentation Test Redfish to verify responses for SessionService and Hypermedia. 3 4Resource ../../lib/bmc_redfish_resource.robot 5Resource ../../lib/openbmc_ffdc.robot 6 7Test Teardown FFDC On Test Case Fail 8Test Setup Printn 9 10Test Tags Service_Root 11 12*** Test Cases *** 13 14Redfish Login And Logout 15 [Documentation] Login to BMCweb and then logout. 16 [Tags] Redfish_Login_And_Logout 17 18 Redfish.Login 19 Redfish.Logout 20 21 22GET Redfish Hypermedia Without Login 23 [Documentation] GET hypermedia URL without login. 24 [Tags] GET_Redfish_Hypermedia_Without_Login 25 [Setup] Redfish.Logout 26 [Template] GET And Verify Redfish Response 27 28 # Expect status Resource URL Path 29 ${HTTP_OK} /redfish 30 ${HTTP_OK} /redfish/v1 31 32 33GET Redfish SessionService Without Login 34 [Documentation] Get /redfish/v1/SessionService without login 35 [Tags] GET_Redfish_SessionService_Without_Login 36 [Setup] Redfish.Logout 37 38 Redfish.Get /redfish/v1/SessionService 39 ... valid_status_codes=[${HTTP_UNAUTHORIZED}] 40 41 42GET Redfish Resources With Login 43 [Documentation] Login to BMCweb and GET valid resource. 44 [Tags] GET_Redfish_Resources_With_Login 45 [Setup] Redfish.Login 46 [Template] GET And Verify Redfish Response 47 48 # Expect status Resource URL Path 49 ${HTTP_OK} /redfish/v1/SessionService 50 ${HTTP_OK} /redfish/v1/AccountService 51 ${HTTP_OK} /redfish/v1/Systems/${SYSTEM_ID} 52 ${HTTP_OK} /redfish/v1/Chassis/${CHASSIS_ID} 53 ${HTTP_OK} /redfish/v1/Managers/${MANAGER_ID} 54 ${HTTP_OK} /redfish/v1/UpdateService 55 56 57Redfish Login Using Invalid Token 58 [Documentation] Login to BMCweb with invalid token. 59 [Tags] Redfish_Login_Using_Invalid_Token 60 61 Create Session openbmc ${AUTH_URI} 62 63 # Example: "X-Auth-Token: 3la1JUf1vY4yN2dNOwun" 64 VAR &{headers} = Content-Type=application/json 65 ... X-Auth-Token=deadbeef 66 67 ${resp} = GET On Session 68 ... openbmc /redfish/v1/SessionService/Sessions headers=${headers} 69 ... expected_status=${HTTP_UNAUTHORIZED} 70 71 Should Be Equal As Strings ${resp.status_code} ${HTTP_UNAUTHORIZED} 72 73 74Verify Redfish Invalid URL Response Code 75 [Documentation] Login to BMCweb and verify error response code. 76 [Tags] Verify_Redfish_Invalid_URL_Response_Code 77 78 Redfish.Login 79 Wait Until Keyword Succeeds 1 min 30 sec 80 ... Redfish.Get /redfish/v1/idontexist valid_status_codes=[${HTTP_NOT_FOUND}] 81 Redfish.Logout 82 83 84Delete Redfish Session Using Valid Login 85 [Documentation] Delete a session using valid login. 86 [Tags] Delete_Redfish_Session_Using_Valid_Login 87 88 Redfish.Login 89 ${session_info} = Get Redfish Session Info 90 91 Redfish.Login 92 93 # Example o/p: 94 # [{'@odata.id': '/redfish/v1/SessionService/Sessions/bOol3WlCI8'}, 95 # {'@odata.id': '/redfish/v1/SessionService/Sessions/Yu3xFqjZr1'}] 96 ${resp_list} = Redfish_Utils.List Request 97 ... /redfish/v1/SessionService/Sessions 98 99 Redfish.Delete ${session_info["location"]} 100 101 ${resp} = Redfish_Utils.List Request /redfish/v1/SessionService/Sessions 102 List Should Not Contain Value ${resp} ${session_info["location"]} 103 104 105Redfish Login Via SessionService 106 [Documentation] Login to BMC via redfish session service. 107 [Tags] Redfish_Login_Via_SessionService 108 109 Create Session openbmc https://${OPENBMC_HOST}:${HTTPS_PORT} 110 VAR &{headers} = Content-Type=application/json 111 VAR ${data} = {"UserName":"${OPENBMC_USERNAME}", "Password":"${OPENBMC_PASSWORD}"} 112 113 ${resp} = POST On Session openbmc /redfish/v1/SessionService/Sessions data=${data} headers=${headers} 114 Should Be Equal As Strings ${resp.status_code} ${HTTP_CREATED} 115 116 VAR &{headers} = Content-Type=application/json 117 ... X-Auth-Token=${resp.headers["X-Auth-Token"]} 118 ${resp} = DELETE On Session openbmc ${REDFISH_SESSION}${/}${resp.json()["Id"]} headers=${headers} 119 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} 120 121 122Verify Redfish Unresponsive URL paths 123 [Documentation] Verify that all URLs in /redfish/v1 respond. 124 [Tags] Verify_Redfish_Unresponsive_URL_paths 125 126 Redfish.Login 127 ${resource_list} ${dead_resources} = Enumerate Request /redfish/v1 include_dead_resources=True 128 Redfish.Logout 129 Valid Length dead_resources max_length=0 130 131 132Verify Service Root Unsupported Methods 133 [Documentation] Verify Unsupported methods of service root 134 [Tags] Verify_Service_Root_Unsupported_Methods 135 136 # Put operation on Service Root 137 Redfish.Put /redfish/v1 138 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}] 139 140 # Post operation on Service Root 141 Redfish.Post /redfish/v1/ 142 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}] 143 144 # Delete operation on Service Root 145 Redfish.Delete /redfish/v1 146 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}] 147 148 # Patch operation on Service Root 149 Redfish.Patch /redfish/v1 150 ... valid_status_codes=[${HTTP_METHOD_NOT_ALLOWED}] 151 152*** Keywords *** 153 154GET And Verify Redfish Response 155 [Documentation] GET given resource and verify response. 156 [Arguments] ${valid_status_codes} ${resource_path} 157 158 # Description of argument(s): 159 # valid_status_codes A comma-separated list of acceptable 160 # status codes (e.g. 200). 161 # resource_path Redfish resource URL path. 162 163 Redfish.Get ${resource_path} 164 ... valid_status_codes=[${valid_status_codes}] 165