blob: cc39ea6208346874926c0900691676cceb34a616 [file] [log] [blame]
Prashanth Kattiabbce3d2021-06-29 04:56:37 -05001*** Settings ***
2Documentation Test BMC manager protocol enable/disable functionality.
3
4Resource ../../lib/resource.robot
5Resource ../../lib/bmc_redfish_resource.robot
6Resource ../../lib/openbmc_ffdc.robot
7
Prashanth Katti2e413452021-07-13 02:26:45 -05008Suite Setup Redfish.Login
9Suite Teardown Redfish.Logout
10Test Teardown FFDC On Test Case Fail
Prashanth Kattiabbce3d2021-06-29 04:56:37 -050011
12
13*** Test Cases ***
14
Prashanth Katti2e413452021-07-13 02:26:45 -050015Verify SSH Is Enabled By Default
16 [Documentation] Verify SSH is enabled by default.
17 [Tags] Verify_SSH_Is_Enabled_By_Default
18
19 # Check if SSH is enabled by default.
20 Verify SSH Protocol State ${True}
21
22
Prashanth Kattiabbce3d2021-06-29 04:56:37 -050023Enable SSH Protocol And Verify
24 [Documentation] Enable SSH protocol and verify.
25 [Tags] Enable_SSH_Protocol_And_Verify
26
27 Enable SSH Protocol ${True}
28
29 # Check if SSH is really enabled via Redfish.
30 Verify SSH Protocol State ${True}
31
32 # Check if SSH login and commands on SSH session work.
33 Verify SSH Login And Commands Work
34
35
36Disable SSH Protocol And Verify
37 [Documentation] Disable SSH protocol and verify.
38 [Teardown] Enable SSH Protocol ${True}
39
40 # Disable SSH interface.
41 Enable SSH Protocol ${False}
42
43 # Check if SSH is really disabled via Redfish.
44 Verify SSH Protocol State ${False}
45
46 # Check if SSH login and commands fail.
47 ${status}= Run Keyword And Return Status
48 ... Verify SSH Login And Commands Work
49
50 Should Be Equal As Strings ${status} False
51 ... msg=SSH Login and commands are working after disabling SSH.
52
53
54Enable SSH Protocol And Check Persistency On BMC Reboot
55 [Documentation] Enable SSH protocol and verify persistency.
56
57 Enable SSH Protocol ${True}
58
59 # Reboot BMC and verify persistency.
60 OBMC Reboot (off)
61
62 # Check if SSH is really enabled via Redfish.
63 Verify SSH Protocol State ${True}
64
65 # Check if SSH login and commands on SSH session work.
66 Verify SSH Login And Commands Work
67
68
69Disable SSH Protocol And Check Persistency On BMC Reboot
70 [Documentation] Disable SSH protocol and verify persistency.
71 [Teardown] Enable SSH Protocol ${True}
72
73 # Disable SSH interface.
74 Enable SSH Protocol ${False}
75
76 # Reboot BMC and verify persistency.
77 OBMC Reboot (off)
78
79 # Check if SSH is really disabled via Redfish.
80 Verify SSH Protocol State ${False}
81
82 # Check if SSH login and commands fail.
83 ${status}= Run Keyword And Return Status
84 ... Verify SSH Login And Commands Work
85
86 Should Be Equal As Strings ${status} False
87 ... msg=SSH Login and commands are working after disabling SSH.
88
89
Prashanth Katti2e413452021-07-13 02:26:45 -050090Verify Disabling SSH Port Does Not Disable Serial Console Port
91 [Documentation] Verify disabling SSH does not disable serial console port.
92 [Tags] Verify_Disabling_SSH_Port_Does_Not_Disable_Serial_Console_Port
93 [Teardown] Enable SSH Protocol ${True}
94
95 # Disable SSH interface.
96 Enable SSH Protocol ${False}
97
98 # Check able to establish connection with serial port console.
99 Open Connection And Log In host=${OPENBMC_HOST} port=2200
100 Close All Connections
101
102
103Verify Existing SSH Session Gets Closed On Disabling SSH
104 [Documentation] Verify existing SSH session gets closed on disabling ssh.
105 [Tags] Verify_Existing_SSH_Session_Gets_Closed_On_Disabling_SSH
106 [Teardown] Enable SSH Protocol ${True}
107
108 # Open SSH connection.
109 Open Connection And Login
110
111 # Disable SSH interface.
112 Enable SSH Protocol ${False}
113
114 # Check if SSH is really disabled via Redfish.
115 Verify SSH Protocol State ${False}
116
117 # Try to execute CLI command on SSH connection.
118 # It should fail as disable SSH will close pre existing sessions.
119 ${status}= Run Keyword And Return Status
120 ... BMC Execute Command /sbin/ip addr
121
122 Should Be Equal As Strings ${status} False
123 ... msg=Disabling SSH has not closed existing SSH sessions.
124
125
Prashanth Kattiabbce3d2021-06-29 04:56:37 -0500126*** Keywords ***
127
128Enable SSH Protocol
129 [Documentation] Enable or disable SSH protocol.
130 [Arguments] ${enable_value}=${True}
131
132 # Description of argument(s}:
133 # enable_value Enable or disable SSH, e.g. (true, false).
134
135 ${ssh_state}= Create Dictionary ProtocolEnabled=${enable_value}
136 ${data}= Create Dictionary SSH=${ssh_state}
137
138 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body=&{data}
139 ... valid_status_codes=[${HTTP_NO_CONTENT}]
140
141 # Wait for timeout for new values to take effect.
142 Sleep ${NETWORK_TIMEOUT}s
143
144
145Verify SSH Login And Commands Work
146 [Documentation] Verify if SSH connection works and able to run command on SSH session.
147 [Teardown] Close All Connections
148
149 # Check if we can open SSH connection and login.
150 Open Connection And Login
151
152 # Check if we can run command successfully on SSH session.
153 BMC Execute Command /sbin/ip addr
154
155
156Verify SSH Protocol State
157 [Documentation] verify SSH protocol state.
158 [Arguments] ${state}=${True}
159
160 # Description of argument(s}:
161 # state Enable or disable SSH, e.g. (true, false)
162
163 # Sample output:
164 # {
165 # "@odata.id": "/redfish/v1/Managers/bmc/NetworkProtocol",
166 # "@odata.type": "#ManagerNetworkProtocol.v1_5_0.ManagerNetworkProtocol",
167 # "Description": "Manager Network Service",
168 # "FQDN": "bmc",
169 # "HTTP": {
170 # "Port": 0,
171 # "ProtocolEnabled": false
172 # },
173 # "HTTPS": {
174 # "Certificates": {
175 # "@odata.id": "/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates"
176 # },
177 # "Port": xxx,
178 # "ProtocolEnabled": true
179 # },
180 # "HostName": "xxxxbmc",
181 # "IPMI": {
182 # "Port": xxx,
183 # "ProtocolEnabled": true
184 # },
185 # "Id": "NetworkProtocol",
186 # "NTP": {
187 # "NTPServers": [
188 # "xx.xx.xx.xx",
189 # "xx.xx.xx.xx",
190 # "xx.xx.xx.xx"
191 # ],
192 # "ProtocolEnabled": true
193 # },
194 # "Name": "Manager Network Protocol",
195 # "SSH": {
196 # "Port": xx,
197 # "ProtocolEnabled": true
198 # },
199 # "Status": {
200 # "Health": "OK",
201 # "HealthRollup": "OK",
202 # "State": "Enabled"
203 # }
204 # }
205
206 ${resp}= Redfish.Get ${REDFISH_NW_PROTOCOL_URI}
207 Should Be Equal As Strings ${resp.dict['SSH']['ProtocolEnabled']} ${state}
208 ... msg=Protocol states are not matching.