blob: 4c34fc5249b9885f74f0536598938400ffcb090e [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
20Variables ../gui/data/gui_variables.py
Prashanth Kattifa699cf2020-04-06 10:13:33 -050021
22*** Variables ***
23
Anvesh Kumar Rayankula85df1372020-04-28 05:01:14 -050024${iterations} 10000
Anvesh Kumar Rayankula3cddd032020-03-26 04:16:13 -050025${loop_iteration} ${1000}
Anvesh Kumar Rayankula85df1372020-04-28 05:01:14 -050026${hostname} test_hostname
27${MAX_UNAUTH_PER_IP} ${5}
Prashanth Kattiee26d5e2021-05-21 00:38:31 -050028${bmc_url} https://${OPENBMC_HOST}
29
Prashanth Kattifa699cf2020-04-06 10:13:33 -050030
31*** Test Cases ***
32
33Test Patch Without Auth Token Fails
34 [Documentation] Send patch method without auth token and verify it throws an error.
George Keishing966a4c52020-05-13 10:53:58 -050035 [Tags] Test_Patch_Without_Auth_Token_Fails
Prashanth Kattifa699cf2020-04-06 10:13:33 -050036
Anves Kumar rayankula816d3ce2021-06-13 23:55:41 -050037 ${active_channel_config}= Get Active Channel Config
38 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
39
40 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} body={'HostName': '${hostname}'}
Prashanth Kattifa699cf2020-04-06 10:13:33 -050041 ... valid_status_codes=[${HTTP_UNAUTHORIZED}, ${HTTP_FORBIDDEN}]
42
43
44Flood Patch Without Auth Token And Check Stability Of BMC
45 [Documentation] Flood patch method without auth token and check BMC stability.
46 [Tags] Flood_Patch_Without_Auth_Token_And_Check_Stability_Of_BMC
47 @{status_list}= Create List
48
Anves Kumar rayankula816d3ce2021-06-13 23:55:41 -050049 ${active_channel_config}= Get Active Channel Config
50 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
51
Prashanth Kattifa699cf2020-04-06 10:13:33 -050052 FOR ${i} IN RANGE ${1} ${iterations}
53 Log To Console ${i}th iteration
54 Run Keyword And Ignore Error
Anves Kumar rayankula816d3ce2021-06-13 23:55:41 -050055 ... Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} body={'HostName': '${hostname}'}
Prashanth Kattifa699cf2020-04-06 10:13:33 -050056
57 # Every 100th iteration, check BMC allows patch with auth token.
58 ${status}= Run Keyword If ${i} % 100 == 0 Run Keyword And Return Status
59 ... Login And Configure Hostname
60 Run Keyword If ${status} == False Append To List ${status_list} ${status}
61 END
62 ${verify_count}= Evaluate ${iterations}/100
63 ${fail_count}= Get Length ${status_list}
64
Anvesh Kumar Rayankula3cddd032020-03-26 04:16:13 -050065 Should Be Equal ${fail_count} 0
66 ... msg=Patch operation failed ${fail_count} times in ${verify_count} attempts
Prashanth Kattifa699cf2020-04-06 10:13:33 -050067
68
Anvesh Kumar Rayankula85df1372020-04-28 05:01:14 -050069Verify Uer Cannot Login After 5 Non-Logged In Sessions
70 [Documentation] User should not be able to login when there
71 ... are 5 non-logged in sessions.
72 [Tags] Verify_User_Cannot_Login_After_5_Non-Logged_In_Sessions
73
74 FOR ${i} IN RANGE ${0} ${MAX_UNAUTH_PER_IP}
75 SSHLibrary.Open Connection ${OPENBMC_HOST}
76 Start Process ssh ${OPENBMC_USERNAME}@${OPENBMC_HOST} shell=True
77 END
78
79 SSHLibrary.Open Connection ${OPENBMC_HOST}
80 ${status}= Run Keyword And Return Status SSHLibrary.Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
Prashanth Katti91e59712020-04-14 08:12:09 -050081
Anvesh Kumar Rayankula85df1372020-04-28 05:01:14 -050082 Should Be Equal ${status} ${False}
83
84
Prashanth Katti91e59712020-04-14 08:12:09 -050085Test Post Without Auth Token Fails
86 [Documentation] Send post method without auth token and verify it throws an error.
87 [Tags] Test_Post_Without_Auth_Token_Fails
88
Anvesh Kumar Rayankula3cddd032020-03-26 04:16:13 -050089 ${user_info}= Create Dictionary
90 ... UserName=test_user Password=TestPwd123 RoleId=Operator Enabled=${True}
Prashanth Katti91e59712020-04-14 08:12:09 -050091 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{user_info}
92 ... valid_status_codes=[${HTTP_UNAUTHORIZED}, ${HTTP_FORBIDDEN}]
93
94
95Flood Post Without Auth Token And Check Stability Of BMC
96 [Documentation] Flood post method without auth token and check BMC stability.
97 [Tags] Flood_Post_Without_Auth_Token_And_Check_Stability_Of_BMC
98
99 @{status_list}= Create List
Anvesh Kumar Rayankula3cddd032020-03-26 04:16:13 -0500100 ${user_info}= Create Dictionary
101 ... UserName=test_user Password=TestPwd123 RoleId=Operator Enabled=${True}
Prashanth Katti91e59712020-04-14 08:12:09 -0500102
103 FOR ${i} IN RANGE ${1} ${iterations}
104 Log To Console ${i}th iteration
105 Run Keyword And Ignore Error
106 ... Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{user_info}
107
108 # Every 100th iteration, check BMC allows post with auth token.
109 ${status}= Run Keyword If ${i} % 100 == 0 Run Keyword And Return Status
110 ... Login And Create User
111 Run Keyword If ${status} == False Append To List ${status_list} ${status}
112 END
113 ${verify_count}= Evaluate ${iterations}/100
114 ${fail_count}= Get Length ${status_list}
115
Anvesh Kumar Rayankula3cddd032020-03-26 04:16:13 -0500116 Should Be Equal ${fail_count} 0
117 ... msg=Post operation failed ${fail_count} times in ${verify_count} attempts
118
119
120Make Large Number Of Wrong SSH Login Attempts And Check Stability
121 [Documentation] Check BMC stability with large number of SSH wrong login requests.
122 [Tags] Make_Large_Number_Of_Wrong_SSH_Login_Attempts_And_Check_Stability
123 [Setup] Set Account Lockout Threshold
124 [Teardown] FFDC On Test Case Fail
125
126 SSHLibrary.Open Connection ${OPENBMC_HOST}
127 @{ssh_status_list}= Create List
128 FOR ${i} IN RANGE ${loop_iteration}
129 Log To Console ${i}th iteration
130 ${invalid_password}= Catenate ${OPENBMC_PASSWORD}${i}
131 Run Keyword and Ignore Error
132 ... Open Connection And Log In ${OPENBMC_USERNAME} ${invalid_password}
133
134 # Every 100th iteration Login with correct credentials
135 ${status}= Run keyword If ${i} % ${100} == ${0} Run Keyword And Return Status
136 ... Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
137 Run Keyword If ${status} == ${False} Append To List ${ssh_status_list} ${status}
138 SSHLibrary.Close Connection
139 END
140
141 ${valid_login_count}= Evaluate ${iterations}/100
142 ${fail_count}= Get Length ${ssh_status_list}
143 Should Be Equal ${fail_count} ${0}
144 ... msg= Login Failed ${fail_count} times in ${valid_login_count} attempts.
Prashanth Katti91e59712020-04-14 08:12:09 -0500145
146
Prashanth Kattiee26d5e2021-05-21 00:38:31 -0500147Test Stability On Large Number Of Wrong Login Attempts To GUI
148 [Documentation] Test stability on large number of wrong login attempts to GUI.
149 [Tags] Test_Stability_On_Large_Number_Of_Wrong_Login_Attempts_To_GUI
150
151 @{status_list}= Create List
152
153 # Open headless browser.
154 Start Virtual Display
155 ${browser_ID}= Open Browser ${bmc_url} alias=browser1
156 Set Window Size 1920 1080
157
158 Go To ${bmc_url}
159
160 FOR ${i} IN RANGE ${1} ${iterations}
161 Log To Console ${i}th login
162 Run Keyword And Ignore Error Login to GUI With Wrong Credentials
163
164 # Every 100th iteration, check BMC GUI is responsive.
165 ${status}= Run Keyword If ${i} % 100 == 0 Run Keyword And Return Status
166 ... Open Browser ${bmc_url}
167 Append To List ${status_list} ${status}
168 Run Keyword If '${status}' == 'True' Run Keywords Close Browser AND Switch Browser browser1
169 END
170
171 ${fail_count}= Count Values In List ${status_list} False
172 Run Keyword If ${fail_count} > ${0} FAIL Could not open BMC GUI ${fail_count} times
173
174
Prashanth Kattifa699cf2020-04-06 10:13:33 -0500175*** Keywords ***
176
177Login And Configure Hostname
178 [Documentation] Login and configure hostname
179
180 [Teardown] Redfish.Logout
181
182 Redfish.Login
183
184 Redfish.patch ${REDFISH_NW_PROTOCOL_URI} body={'HostName': '${hostname}'}
185 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
186
Prashanth Katti91e59712020-04-14 08:12:09 -0500187
188Login And Create User
189 [Documentation] Login and create user
190
191 [Teardown] Redfish.Logout
192
193 Redfish.Login
194
Anvesh Kumar Rayankula3cddd032020-03-26 04:16:13 -0500195 ${user_info}= Create Dictionary
196 ... UserName=test_user Password=TestPwd123 RoleId=Operator Enabled=${True}
197 Redfish.Post /redfish/v1/AccountService/Accounts/ body=&{user_info}
198 ... valid_status_codes=[${HTTP_OK}]
199
200
201Set Account Lockout Threshold
202 [Documentation] Set user account lockout threshold.
203
204 [Teardown] Redfish.Logout
205
206 Redfish.Login
207 Redfish.Patch /redfish/v1/AccountService body=[('AccountLockoutThreshold', 0)]
Prashanth Kattiee26d5e2021-05-21 00:38:31 -0500208
209
210Login to GUI With Incorrect Credentials
211 [Documentation] Login to GUI With Wrong Credentials.
212
213 Input Text ${xpath_textbox_username} root
214 Input Password ${xpath_textbox_password} incorrect_password
215 Click Button ${xpath_login_button}