blob: bb71a1bd51ad73b0c86dd4eb6d206ed071240176 [file] [log] [blame]
Prashanth Kattifa699cf2020-04-06 10:13:33 -05001*** Settings ***
2Documentation Connections and authentication module stability tests.
3
4Resource ../lib/bmc_redfish_resource.robot
5Resource ../lib/bmc_network_utils.robot
6Resource ../lib/openbmc_ffdc.robot
Anvesh Kumar Rayankula85df1372020-04-28 05:01:14 -05007Resource ../lib/resource.robot
8Resource ../lib/utils.robot
9Resource ../lib/connection_client.robot
Prashanth Kattifa699cf2020-04-06 10:13:33 -050010Library ../lib/bmc_network_utils.py
11
Anvesh Kumar Rayankula85df1372020-04-28 05:01:14 -050012Library SSHLibrary
Prashanth Kattifa699cf2020-04-06 10:13:33 -050013Library Collections
Prashanth Kattiee26d5e2021-05-21 00:38:31 -050014Library XvfbRobot
15Library OperatingSystem
16Library Selenium2Library 120 120
17Library Telnet 30 Seconds
18Library Screenshot
19
shrsuman123a8ca2962022-01-07 03:30:08 -060020
21Suite Setup Redfish.Logout
22
Prashanth Kattiee26d5e2021-05-21 00:38:31 -050023Variables ../gui/data/gui_variables.py
Prashanth Kattifa699cf2020-04-06 10:13:33 -050024
25*** Variables ***
26
Anvesh Kumar Rayankula85df1372020-04-28 05:01:14 -050027${iterations} 10000
Anvesh Kumar Rayankula3cddd032020-03-26 04:16:13 -050028${loop_iteration} ${1000}
Anvesh Kumar Rayankula85df1372020-04-28 05:01:14 -050029${hostname} test_hostname
30${MAX_UNAUTH_PER_IP} ${5}
Prashanth Kattiee26d5e2021-05-21 00:38:31 -050031${bmc_url} https://${OPENBMC_HOST}
32
Prashanth Kattifa699cf2020-04-06 10:13:33 -050033
34*** Test Cases ***
35
36Test Patch Without Auth Token Fails
37 [Documentation] Send patch method without auth token and verify it throws an error.
George Keishing966a4c52020-05-13 10:53:58 -050038 [Tags] Test_Patch_Without_Auth_Token_Fails
Prashanth Kattifa699cf2020-04-06 10:13:33 -050039
Anves Kumar rayankula816d3ce2021-06-13 23:55:41 -050040 ${active_channel_config}= Get Active Channel Config
41 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
42
43 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} body={'HostName': '${hostname}'}
Prashanth Kattifa699cf2020-04-06 10:13:33 -050044 ... valid_status_codes=[${HTTP_UNAUTHORIZED}, ${HTTP_FORBIDDEN}]
45
46
47Flood Patch Without Auth Token And Check Stability Of BMC
48 [Documentation] Flood patch method without auth token and check BMC stability.
49 [Tags] Flood_Patch_Without_Auth_Token_And_Check_Stability_Of_BMC
50 @{status_list}= Create List
51
Anves Kumar rayankula816d3ce2021-06-13 23:55:41 -050052 ${active_channel_config}= Get Active Channel Config
53 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
54
Prashanth Kattifa699cf2020-04-06 10:13:33 -050055 FOR ${i} IN RANGE ${1} ${iterations}
56 Log To Console ${i}th iteration
57 Run Keyword And Ignore Error
Anves Kumar rayankula816d3ce2021-06-13 23:55:41 -050058 ... Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} body={'HostName': '${hostname}'}
Prashanth Kattifa699cf2020-04-06 10:13:33 -050059
60 # Every 100th iteration, check BMC allows patch with auth token.
61 ${status}= Run Keyword If ${i} % 100 == 0 Run Keyword And Return Status
62 ... Login And Configure Hostname
63 Run Keyword If ${status} == False Append To List ${status_list} ${status}
64 END
65 ${verify_count}= Evaluate ${iterations}/100
66 ${fail_count}= Get Length ${status_list}
67
Anvesh Kumar Rayankula3cddd032020-03-26 04:16:13 -050068 Should Be Equal ${fail_count} 0
69 ... msg=Patch operation failed ${fail_count} times in ${verify_count} attempts
Prashanth Kattifa699cf2020-04-06 10:13:33 -050070
71
George Keishing4fb89c12022-01-06 22:29:33 -060072Verify User Cannot Login After 5 Non-Logged In Sessions
Anvesh Kumar Rayankula85df1372020-04-28 05:01:14 -050073 [Documentation] User should not be able to login when there
74 ... are 5 non-logged in sessions.
75 [Tags] Verify_User_Cannot_Login_After_5_Non-Logged_In_Sessions
76
77 FOR ${i} IN RANGE ${0} ${MAX_UNAUTH_PER_IP}
78 SSHLibrary.Open Connection ${OPENBMC_HOST}
79 Start Process ssh ${OPENBMC_USERNAME}@${OPENBMC_HOST} shell=True
80 END
81
82 SSHLibrary.Open Connection ${OPENBMC_HOST}
83 ${status}= Run Keyword And Return Status SSHLibrary.Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
Prashanth Katti91e59712020-04-14 08:12:09 -050084
Anvesh Kumar Rayankula85df1372020-04-28 05:01:14 -050085 Should Be Equal ${status} ${False}
86
87
Prashanth Katti91e59712020-04-14 08:12:09 -050088Test Post Without Auth Token Fails
89 [Documentation] Send post method without auth token and verify it throws an error.
90 [Tags] Test_Post_Without_Auth_Token_Fails
91
Anvesh Kumar Rayankula3cddd032020-03-26 04:16:13 -050092 ${user_info}= Create Dictionary
93 ... UserName=test_user Password=TestPwd123 RoleId=Operator Enabled=${True}
Prashanth Katti91e59712020-04-14 08:12:09 -050094 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{user_info}
95 ... valid_status_codes=[${HTTP_UNAUTHORIZED}, ${HTTP_FORBIDDEN}]
96
97
98Flood Post Without Auth Token And Check Stability Of BMC
99 [Documentation] Flood post method without auth token and check BMC stability.
100 [Tags] Flood_Post_Without_Auth_Token_And_Check_Stability_Of_BMC
101
102 @{status_list}= Create List
Anvesh Kumar Rayankula3cddd032020-03-26 04:16:13 -0500103 ${user_info}= Create Dictionary
104 ... UserName=test_user Password=TestPwd123 RoleId=Operator Enabled=${True}
Prashanth Katti91e59712020-04-14 08:12:09 -0500105
106 FOR ${i} IN RANGE ${1} ${iterations}
107 Log To Console ${i}th iteration
108 Run Keyword And Ignore Error
109 ... Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{user_info}
110
111 # Every 100th iteration, check BMC allows post with auth token.
112 ${status}= Run Keyword If ${i} % 100 == 0 Run Keyword And Return Status
113 ... Login And Create User
114 Run Keyword If ${status} == False Append To List ${status_list} ${status}
115 END
116 ${verify_count}= Evaluate ${iterations}/100
117 ${fail_count}= Get Length ${status_list}
118
Anvesh Kumar Rayankula3cddd032020-03-26 04:16:13 -0500119 Should Be Equal ${fail_count} 0
120 ... msg=Post operation failed ${fail_count} times in ${verify_count} attempts
121
122
123Make Large Number Of Wrong SSH Login Attempts And Check Stability
124 [Documentation] Check BMC stability with large number of SSH wrong login requests.
125 [Tags] Make_Large_Number_Of_Wrong_SSH_Login_Attempts_And_Check_Stability
126 [Setup] Set Account Lockout Threshold
127 [Teardown] FFDC On Test Case Fail
128
129 SSHLibrary.Open Connection ${OPENBMC_HOST}
130 @{ssh_status_list}= Create List
131 FOR ${i} IN RANGE ${loop_iteration}
132 Log To Console ${i}th iteration
133 ${invalid_password}= Catenate ${OPENBMC_PASSWORD}${i}
134 Run Keyword and Ignore Error
135 ... Open Connection And Log In ${OPENBMC_USERNAME} ${invalid_password}
136
137 # Every 100th iteration Login with correct credentials
138 ${status}= Run keyword If ${i} % ${100} == ${0} Run Keyword And Return Status
139 ... Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
140 Run Keyword If ${status} == ${False} Append To List ${ssh_status_list} ${status}
141 SSHLibrary.Close Connection
142 END
143
144 ${valid_login_count}= Evaluate ${iterations}/100
145 ${fail_count}= Get Length ${ssh_status_list}
146 Should Be Equal ${fail_count} ${0}
147 ... msg= Login Failed ${fail_count} times in ${valid_login_count} attempts.
Prashanth Katti91e59712020-04-14 08:12:09 -0500148
149
Prashanth Kattiee26d5e2021-05-21 00:38:31 -0500150Test Stability On Large Number Of Wrong Login Attempts To GUI
151 [Documentation] Test stability on large number of wrong login attempts to GUI.
152 [Tags] Test_Stability_On_Large_Number_Of_Wrong_Login_Attempts_To_GUI
153
154 @{status_list}= Create List
155
156 # Open headless browser.
157 Start Virtual Display
158 ${browser_ID}= Open Browser ${bmc_url} alias=browser1
159 Set Window Size 1920 1080
160
161 Go To ${bmc_url}
162
163 FOR ${i} IN RANGE ${1} ${iterations}
164 Log To Console ${i}th login
165 Run Keyword And Ignore Error Login to GUI With Wrong Credentials
166
167 # Every 100th iteration, check BMC GUI is responsive.
168 ${status}= Run Keyword If ${i} % 100 == 0 Run Keyword And Return Status
169 ... Open Browser ${bmc_url}
170 Append To List ${status_list} ${status}
171 Run Keyword If '${status}' == 'True' Run Keywords Close Browser AND Switch Browser browser1
172 END
173
174 ${fail_count}= Count Values In List ${status_list} False
175 Run Keyword If ${fail_count} > ${0} FAIL Could not open BMC GUI ${fail_count} times
176
177
Prashanth Kattifa699cf2020-04-06 10:13:33 -0500178*** Keywords ***
179
180Login And Configure Hostname
181 [Documentation] Login and configure hostname
182
183 [Teardown] Redfish.Logout
184
185 Redfish.Login
186
187 Redfish.patch ${REDFISH_NW_PROTOCOL_URI} body={'HostName': '${hostname}'}
188 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
189
Prashanth Katti91e59712020-04-14 08:12:09 -0500190
191Login And Create User
192 [Documentation] Login and create user
193
194 [Teardown] Redfish.Logout
195
196 Redfish.Login
197
Anvesh Kumar Rayankula3cddd032020-03-26 04:16:13 -0500198 ${user_info}= Create Dictionary
199 ... UserName=test_user Password=TestPwd123 RoleId=Operator Enabled=${True}
200 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{user_info}
201 ... valid_status_codes=[${HTTP_OK}]
202
203
204Set Account Lockout Threshold
205 [Documentation] Set user account lockout threshold.
206
207 [Teardown] Redfish.Logout
208
209 Redfish.Login
210 Redfish.Patch /redfish/v1/AccountService body=[('AccountLockoutThreshold', 0)]
Prashanth Kattiee26d5e2021-05-21 00:38:31 -0500211
212
213Login to GUI With Incorrect Credentials
214 [Documentation] Login to GUI With Wrong Credentials.
215
216 Input Text ${xpath_textbox_username} root
217 Input Password ${xpath_textbox_password} incorrect_password
218 Click Button ${xpath_login_button}