1*** Settings ***
2
3Documentation   Test OpenBMC GUI "SNMP Alerts" sub-menu of "Settings".
4
5Resource        ../../lib/gui_resource.robot
6Resource        ../../lib/snmp/resource.robot
7Resource        ../../lib/snmp/redfish_snmp_utils.robot
8
9Suite Setup     Suite Setup Execution
10Suite Teardown  Close Browser
11
12
13*** Variables ***
14
15${xpath_snmp_alerts_sub_menu}                     //*[@data-test-id='nav-item-snmp-alerts']
16${xpath_snmp_alerts_heading}                      //h1[text()="SNMP Alerts"]
17${xpath_select_all_snmp}                          //*[@data-test-id='snmpAlerts-checkbox-selectAll']
18${xpath_add_destination}                          //button[contains(text(),'Add destination')]
19${xpath_snmp_alert_destination_heading}           //h5[contains(text(),'Add SNMP alert destination')]
20${xpath_ip_address_input_button}                  //*[@data-test-id='snmpAlerts-input-ipAddress']
21${xpath_port_optional_input_button}               //*[@data-test-id='snmpAlerts-input-port']
22${xpath_snmp_add_destination_button}              //*[@data-test-id='snmpAlerts-button-ok']
23${xpath_cancel_button}                            //button[contains(text(),'Cancel')]
24${xpath_delete_button}                            //*[@data-test-id='snmpAlerts-button-deleteRow-undefined']
25${xpath_delete_destination}                       //button[contains(text(),'Delete destination')]
26
27
28*** Test Cases ***
29
30Verify Navigation To SNMP Alerts Page
31    [Documentation]  Verify navigation to SNMP alerts page.
32    [Tags]  Verify_Navigation_To_SNMP_Alerts_Page
33
34    Page Should Contain Element  ${xpath_snmp_alerts_heading}
35
36
37Verify Existence Of All Input Boxes In SNMP Alerts Page
38    [Documentation]  Verify existence of all sections in SNMP alerts page.
39    [Tags]  Verify_Existence_Of_All_Input_Boxes_In_SNMP_Alerts_Page
40
41    Page Should Contain Checkbox  ${xpath_select_all_snmp}
42
43
44Verify Existence Of All Buttons In SNMP Alerts Page
45    [Documentation]  Verify existence of all buttons in SNMP alerts page.
46    [Tags]  Verify_Existence_Of_All_Buttons_In_SNMP_Alerts_Page
47
48    Page should Contain Button  ${xpath_add_destination}
49
50
51Verify Existence Of All Fields In Add Destination
52    [Documentation]  Verify existence of all buttons and fields in add destination page.
53    [Tags]  Verify_Existence_Of_All_Button_And_Fields_In_Add_Destination
54    [Teardown]  Run Keywords  Click Button  ${xpath_cancel_button}  AND
55    ...  Wait Until Keyword Succeeds  10 sec  5 sec
56    ...  Refresh GUI And Verify Element Value  ${xpath_snmp_alerts_heading}  SNMP Alerts
57
58    Click Element  ${xpath_add_destination}
59    Wait Until Page Contains Element  ${xpath_snmp_alert_destination_heading}
60    Page Should Contain Element  ${xpath_ip_address_input_button}
61    Page Should Contain Element  ${xpath_port_optional_input_button}
62    Page Should Contain Element  ${xpath_cancel_button}
63    Page Should Contain Element  ${xpath_snmp_add_destination_button}
64
65
66Configure SNMP Settings On BMC With NON Default Port Via GUI And Verify
67    [Documentation]  Configure SNMP settings on BMC with non default port via GUI and verify.
68    [Tags]  Configure_SNMP_Settings_On_BMC_With_Non_Default_Port_Via_GUI_And_Verify
69    [Teardown]  Delete SNMP Manager Via GUI
70
71    Configure SNMP Manager Via GUI  ${SNMP_MGR1_IP}  ${NON_DEFAULT_PORT1}
72
73    Wait Until Page Contains  ${SNMP_MGR1_IP}  timeout=30s
74
75    Verify SNMP Manager Configured On BMC  ${SNMP_MGR1_IP}  ${NON_DEFAULT_PORT1}
76
77
78Configure SNMP Settings On BMC Via GUI And Verify
79    [Documentation]  Configure SNMP settings on BMC via GUI and verify.
80    [Tags]  Configure_SNMP_Settings_On_BMC_Via_GUI_And_Verify
81    [Teardown]  Delete SNMP Manager Via GUI
82
83    Configure SNMP Manager Via GUI  ${SNMP_MGR1_IP}  ${SNMP_DEFAULT_PORT}
84
85    Wait Until Page Contains  ${SNMP_MGR1_IP}  timeout=30s
86
87    Verify SNMP Manager Configured On BMC  ${SNMP_MGR1_IP}  ${SNMP_DEFAULT_PORT}
88
89
90*** Keywords ***
91
92Suite Setup Execution
93    [Documentation]  Do test case setup tasks.
94
95    Launch Browser And Login GUI
96
97    Click Element  ${xpath_settings_menu}
98    Click Element  ${xpath_snmp_alerts_sub_menu}
99    Wait Until Keyword Succeeds  30 sec  10 sec  Location Should Contain  snmp-alerts
100
101
102Configure SNMP Manager Via GUI
103    [Documentation]  Configure SNMP manager via GUI.
104    [Arguments]  ${snmp_ip}  ${port}
105
106    # Description of argument(s):
107    # snmp_ip  SNMP manager IP address.
108    # port     SNMP manager port.
109
110    Click Element  ${xpath_add_destination}
111    Wait Until Page Contains Element  ${xpath_snmp_alert_destination_heading}
112    Input Text  ${xpath_ip_address_input_button}  ${snmp_ip}
113    Wait Until Keyword Succeeds  30 sec  5 sec  Get Value  ${xpath_ip_address_input_button}
114    Input Text  ${xpath_port_optional_input_button}  ${port}
115    Click Element  ${xpath_snmp_add_destination_button}
116
117
118Delete SNMP Manager Via GUI
119    [Documentation]  Delete SNMP manager via GUI.
120
121    Click Element At Coordinates  ${xpath_select_all_snmp}  0  0
122    Wait Until Keyword Succeeds  30 sec  5 sec  Click Element  ${xpath_delete_button}
123    Wait Until Page Contains  Delete SNMP alert destination
124    Click Element  ${xpath_delete_destination}
125    Wait Until Keyword Succeeds  30 sec  10 sec  Refresh GUI And Verify Element Value
126    ...  ${xpath_snmp_alerts_heading}  SNMP Alerts
127