blob: 4bcec85fb51d15a0de5a3cb8d3e4971cc5aeb071 [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
8Suite Setup Redfish.Login
9Test Teardown FFDC On Test Case Fail
10
11
12*** Test Cases ***
13
14Enable SSH Protocol And Verify
15 [Documentation] Enable SSH protocol and verify.
16 [Tags] Enable_SSH_Protocol_And_Verify
17
18 Enable SSH Protocol ${True}
19
20 # Check if SSH is really enabled via Redfish.
21 Verify SSH Protocol State ${True}
22
23 # Check if SSH login and commands on SSH session work.
24 Verify SSH Login And Commands Work
25
26
27Disable SSH Protocol And Verify
28 [Documentation] Disable SSH protocol and verify.
29 [Teardown] Enable SSH Protocol ${True}
30
31 # Disable SSH interface.
32 Enable SSH Protocol ${False}
33
34 # Check if SSH is really disabled via Redfish.
35 Verify SSH Protocol State ${False}
36
37 # Check if SSH login and commands fail.
38 ${status}= Run Keyword And Return Status
39 ... Verify SSH Login And Commands Work
40
41 Should Be Equal As Strings ${status} False
42 ... msg=SSH Login and commands are working after disabling SSH.
43
44
45Enable SSH Protocol And Check Persistency On BMC Reboot
46 [Documentation] Enable SSH protocol and verify persistency.
47
48 Enable SSH Protocol ${True}
49
50 # Reboot BMC and verify persistency.
51 OBMC Reboot (off)
52
53 # Check if SSH is really enabled via Redfish.
54 Verify SSH Protocol State ${True}
55
56 # Check if SSH login and commands on SSH session work.
57 Verify SSH Login And Commands Work
58
59
60Disable SSH Protocol And Check Persistency On BMC Reboot
61 [Documentation] Disable SSH protocol and verify persistency.
62 [Teardown] Enable SSH Protocol ${True}
63
64 # Disable SSH interface.
65 Enable SSH Protocol ${False}
66
67 # Reboot BMC and verify persistency.
68 OBMC Reboot (off)
69
70 # Check if SSH is really disabled via Redfish.
71 Verify SSH Protocol State ${False}
72
73 # Check if SSH login and commands fail.
74 ${status}= Run Keyword And Return Status
75 ... Verify SSH Login And Commands Work
76
77 Should Be Equal As Strings ${status} False
78 ... msg=SSH Login and commands are working after disabling SSH.
79
80
81*** Keywords ***
82
83Enable SSH Protocol
84 [Documentation] Enable or disable SSH protocol.
85 [Arguments] ${enable_value}=${True}
86
87 # Description of argument(s}:
88 # enable_value Enable or disable SSH, e.g. (true, false).
89
90 ${ssh_state}= Create Dictionary ProtocolEnabled=${enable_value}
91 ${data}= Create Dictionary SSH=${ssh_state}
92
93 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body=&{data}
94 ... valid_status_codes=[${HTTP_NO_CONTENT}]
95
96 # Wait for timeout for new values to take effect.
97 Sleep ${NETWORK_TIMEOUT}s
98
99
100Verify SSH Login And Commands Work
101 [Documentation] Verify if SSH connection works and able to run command on SSH session.
102 [Teardown] Close All Connections
103
104 # Check if we can open SSH connection and login.
105 Open Connection And Login
106
107 # Check if we can run command successfully on SSH session.
108 BMC Execute Command /sbin/ip addr
109
110
111Verify SSH Protocol State
112 [Documentation] verify SSH protocol state.
113 [Arguments] ${state}=${True}
114
115 # Description of argument(s}:
116 # state Enable or disable SSH, e.g. (true, false)
117
118 # Sample output:
119 # {
120 # "@odata.id": "/redfish/v1/Managers/bmc/NetworkProtocol",
121 # "@odata.type": "#ManagerNetworkProtocol.v1_5_0.ManagerNetworkProtocol",
122 # "Description": "Manager Network Service",
123 # "FQDN": "bmc",
124 # "HTTP": {
125 # "Port": 0,
126 # "ProtocolEnabled": false
127 # },
128 # "HTTPS": {
129 # "Certificates": {
130 # "@odata.id": "/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates"
131 # },
132 # "Port": xxx,
133 # "ProtocolEnabled": true
134 # },
135 # "HostName": "xxxxbmc",
136 # "IPMI": {
137 # "Port": xxx,
138 # "ProtocolEnabled": true
139 # },
140 # "Id": "NetworkProtocol",
141 # "NTP": {
142 # "NTPServers": [
143 # "xx.xx.xx.xx",
144 # "xx.xx.xx.xx",
145 # "xx.xx.xx.xx"
146 # ],
147 # "ProtocolEnabled": true
148 # },
149 # "Name": "Manager Network Protocol",
150 # "SSH": {
151 # "Port": xx,
152 # "ProtocolEnabled": true
153 # },
154 # "Status": {
155 # "Health": "OK",
156 # "HealthRollup": "OK",
157 # "State": "Enabled"
158 # }
159 # }
160
161 ${resp}= Redfish.Get ${REDFISH_NW_PROTOCOL_URI}
162 Should Be Equal As Strings ${resp.dict['SSH']['ProtocolEnabled']} ${state}
163 ... msg=Protocol states are not matching.