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      Launch Browser And Login GUI
10Suite Teardown   Close Browser
11Test Setup       Test Setup Execution
12
13
14*** Variables ***
15
16${xpath_policies_heading}       //h1[text()="Policies"]
17${xpath_bmc_ssh_toggle}         //*[@data-test-id='policies-toggle-bmcShell']/following-sibling::label
18${xpath_network_ipmi_toggle}    //*[@data-test-id='polices-toggle-networkIpmi']/following-sibling::label
19
20
21*** Test Cases ***
22
23Verify Navigation To Policies Page
24    [Documentation]  Verify navigation to policies page.
25    [Tags]  Verify_Navigation_To_Policies_Page
26
27    Page Should Contain Element  ${xpath_policies_heading}
28
29
30Verify Existence Of All Sections In Policies Page
31    [Documentation]  Verify existence of all sections in policies page.
32    [Tags]  Verify_Existence_Of_All_Sections_In_Policies_Page
33
34    Page Should Contain  Network services
35    Page Should Contain  BMC shell (via SSH)
36    Page Should Contain  Network IPMI (out-of-band IPMI)
37
38
39Verify Existence Of All Buttons In Policies Page
40    [Documentation]  Verify existence of All Buttons in policies page.
41    [Tags]  Verify_Existence_Of_All_Buttons_In_Policies_Page
42
43    Page Should Contain Element  ${xpath_bmc_ssh_toggle}
44    Page Should Contain Element  ${xpath_network_ipmi_toggle}
45
46
47Enable SSH Via GUI And Verify
48    [Documentation]  Login to GUI Policies page,enable SSH toggle and
49    ...  verify that SSH to BMC starts working after enabling SSH.
50    [Tags]  Enable_SSH_Via_GUI_And_Verify
51
52    Set Policy Via GUI  SSH  Enabled
53    Wait Until Keyword Succeeds  10 sec  5 sec  Open Connection And Login
54
55
56Disable SSH Via GUI And Verify
57    [Documentation]  Login to GUI Policies page,disable SSH and
58    ...  verify that SSH to BMC stops working after disabling SSH.
59    [Tags]  Disable_SSH_Via_GUI_And_Verify
60    [Teardown]  Run Keywords  Enable SSH Protocol  ${True}  AND
61    ...  Wait Until Keyword Succeeds  30 sec  10 sec  Open Connection And Login
62
63    Set Policy Via GUI  SSH  Disabled
64
65    ${status}=  Run Keyword And Return Status
66    ...  Open Connection And Login
67
68    Should Be Equal As Strings  ${status}  False
69    ...  msg=SSH login still working after disabling SSH.
70
71
72Disable IPMI Via GUI And Verify
73    [Documentation]  Login to GUI Policies page,disable IPMI and
74    ...  verify that IPMI command doesnot work after disabling IPMI.
75    [Tags]  Disable_IPMI_Via_GUI_And_Verify
76
77    Set Policy Via GUI  IPMI  Disabled
78
79    ${status}=  Run Keyword And Return Status
80    ...  Wait Until Keyword Succeeds  10 sec  5 sec  Run IPMI Standard Command  sel info
81
82    Should Be Equal As Strings  ${status}  False
83    ...  msg=IPMI command is working after disabling IPMI.
84
85
86Enable IPMI Via GUI And Verify
87    [Documentation]  Login to GUI Policies page,enable IPMI and
88    ...  verify that IPMI command works after enabling IPMI.
89    [Tags]  Enable_IPMI_Via_GUI_And_Verify
90
91    Set Policy Via GUI  IPMI  Enabled
92    Wait Until Keyword Succeeds  10 sec  5 sec  Run IPMI Standard Command  sel info
93
94
95Enable SSH Via GUI And Verify Persistency On BMC Reboot
96    [Documentation]  Login to GUI Policies page,enable SSH and
97    ...  verify persistency of SSH connection on BMC reboot.
98    [Tags]  Enable_SSH_Via_GUI_And_Verify_Persistency_On_BMC_Reboot
99
100    Set Policy Via GUI  SSH  Enabled
101
102    Reboot BMC via GUI
103
104    Wait Until Keyword Succeeds  5 min  30 sec  Open Connection And Login
105
106
107Enable IPMI Via GUI And Verify Persistency On BMC Reboot
108    [Documentation]  Login to GUI Policies page,enable IPMI and
109    ...  verify persistency of IPMI command work on BMC reboot.
110    [Tags]  Enable_IPMI_Via_GUI_And_Verify_Persistency_On_BMC_Reboot
111
112    Set Policy Via GUI  IPMI  Enabled
113
114    Reboot BMC via GUI
115
116    Wait Until Keyword Succeeds  2 min  30 sec  Run IPMI Standard Command  sel info
117
118
119*** Keywords ***
120
121Test Setup Execution
122    [Documentation]  Do test case setup tasks.
123
124    Click Element  ${xpath_secuity_and_accesss_menu}
125    Click Element  ${xpath_policies_sub_menu}
126    Wait Until Keyword Succeeds  30 sec  10 sec  Location Should Contain  policies
127
128
129Set Policy Via GUI
130
131    [Documentation]  Login to GUI Policies page and set policy.
132    [Arguments]  ${policy}  ${state}
133
134    # Description of argument(s):
135    # policy   policy to be set(e.g. SSH, IPMI).
136    # state    state to be set(e.g. Enable, Disable).
137
138    ${opposite_state_gui}  ${opposite_state_redfish}=  Run Keyword If
139    ...  '${state}' == 'Enabled'  Set Variable  Disabled  ${False}
140    ...  ELSE IF  '${state}' == 'Disabled'  Set Variable  Enabled  ${True}
141
142    # Setting policy to an opposite value via Redfish.
143    Run Keyword If  '${policy}' == 'SSH'
144    ...  Enable SSH Protocol  ${opposite_state_redfish}
145    ...  ELSE IF  '${policy}' == 'IPMI'
146    ...  Enable IPMI Protocol  ${opposite_state_redfish}
147
148    ${policy_toggle_button}=  Run Keyword If  '${policy}' == 'SSH'
149    ...  Set variable  ${xpath_bmc_ssh_toggle}
150    ...  ELSE IF  '${policy}' == 'IPMI'
151    ...  Set variable  ${xpath_network_ipmi_toggle}
152
153    Wait Until Keyword Succeeds  1 min  30 sec
154    ...  Refresh GUI And Verify Element Value  ${policy_toggle_button}  ${opposite_state_gui}
155    Click Element  ${policy_toggle_button}
156
157    # Wait for GUI to reflect policy status.
158    Wait Until Keyword Succeeds  1 min  30 sec
159    ...  Refresh GUI And Verify Element Value  ${policy_toggle_button}  ${state}
160