George Keishing | 4c39401 | 2019-02-01 06:03:02 -0600 | [diff] [blame] | 1 | *** Settings *** |
Joy Onyerikwu | dbfe97d | 2019-03-11 19:44:56 -0500 | [diff] [blame] | 2 | Documentation Test Redfish service root login security. |
| 3 | |
George Keishing | 4c39401 | 2019-02-01 06:03:02 -0600 | [diff] [blame] | 4 | Resource ../../lib/bmc_redfish_resource.robot |
George Keishing | 3298d5c | 2019-02-12 06:59:25 -0600 | [diff] [blame] | 5 | Resource ../../lib/openbmc_ffdc.robot |
| 6 | |
| 7 | Test Teardown FFDC On Test Case Fail |
Michael Walsh | c108e42 | 2019-03-28 12:27:18 -0500 | [diff] [blame] | 8 | Test Setup Printn |
George Keishing | 4c39401 | 2019-02-01 06:03:02 -0600 | [diff] [blame] | 9 | |
George Keishing | 374e684 | 2019-02-20 08:57:18 -0600 | [diff] [blame] | 10 | *** Variables *** |
| 11 | |
| 12 | ${LOGIN_SESSION_COUNT} ${50} |
| 13 | |
George Keishing | 35e0bba | 2019-06-04 13:10:55 -0500 | [diff] [blame] | 14 | &{header_requirements} Strict-Transport-Security=max-age=31536000; includeSubdomains; preload |
| 15 | ... X-Frame-Options=DENY |
| 16 | ... Pragma=no-cache |
| 17 | ... Cache-Control=no-Store,no-Cache |
Brian Ma | 2bbdb3b | 2022-04-21 14:03:46 +0800 | [diff] [blame] | 18 | ... Content-Security-Policy=default-src 'none'; img-src 'self' data:; font-src 'self'; style-src 'self'; script-src 'self'; connect-src 'self' wss:; form-action 'none'; frame-ancestors 'none'; object-src 'none'; base-uri 'none' |
George Keishing | 35e0bba | 2019-06-04 13:10:55 -0500 | [diff] [blame] | 19 | ... X-XSS-Protection=1; mode=block |
| 20 | ... X-Content-Type-Options=nosniff |
George Keishing | 9edf5bc | 2019-04-09 15:07:28 -0500 | [diff] [blame] | 21 | |
George Keishing | 4c39401 | 2019-02-01 06:03:02 -0600 | [diff] [blame] | 22 | *** Test Cases *** |
| 23 | |
George Keishing | 5ee33d9 | 2019-02-02 12:33:25 -0600 | [diff] [blame] | 24 | Redfish Login With Invalid Credentials |
George Keishing | 4c39401 | 2019-02-01 06:03:02 -0600 | [diff] [blame] | 25 | [Documentation] Login to BMC web using invalid credential. |
George Keishing | 5ee33d9 | 2019-02-02 12:33:25 -0600 | [diff] [blame] | 26 | [Tags] Redfish_Login_With_Invalid_Credentials |
George Keishing | 4c39401 | 2019-02-01 06:03:02 -0600 | [diff] [blame] | 27 | [Template] Login And Verify Redfish Response |
| 28 | |
George Keishing | 3261604 | 2022-09-22 05:25:39 -0500 | [diff] [blame] | 29 | # Username Password Expect status |
| 30 | ${OPENBMC_USERNAME} deadpassword InvalidCredentialsError |
| 31 | groot ${OPENBMC_PASSWORD} InvalidCredentialsError |
| 32 | ${EMPTY} ${OPENBMC_PASSWORD} SessionCreationError |
| 33 | ${OPENBMC_USERNAME} ${EMPTY} SessionCreationError |
| 34 | ${EMPTY} ${EMPTY} SessionCreationError |
George Keishing | 4c39401 | 2019-02-01 06:03:02 -0600 | [diff] [blame] | 35 | |
| 36 | |
George Keishing | 5ee33d9 | 2019-02-02 12:33:25 -0600 | [diff] [blame] | 37 | Redfish Login Using Unsecured HTTP |
George Keishing | a811693 | 2019-02-05 11:51:47 -0600 | [diff] [blame] | 38 | [Documentation] Login to BMC web through http unsecured. |
George Keishing | 5ee33d9 | 2019-02-02 12:33:25 -0600 | [diff] [blame] | 39 | [Tags] Redfish_Login_Using_Unsecured_HTTP |
George Keishing | a811693 | 2019-02-05 11:51:47 -0600 | [diff] [blame] | 40 | |
| 41 | Create Session openbmc http://${OPENBMC_HOST} |
| 42 | ${data}= Create Dictionary |
| 43 | ... UserName=${OPENBMC_USERNAME} Password=${OPENBMC_PASSWORD} |
| 44 | |
| 45 | ${headers}= Create Dictionary Content-Type=application/json |
| 46 | |
| 47 | Run Keyword And Expect Error *Connection refused* |
George Keishing | fbd6700 | 2022-08-01 11:24:03 -0500 | [diff] [blame] | 48 | ... POST On Session openbmc /redfish/v1/SessionService/Sessions |
George Keishing | a811693 | 2019-02-05 11:51:47 -0600 | [diff] [blame] | 49 | ... data=${data} headers=${headers} |
| 50 | |
| 51 | |
George Keishing | b2f0734 | 2019-02-09 05:21:45 -0600 | [diff] [blame] | 52 | Redfish Login Using HTTPS Wrong Port 80 Protocol |
| 53 | [Documentation] Login to BMC web through wrong protocol port 80. |
| 54 | [Tags] Redfish_Login_Using_HTTPS_Wrong_Port_80_Protocol |
| 55 | |
| 56 | Create Session openbmc https://${OPENBMC_HOST}:80 |
| 57 | ${data}= Create Dictionary |
| 58 | ... UserName=${OPENBMC_USERNAME} Password=${OPENBMC_PASSWORD} |
| 59 | |
| 60 | ${headers}= Create Dictionary Content-Type=application/json |
| 61 | |
| 62 | Run Keyword And Expect Error *Connection refused* |
George Keishing | fbd6700 | 2022-08-01 11:24:03 -0500 | [diff] [blame] | 63 | ... POST On Session openbmc /redfish/v1/SessionService/Sessions |
George Keishing | b2f0734 | 2019-02-09 05:21:45 -0600 | [diff] [blame] | 64 | ... data=${data} headers=${headers} |
| 65 | |
| 66 | |
George Keishing | 374e684 | 2019-02-20 08:57:18 -0600 | [diff] [blame] | 67 | Create Multiple Login Sessions And Verify |
| 68 | [Documentation] Create 50 login instances and verify. |
| 69 | [Tags] Create_Multiple_Login_Sessions_And_Verify |
Sushil Singh | d1a35ac | 2020-08-04 11:28:56 -0500 | [diff] [blame] | 70 | [Teardown] Run Keyword And Ignore Error Multiple Session Cleanup |
George Keishing | 374e684 | 2019-02-20 08:57:18 -0600 | [diff] [blame] | 71 | |
George Keishing | 97c9394 | 2019-03-04 12:45:07 -0600 | [diff] [blame] | 72 | Redfish.Login |
George Keishing | 374e684 | 2019-02-20 08:57:18 -0600 | [diff] [blame] | 73 | # Example: |
| 74 | # { |
| 75 | # 'key': 'L0XEsZAXpNdF147jJaOD', |
| 76 | # 'location': '/redfish/v1/SessionService/Sessions/qWn2JOJSOs' |
| 77 | # } |
George Keishing | 0b9d8ab | 2019-02-20 14:02:41 -0600 | [diff] [blame] | 78 | ${saved_session_info}= Get Redfish Session Info |
George Keishing | 374e684 | 2019-02-20 08:57:18 -0600 | [diff] [blame] | 79 | |
| 80 | # Sessions book keeping for cleanup once done. |
| 81 | ${session_list}= Create List |
| 82 | Set Test Variable ${session_list} |
| 83 | |
| 84 | Repeat Keyword ${LOGIN_SESSION_COUNT} times Create New Login Session |
| 85 | |
| 86 | # Update the redfish session object with the first login key and location |
| 87 | # and verify if it is still working. |
George Keishing | 97c9394 | 2019-03-04 12:45:07 -0600 | [diff] [blame] | 88 | Redfish.Set Session Key ${saved_session_info["key"]} |
| 89 | Redfish.Set Session Location ${saved_session_info["location"]} |
| 90 | Redfish.Get ${saved_session_info["location"]} |
George Keishing | 374e684 | 2019-02-20 08:57:18 -0600 | [diff] [blame] | 91 | |
| 92 | |
George Keishing | 0b9d8ab | 2019-02-20 14:02:41 -0600 | [diff] [blame] | 93 | Attempt Login With Expired Session |
| 94 | [Documentation] Authenticate to redfish, then log out and attempt to |
| 95 | ... use the session. |
| 96 | [Tags] Attempt_Login_With_Expired_Session |
| 97 | |
George Keishing | 97c9394 | 2019-03-04 12:45:07 -0600 | [diff] [blame] | 98 | Redfish.Login |
George Keishing | 0b9d8ab | 2019-02-20 14:02:41 -0600 | [diff] [blame] | 99 | ${saved_session_info}= Get Redfish Session Info |
George Keishing | 97c9394 | 2019-03-04 12:45:07 -0600 | [diff] [blame] | 100 | Redfish.Logout |
George Keishing | 0b9d8ab | 2019-02-20 14:02:41 -0600 | [diff] [blame] | 101 | |
| 102 | # Attempt login with expired session. |
| 103 | # By default 60 minutes of inactivity closes the session. |
George Keishing | 97c9394 | 2019-03-04 12:45:07 -0600 | [diff] [blame] | 104 | Redfish.Set Session Key ${saved_session_info["key"]} |
| 105 | Redfish.Set Session Location ${saved_session_info["location"]} |
George Keishing | 0b9d8ab | 2019-02-20 14:02:41 -0600 | [diff] [blame] | 106 | |
George Keishing | 97c9394 | 2019-03-04 12:45:07 -0600 | [diff] [blame] | 107 | Redfish.Get ${saved_session_info["location"]} valid_status_codes=[${HTTP_UNAUTHORIZED}] |
George Keishing | 0b9d8ab | 2019-02-20 14:02:41 -0600 | [diff] [blame] | 108 | |
| 109 | |
George Keishing | 9edf5bc | 2019-04-09 15:07:28 -0500 | [diff] [blame] | 110 | Login And Verify HTTP Response Header |
| 111 | [Documentation] Login and verify redfish HTTP response header. |
| 112 | [Tags] Login_And_Verify_HTTP_Response_Header |
| 113 | |
| 114 | # Example of HTTP redfish response header. |
| 115 | # Strict-Transport-Security: max-age=31536000; includeSubdomains; preload |
| 116 | # X-Frame-Options: DENY |
| 117 | # Pragma: no-cache |
| 118 | # Cache-Control: no-Store,no-Cache |
| 119 | # Content-Security-Policy: default-src 'self'; img-src 'self' data: |
| 120 | # X-XSS-Protection: 1; mode=block |
| 121 | # X-Content-Type-Options: nosniff |
| 122 | |
Michael Walsh | 0d5f96a | 2019-05-20 10:09:57 -0500 | [diff] [blame] | 123 | Rprint Vars header_requirements fmt=1 |
George Keishing | 9edf5bc | 2019-04-09 15:07:28 -0500 | [diff] [blame] | 124 | |
| 125 | Redfish.Login |
| 126 | ${resp}= Redfish.Get /redfish/v1/SessionService/Sessions |
| 127 | |
| 128 | # The getheaders() method returns the headers as a list of tuples: |
| 129 | # headers: |
| 130 | # [Strict-Transport-Security]: max-age=31536000; includeSubdomains; preload |
| 131 | # [X-Frame-Options]: DENY |
| 132 | # [Pragma]: no-cache |
| 133 | # [Cache-Control]: no-Store,no-Cache |
| 134 | # [Content-Security-Policy]: default-src 'self'; img-src 'self' data: |
| 135 | # [X-XSS-Protection]: 1; mode=block |
| 136 | # [X-Content-Type-Options]: nosniff |
| 137 | # [X-UA-Compatible]: IE=11 |
| 138 | # [Content-Type]: application/json |
| 139 | # [Server]: iBMC |
| 140 | # [Date]: Tue, 16 Apr 2019 17:49:46 GMT |
| 141 | # [Content-Length]: 2177 |
| 142 | |
| 143 | ${headers}= Key Value List To Dict ${resp.getheaders()} |
Michael Walsh | 0d5f96a | 2019-05-20 10:09:57 -0500 | [diff] [blame] | 144 | Rprint Vars headers fmt=1 |
George Keishing | 9edf5bc | 2019-04-09 15:07:28 -0500 | [diff] [blame] | 145 | |
| 146 | Dictionary Should Contain Sub Dictionary ${headers} ${header_requirements} |
| 147 | |
| 148 | |
George Keishing | 4c39401 | 2019-02-01 06:03:02 -0600 | [diff] [blame] | 149 | *** Keywords *** |
| 150 | |
| 151 | Login And Verify Redfish Response |
| 152 | [Documentation] Login and verify redfish response. |
George Keishing | 3261604 | 2022-09-22 05:25:39 -0500 | [diff] [blame] | 153 | [Arguments] ${username} ${password} ${expected_response} |
George Keishing | 4c39401 | 2019-02-01 06:03:02 -0600 | [diff] [blame] | 154 | |
| 155 | # Description of arguments: |
George Keishing | 3261604 | 2022-09-22 05:25:39 -0500 | [diff] [blame] | 156 | # expected_response Expected REST status. |
| 157 | # username The username to be used to connect to the server. |
| 158 | # password The password to be used to connect to the server. |
George Keishing | 4c39401 | 2019-02-01 06:03:02 -0600 | [diff] [blame] | 159 | |
George Keishing | 5e6515e | 2019-03-12 14:22:33 -0500 | [diff] [blame] | 160 | # The redfish object may preserve a valid username or password from the |
| 161 | # last failed login attempt. If we then try to login with a null username |
| 162 | # or password value, the redfish object may prefer the preserved value. |
| 163 | # Since we're testing bad path, we wish to avoid this scenario so we will |
| 164 | # clear these values. |
| 165 | |
| 166 | Redfish.Set Username ${EMPTY} |
| 167 | Redfish.Set Password ${EMPTY} |
| 168 | |
George Keishing | 3261604 | 2022-09-22 05:25:39 -0500 | [diff] [blame] | 169 | ${msg}= Run Keyword And Expect Error * Redfish.Login ${username} ${password} |
| 170 | |
| 171 | # redfish package version <=3.1.6 default response is InvalidCredentialsError. |
| 172 | Should Contain Any ${msg} InvalidCredentialsError ${expected_response} |
George Keishing | 374e684 | 2019-02-20 08:57:18 -0600 | [diff] [blame] | 173 | |
| 174 | |
| 175 | Create New Login Session |
| 176 | [Documentation] Multiple login session keys. |
| 177 | |
George Keishing | 97c9394 | 2019-03-04 12:45:07 -0600 | [diff] [blame] | 178 | Redfish.Login |
George Keishing | 374e684 | 2019-02-20 08:57:18 -0600 | [diff] [blame] | 179 | ${session_info}= Get Redfish Session Info |
| 180 | |
| 181 | # Append the session location to the list. |
| 182 | # ['/redfish/v1/SessionService/Sessions/uDzihgDecs', |
| 183 | # '/redfish/v1/SessionService/Sessions/PaHF5brPPd'] |
| 184 | Append To List ${session_list} ${session_info["location"]} |
| 185 | |
| 186 | |
| 187 | Multiple Session Cleanup |
| 188 | [Documentation] Do the teardown for multiple sessions. |
| 189 | |
| 190 | FFDC On Test Case Fail |
| 191 | |
Sushil Singh | 5062114 | 2020-06-16 11:12:21 -0500 | [diff] [blame] | 192 | FOR ${item} IN @{session_list} |
| 193 | Redfish.Delete ${item} |
| 194 | END |