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
7Suite Setup      Launch Browser And Login GUI
8Suite Teardown   Close Browser
9Test Setup       Test Setup Execution
10
11
12*** Variables ***
13
14${xpath_policies_heading}       //h1[text()="Policies"]
15${xpath_bmc_ssh_toggle}         //*[@data-test-id='policies-toggle-bmcShell']/following-sibling::label
16${xpath_network_ipmi_toggle}    //*[@data-test-id='polices-toggle-networkIpmi']/following-sibling::label
17
18
19*** Test Cases ***
20
21Verify Navigation To Policies Page
22    [Documentation]  Verify navigation to policies page.
23    [Tags]  Verify_Navigation_To_Policies_Page
24
25    Page Should Contain Element  ${xpath_policies_heading}
26
27
28Verify Existence Of All Sections In Policies Page
29    [Documentation]  Verify existence of all sections in policies page.
30    [Tags]  Verify_Existence_Of_All_Sections_In_Policies_Page
31
32    Page Should Contain  Network services
33    Page Should Contain  BMC shell (via SSH)
34    Page Should Contain  Network IPMI (out-of-band IPMI)
35
36
37Verify Existence Of All Buttons In Policies Page
38    [Documentation]  Verify existence of All Buttons in policies page.
39    [Tags]  Verify_Existence_Of_All_Buttons_In_Policies_Page
40
41    Page Should Contain Element  ${xpath_bmc_ssh_toggle}
42    Page Should Contain Element  ${xpath_network_ipmi_toggle}
43
44
45Enable SSH Via GUI And Verify
46    [Documentation]  Verify that SSH to BMC starts working after enabling SSH.
47    [Tags]  Enable_SSH_Via_GUI_And_Verify
48    [Teardown]  Run Keywords  Redfish.Patch  /redfish/v1/Managers/bmc/NetworkProtocol
49    ...  body={"SSH":{"ProtocolEnabled":True}}  valid_status_codes=[200, 204]  AND
50    ...  Wait Until Keyword Succeeds  30 sec  5 sec  Open Connection And Login
51
52    # Disable ssh via Redfish.
53    Redfish.Patch  /redfish/v1/Managers/bmc/NetworkProtocol  body={"SSH":{"ProtocolEnabled":False}}
54    ...   valid_status_codes=[200, 204]
55
56    # Wait for GUI to reflect disable SSH status.
57    Wait Until Keyword Succeeds  30 sec  10 sec
58    ...  Refresh GUI And Verify Element Value  ${xpath_bmc_ssh_toggle}  Disabled
59
60    # Enable ssh via GUI.
61    Click Element  ${xpath_bmc_ssh_toggle}
62
63    # Wait for GUI to reflect enable SSH status.
64    Wait Until Keyword Succeeds  30 sec  10 sec
65    ...  Refresh GUI And Verify Element Value  ${xpath_bmc_ssh_toggle}  Enabled
66
67    Wait Until Keyword Succeeds  10 sec  5 sec  Open Connection And Login
68
69
70Disable SSH Via GUI And Verify
71    [Documentation]  Verify that SSH to BMC stops working after disabling SSH.
72    [Tags]  Disable_SSH_Via_GUI_And_Verify
73    [Teardown]  Run Keywords  Redfish.Patch  /redfish/v1/Managers/bmc/NetworkProtocol
74    ...  body={"SSH":{"ProtocolEnabled":True}}  valid_status_codes=[200, 204]  AND
75    ...  Wait Until Keyword Succeeds  30 sec  5 sec  Open Connection And Login
76
77    # Enable ssh via Redfish.
78    Redfish.Patch  /redfish/v1/Managers/bmc/NetworkProtocol  body={"SSH":{"ProtocolEnabled":True}}
79    ...   valid_status_codes=[200, 204]
80
81    # Wait for GUI to reflect enable SSH status.
82    Wait Until Keyword Succeeds  30 sec  10 sec
83    ...  Refresh GUI And Verify Element Value  ${xpath_bmc_ssh_toggle}  Enabled
84
85    # Disable ssh via GUI.
86    Click Element  ${xpath_bmc_ssh_toggle}
87
88    # Wait for GUI to reflect disable SSH status.
89    Wait Until Keyword Succeeds  30 sec  10 sec
90    ...  Refresh GUI And Verify Element Value  ${xpath_bmc_ssh_toggle}  Disabled
91
92    ${status}=  Run Keyword And Return Status
93    ...  Open Connection And Login
94
95    Should Be Equal As Strings  ${status}  False
96    ...  msg=SSH login still working after disabling SSH.
97
98
99Disable IPMI Via GUI And Verify
100    [Documentation]  Verify that IPMI command does not work after disabling IPMI.
101    [Tags]  Disable_IPMI_Via_GUI_And_Verify
102    [Teardown]  Redfish.Patch  /redfish/v1/Managers/bmc/NetworkProtocol
103    ...  body={"IPMI":{"ProtocolEnabled":True}}  valid_status_codes=[200, 204]
104
105    # Due to github issue 2125 we are using click element instead of select checkbox.
106    # https://github.com/openbmc/openbmc-test-automation/issues/2125.
107    # Enable IPMI via Redfish.
108    Redfish.Patch  /redfish/v1/Managers/bmc/NetworkProtocol  body={"IPMI":{"ProtocolEnabled":True}}
109    ...   valid_status_codes=[200, 204]
110
111    # Wait for GUI to reflect enable IPMI status.
112    Wait Until Keyword Succeeds  30 sec  10 sec
113    ...  Refresh GUI And Verify Element Value  ${xpath_network_ipmi_toggle}  Enabled
114
115    # Disable IPMI via GUI.
116    Click Element  ${xpath_network_ipmi_toggle}
117
118    # Wait for GUI to reflect disable IPMI status.
119    Wait Until Keyword Succeeds  30 sec  10 sec
120    ...  Refresh GUI And Verify Element Value  ${xpath_network_ipmi_toggle}  Disabled
121
122    ${status}=  Run Keyword And Return Status
123    ...  Wait Until Keyword Succeeds  10 sec  5 sec  Run IPMI Standard Command  sel info
124
125    Should Be Equal As Strings  ${status}  False
126    ...  msg=IPMI command is working after disabling IPMI.
127
128
129Enable IPMI Via GUI And Verify
130    [Documentation]  Verify that IPMI command works after enabling IPMI.
131    [Tags]  Enable_IPMI_Via_GUI_And_Verify
132    [Teardown]  Redfish.Patch  /redfish/v1/Managers/bmc/NetworkProtocol
133    ...  body={"IPMI":{"ProtocolEnabled":True}}  valid_status_codes=[200, 204]
134
135    # Due to github issue 2125 we are using click element instead of select checkbox.
136    # https://github.com/openbmc/openbmc-test-automation/issues/2125.
137    # Disable ipmi via Redfish.
138    Redfish.Patch  /redfish/v1/Managers/bmc/NetworkProtocol  body={"IPMI":{"ProtocolEnabled":False}}
139    ...   valid_status_codes=[200, 204]
140
141    # Wait for GUI to reflect disable IPMI status.
142    Wait Until Keyword Succeeds  30 sec  10 sec
143    ...  Refresh GUI And Verify Element Value  ${xpath_network_ipmi_toggle}  Disabled
144
145    # Enable ipmi via GUI.
146    Click Element  ${xpath_network_ipmi_toggle}
147
148    # Wait for GUI to reflect enable IPMI status.
149    Wait Until Keyword Succeeds  30 sec  10 sec
150    ...  Refresh GUI And Verify Element Value  ${xpath_network_ipmi_toggle}  Enabled
151
152    Wait Until Keyword Succeeds  10 sec  5 sec  Run IPMI Standard Command  sel info
153
154
155*** Keywords ***
156
157Test Setup Execution
158    [Documentation]  Do test case setup tasks.
159    Click Element  ${xpath_secuity_and_accesss_menu}
160    Click Element  ${xpath_policies_sub_menu}
161    Wait Until Keyword Succeeds  30 sec  10 sec  Location Should Contain  policies
162
163
164