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