1*** Settings ***
2
3Documentation    Test OpenBMC GUI "Policies" sub-menu of "Security and Access" menu.
4
5Resource         ../../lib/gui_resource.robot
6Resource         ../lib/ipmi_client.robot
7Resource         ../lib/protocol_setting_utils.robot
8Resource         ../lib/common_utils.robot
9Suite Setup      Run Keywords  Launch Browser And Login GUI  AND  Redfish.Login
10Suite Teardown   Close Browser
11Test Setup       Test Setup Execution
12
13
14*** Variables ***
15${xpath_policies_heading}                     //h1[text()="Policies"]
16${xpath_bmc_ssh_toggle}                       //*[@data-test-id='policies-toggle-bmcShell']
17...  /following-sibling::label
18${xpath_network_ipmi_toggle}                  //*[@data-test-id='polices-toggle-networkIpmi']
19...  /following-sibling::label
20${xpath_host_tpm_toggle}                      //input[@id='host-tpm-policy']
21${xpath_virtual_tpm_toggle}                   //*[@data-test-id='policies-toggle-vtpm']
22${xpath_rtad_toggle}                          //*[@data-test-id='policies-toggle-rtad']
23${xpath_usb_firmware_update_policy_toggle}    //*[@data-test-id='policies-toggle-usbFirmwareUpdatePolicy']
24${xpath_secure_version_lockin_toggle}         //*[@data-test-id='policies-toggle-svle']
25${xpath_host_usb_enablement_toggle}           //*[@data-test-id='policies-toggle-hostUsb']
26
27*** Test Cases ***
28
29Verify Navigation To Policies Page
30    [Documentation]  Verify navigation to policies page.
31    [Tags]  Verify_Navigation_To_Policies_Page
32
33    Page Should Contain Element  ${xpath_policies_heading}
34
35
36Verify Existence Of All Sections In Policies Page
37    [Documentation]  Verify existence of all sections in policies page.
38    [Tags]  Verify_Existence_Of_All_Sections_In_Policies_Page
39
40    Page Should Contain  BMC shell (via SSH)
41    Page Should Contain  Network IPMI (out-of-band IPMI)
42    Page Should Contain  Host TPM
43    Page Should Contain  VirtualTPM
44    Page Should Contain  RTAD
45    Page Should Contain  USB firmware update policy
46    Page Should Contain  Secure version lock-in
47    Page Should Contain  Host USB enablement
48
49
50Verify Existence Of All Buttons In Policies Page
51    [Documentation]  Verify existence of All Buttons in policies page.
52    [Tags]  Verify_Existence_Of_All_Buttons_In_Policies_Page
53
54    Page Should Contain Element  ${xpath_bmc_ssh_toggle}
55    Page Should Contain Element  ${xpath_network_ipmi_toggle}
56    Page Should Contain Element  ${xpath_host_tpm_toggle}
57    Page Should Contain Element  ${xpath_virtual_tpm_toggle}
58    Page Should Contain Element  ${xpath_rtad_toggle}
59    Page Should Contain Element  ${xpath_usb_firmware_update_policy_toggle}
60    Page Should Contain Element  ${xpath_secure_version_lockin_toggle}
61    Page Should Contain Element  ${xpath_host_usb_enablement_toggle}
62
63
64Enable SSH Via GUI And Verify
65    [Documentation]  Login to GUI Policies page,enable SSH toggle and
66    ...  verify that SSH to BMC starts working after enabling SSH.
67    [Tags]  Enable_SSH_Via_GUI_And_Verify
68
69    Set Policy Via GUI  SSH  Enabled
70    Wait Until Keyword Succeeds  ${NETWORK_TIMEOUT}  ${NETWORK_RETRY_TIME}  Open Connection And Login
71
72
73Disable SSH Via GUI And Verify
74    [Documentation]  Login to GUI Policies page,disable SSH and
75    ...  verify that SSH to BMC stops working after disabling SSH.
76    [Tags]  Disable_SSH_Via_GUI_And_Verify
77    [Teardown]  Run Keywords  Enable SSH Protocol  ${True}  AND
78    ...  Wait Until Keyword Succeeds  30 sec  15 sec  Open Connection And Login
79
80    Set Policy Via GUI  SSH  Disabled
81
82    ${status}=  Run Keyword And Return Status
83    ...  Open Connection And Login
84
85    Should Be Equal As Strings  ${status}  False
86    ...  msg=SSH login still working after disabling SSH.
87
88
89Disable IPMI Via GUI And Verify
90    [Documentation]  Login to GUI Policies page,disable IPMI and
91    ...  verify that IPMI command does not work after disabling IPMI.
92    [Tags]  Disable_IPMI_Via_GUI_And_Verify
93
94    Set Policy Via GUI  IPMI  Disabled
95
96    ${status}=  Run Keyword And Return Status
97    ...  Wait Until Keyword Succeeds  ${NETWORK_TIMEOUT}  ${NETWORK_RETRY_TIME}  Run IPMI Standard Command  sel info
98
99    Should Be Equal As Strings  ${status}  False
100    ...  msg=IPMI command is working after disabling IPMI.
101
102
103Enable IPMI Via GUI And Verify
104    [Documentation]  Login to GUI Policies page,enable IPMI and
105    ...  verify that IPMI command works after enabling IPMI.
106    [Tags]  Enable_IPMI_Via_GUI_And_Verify
107
108    Set Policy Via GUI  IPMI  Enabled
109    Wait Until Keyword Succeeds  ${NETWORK_TIMEOUT}  ${NETWORK_RETRY_TIME}  Run IPMI Standard Command  sel info
110
111
112Enable SSH Via GUI And Verify Persistency On BMC Reboot
113    [Documentation]  Login to GUI Policies page,enable SSH and
114    ...  verify persistency of SSH connection on BMC reboot.
115    [Tags]  Enable_SSH_Via_GUI_And_Verify_Persistency_On_BMC_Reboot
116
117    Set Policy Via GUI  SSH  Enabled
118
119    Reboot BMC via GUI
120
121    Wait Until Keyword Succeeds  5 min  30 sec  Open Connection And Login
122
123
124Enable IPMI Via GUI And Verify Persistency On BMC Reboot
125    [Documentation]  Login to GUI Policies page,enable IPMI and
126    ...  verify persistency of IPMI command work on BMC reboot.
127    [Tags]  Enable_IPMI_Via_GUI_And_Verify_Persistency_On_BMC_Reboot
128
129    Set Policy Via GUI  IPMI  Enabled
130
131    Reboot BMC via GUI
132
133    Wait Until Keyword Succeeds  2 min  30 sec  Run IPMI Standard Command  sel info
134
135
136Disable SSH Via GUI And Verify Persistency On BMC Reboot
137    [Documentation]  Login to GUI Policies page,disable SSH and
138    ...  verify that SSH to BMC stops working after disabling SSH on BMC reboot.
139    [Tags]  Disable_SSH_Via_GUI_And_Verify_Persistency_On_BMC_Reboot
140    [Teardown]  Run Keywords  Wait Until Keyword Succeeds  2 min  15 sec  Enable SSH Protocol  ${True}
141    ...  AND  Wait Until Keyword Succeeds  2 min  15 sec  Open Connection And Login
142
143    Set Policy Via GUI  SSH  Disabled
144
145    Reboot BMC via GUI
146
147    ${status}=  Run Keyword And Return Status
148    ...  Wait Until Keyword Succeeds  ${NETWORK_TIMEOUT}  ${NETWORK_RETRY_TIME}  Open Connection And Login
149
150    Should Be Equal As Strings  ${status}  False
151    ...  msg=SSH login still working after disabling SSH.
152
153
154Disable IPMI Via GUI And Verify Persistency On BMC Reboot
155    [Documentation]  Login to GUI Policies page,disable IPMI and
156    ...  verify persistency of IPMI command does not work on BMC reboot.
157    [Tags]  Disable_IPMI_Via_GUI_And_Verify_Persistency_On_BMC_Reboot
158    [Teardown]  Run Keywords  Wait Until Keyword Succeeds  2 min  15 sec  Enable IPMI Protocol  ${True}
159    ...  AND  Wait Until Keyword Succeeds  2 min  15 sec  Run IPMI Standard Command  sel info
160
161    Set Policy Via GUI  IPMI  Disabled
162
163    Reboot BMC via GUI
164
165    ${status}=  Run Keyword And Return Status
166    ...  Wait Until Keyword Succeeds  ${NETWORK_TIMEOUT}  ${NETWORK_RETRY_TIME}  Run IPMI Standard Command  sel info
167
168    Should Be Equal As Strings  ${status}  False
169    ...  msg=IPMI command is working after disabling IPMI.
170
171
172*** Keywords ***
173
174Test Setup Execution
175    [Documentation]  Do test case setup tasks.
176
177    Click Element  ${xpath_secuity_and_accesss_menu}
178    Click Element  ${xpath_policies_sub_menu}
179    Wait Until Keyword Succeeds  30 sec  15 sec  Location Should Contain  policies
180
181
182Set Policy Via GUI
183
184    [Documentation]  Login to GUI Policies page and set policy.
185    [Arguments]  ${policy}  ${state}
186
187    # Description of argument(s):
188    # policy   policy to be set(e.g. SSH, IPMI).
189    # state    state to be set(e.g. Enable, Disable).
190
191    ${opposite_state_gui}  ${opposite_state_redfish}=  Run Keyword If
192    ...  '${state}' == 'Enabled'  Set Variable  Disabled  ${False}
193    ...  ELSE IF  '${state}' == 'Disabled'  Set Variable  Enabled  ${True}
194
195    # Setting policy to an opposite value via Redfish.
196    Run Keyword If  '${policy}' == 'SSH'
197    ...  Enable SSH Protocol  ${opposite_state_redfish}
198    ...  ELSE IF  '${policy}' == 'IPMI'
199    ...  Enable IPMI Protocol  ${opposite_state_redfish}
200
201    ${policy_toggle_button}=  Run Keyword If  '${policy}' == 'SSH'
202    ...  Set variable  ${xpath_bmc_ssh_toggle}
203    ...  ELSE IF  '${policy}' == 'IPMI'
204    ...  Set variable  ${xpath_network_ipmi_toggle}
205
206    Wait Until Keyword Succeeds  1 min  30 sec
207    ...  Refresh GUI And Verify Element Value  ${policy_toggle_button}  ${opposite_state_gui}
208    Click Element  ${policy_toggle_button}
209
210    # Wait for GUI to reflect policy status.
211    Wait Until Keyword Succeeds  1 min  30 sec
212    ...  Refresh GUI And Verify Element Value  ${policy_toggle_button}  ${state}
213