1*** Settings *** 2Resource ../../lib/resource.robot 3Resource ../../lib/bmc_redfish_resource.robot 4Resource ../../lib/openbmc_ffdc.robot 5 6Test Teardown FFDC On Test Case Fail 7 8*** Variables *** 9 10${LOGIN_SESSION_COUNT} ${50} 11 12*** Test Cases *** 13 14Redfish Login With Invalid Credentials 15 [Documentation] Login to BMC web using invalid credential. 16 [Tags] Redfish_Login_With_Invalid_Credentials 17 [Template] Login And Verify Redfish Response 18 19 # Expect status Username Password 20 InvalidCredentialsError* ${OPENBMC_USERNAME} deadpassword 21 InvalidCredentialsError* groot ${OPENBMC_PASSWORD} 22 InvalidCredentialsError* ${EMPTY} ${OPENBMC_PASSWORD} 23 InvalidCredentialsError* ${OPENBMC_USERNAME} ${EMPTY} 24 InvalidCredentialsError* ${EMPTY} ${EMPTY} 25 26 27Redfish Login Using Unsecured HTTP 28 [Documentation] Login to BMC web through http unsecured. 29 [Tags] Redfish_Login_Using_Unsecured_HTTP 30 31 Create Session openbmc http://${OPENBMC_HOST} 32 ${data}= Create Dictionary 33 ... UserName=${OPENBMC_USERNAME} Password=${OPENBMC_PASSWORD} 34 35 ${headers}= Create Dictionary Content-Type=application/json 36 37 Run Keyword And Expect Error *Connection refused* 38 ... Post Request openbmc /redfish/v1/SessionService/Sessions 39 ... data=${data} headers=${headers} 40 41 42Redfish Login Using HTTPS Wrong Port 80 Protocol 43 [Documentation] Login to BMC web through wrong protocol port 80. 44 [Tags] Redfish_Login_Using_HTTPS_Wrong_Port_80_Protocol 45 46 Create Session openbmc https://${OPENBMC_HOST}:80 47 ${data}= Create Dictionary 48 ... UserName=${OPENBMC_USERNAME} Password=${OPENBMC_PASSWORD} 49 50 ${headers}= Create Dictionary Content-Type=application/json 51 52 Run Keyword And Expect Error *Connection refused* 53 ... Post Request openbmc /redfish/v1/SessionService/Sessions 54 ... data=${data} headers=${headers} 55 56 57Create Multiple Login Sessions And Verify 58 [Documentation] Create 50 login instances and verify. 59 [Tags] Create_Multiple_Login_Sessions_And_Verify 60 [Teardown] Multiple Session Cleanup 61 62 redfish.Login 63 # Example: 64 # { 65 # 'key': 'L0XEsZAXpNdF147jJaOD', 66 # 'location': '/redfish/v1/SessionService/Sessions/qWn2JOJSOs' 67 # } 68 ${saved_session_info}= Get Redfish Session Info 69 70 # Sessions book keeping for cleanup once done. 71 ${session_list}= Create List 72 Set Test Variable ${session_list} 73 74 Repeat Keyword ${LOGIN_SESSION_COUNT} times Create New Login Session 75 76 # Update the redfish session object with the first login key and location 77 # and verify if it is still working. 78 redfish.Set Session Key ${saved_session_info["key"]} 79 redfish.Set Session Location ${saved_session_info["location"]} 80 ${resp}= redfish.Get ${saved_session_info["location"]} 81 Should Be Equal As Strings ${resp.status} ${HTTP_OK} 82 83 84Attempt Login With Expired Session 85 [Documentation] Authenticate to redfish, then log out and attempt to 86 ... use the session. 87 [Tags] Attempt_Login_With_Expired_Session 88 89 redfish.Login 90 ${saved_session_info}= Get Redfish Session Info 91 redfish.Logout 92 93 # Attempt login with expired session. 94 # By default 60 minutes of inactivity closes the session. 95 redfish.Set Session Key ${saved_session_info["key"]} 96 redfish.Set Session Location ${saved_session_info["location"]} 97 98 ${resp}= redfish.Get ${saved_session_info["location"]} 99 Should Be Equal As Strings ${resp.status} ${HTTP_UNAUTHORIZED} 100 101 102*** Keywords *** 103 104Login And Verify Redfish Response 105 [Documentation] Login and verify redfish response. 106 [Arguments] ${expected_response} ${username} ${password} 107 108 # Description of arguments: 109 # expected_response Expected REST status. 110 # username The username to be used to connect to the server. 111 # password The password to be used to connect to the server. 112 113 ${data}= Create Dictionary username=${username} password=${password} 114 Run Keyword And Expect Error ${expected_response} redfish.Login ${data} 115 116 117Create New Login Session 118 [Documentation] Multiple login session keys. 119 120 redfish.Login 121 ${session_info}= Get Redfish Session Info 122 123 # Append the session location to the list. 124 # ['/redfish/v1/SessionService/Sessions/uDzihgDecs', 125 # '/redfish/v1/SessionService/Sessions/PaHF5brPPd'] 126 Append To List ${session_list} ${session_info["location"]} 127 128 129Multiple Session Cleanup 130 [Documentation] Do the teardown for multiple sessions. 131 132 FFDC On Test Case Fail 133 134 :FOR ${item} IN @{session_list} 135 \ redfish.Delete ${item} 136 137