1*** Settings ***
2
3Documentation   Test OpenBMC GUI "Network" sub-menu of "Settings".
4
5Resource        ../../lib/gui_resource.robot
6Resource        ../../../lib/bmc_network_utils.robot
7
8Suite Setup     Suite Setup Execution
9Suite Teardown  Close Browser
10
11
12*** Variables ***
13
14${xpath_network_heading}                 //h1[text()="Network"]
15${xpath_interface_settings}              //h2[text()="Interface settings"]
16${xpath_network_settings}                //h2[text()="Network settings"]
17${xpath_static_ipv4}                     //h2[text()="IPv4"]
18${xpath_domain_name_toggle}              //*[@data-test-id="networkSettings-switch-useDomainName"]
19${xpath_ntp_servers_toggle}              //*[@data-test-id="networkSettings-switch-useNtp"]
20${xpath_add_static_ipv4_address_button}  //button[contains(text(),"Add static IPv4 address")]
21${xpath_hostname}                        //*[@title="Edit hostname"]
22${xpath_hostname_input}                  //*[@id="hostname"]
23${xpath_input_ip_address}                //*[@id="ipAddress"]
24${xpath_input_gateway}                   //*[@id="gateway"]
25${xpath_input_subnetmask}                //*[@id="subnetMask"]
26${xpath_cancel_button}                   //button[contains(text(),'Cancel')]
27${xpath_delete_dns_server}               //*[@title="Delete DNS address"]
28${xpath_save_button}                     //button[contains(text(),'Save')]
29${xpath_dhcp_toggle_switch}              //*[@id='dhcpSwitch']
30
31${dns_server}                            10.10.10.10
32${test_ipv4_addr}                        10.7.7.7
33${test_ipv4_addr_1}                      10.7.7.8
34${out_of_range_ip}                       10.7.7.256
35${string_ip}                             aa.bb.cc.dd
36${negative_ip}                           10.-7.-7.-7
37${less_octet_ip}                         10.3.36
38${hex_ip}                                0xa.0xb.0xc.0xd
39${spl_char_ip}                           @@@.%%.44.11
40${test_subnet_mask}                      255.255.0.0
41${alpha_netmask}                         ff.ff.ff.ff
42${out_of_range_netmask}                  255.256.255.0
43${more_byte_netmask}                     255.255.255.0.0
44${lowest_netmask}                        128.0.0.0
45${test_hostname}                         openbmc
46
47*** Test Cases ***
48
49Verify Navigation To Network Page
50    [Documentation]  Login to GUI and navigate to the settings sub-menu network page.
51    [Tags]  Verify_Navigation_To_Network_Page
52
53    Page Should Contain Element  ${xpath_network_heading}
54
55
56Verify Existence Of All Sections In Network Page
57    [Documentation]  Login to GUI and navigate to the settings sub-menu network page
58    ...  and confirm the page contains sections that should be accessible.
59    [Tags]  Verify_Existence_Of_All_Sections_In_Network_Page
60
61    Wait Until Page Contains Element  ${xpath_network_settings}  timeout=1min
62    Page Should Contain Element  ${xpath_interface_settings}
63    Page Should Contain Element  ${xpath_static_ipv4}
64    Page Should Contain Element  ${xpath_static_dns}
65
66
67Verify Existence Of All Buttons In Network Page
68    [Documentation]  Login to GUI and navigate to the settings sub-menu network page
69    ...  and confirm the page contains basic features button that should be accessible.
70    [Tags]  Verify_Existence_Of_All_Buttons_In_Network_Page
71
72    Page Should Contain Button  ${xpath_add_static_ipv4_address_button}
73    Page Should Contain Button  ${xpath_add_dns_ip_address_button}
74    Page Should Contain Button  ${xpath_domain_name_toggle}
75    Page Should Contain Button  ${xpath_dns_servers_toggle}
76    Page Should Contain Button  ${xpath_ntp_servers_toggle}
77    Page Should Contain Button  ${xpath_dhcp_toggle_switch}
78
79
80Verify Existence Of All Fields In Hostname
81    [Documentation]  Login to GUI and navigate to the settings sub-menu network page
82    ...  and confirm hostname contains all the fields.
83    [Tags]  Verify_Existence_Of_All_Fields_In_Hostname
84    [Teardown]  Run Keywords  Click Button  ${xpath_cancel_button}  AND
85    ...  Wait Until Keyword Succeeds  10 sec  5 sec
86    ...  Refresh GUI And Verify Element Value  ${xpath_network_heading}  Network
87
88    Click Element  ${xpath_hostname}
89    Wait Until Page Contains  Edit hostname  timeout=1min
90    Page Should Contain Textfield  ${xpath_hostname_input}
91    Page Should Contain Button  ${xpath_cancel_button}
92    Page Should Contain Button  ${xpath_save_button}
93
94
95Verify Existence Of All Fields In Static IP Address
96    [Documentation]  Login to GUI and navigate to the settings sub-menu network page
97    ...  and confirm section static IPv4 contains all the fields.
98    [Tags]  Verify_Existence_Of_All_Fields_In_Static_IP_Address
99    [Teardown]  Run Keywords  Click Button  ${xpath_cancel_button}  AND
100    ...  Wait Until Keyword Succeeds  10 sec  5 sec
101    ...  Refresh GUI And Verify Element Value  ${xpath_network_heading}  Network
102
103    Wait Until Keyword Succeeds  30 sec  10 sec  Click Element  ${xpath_add_static_ipv4_address_button}
104    Wait Until Page Contains  Add static IPv4 address  timeout=15s
105    Page Should Contain Textfield  ${xpath_input_ip_address}
106    Page Should Contain Textfield  ${xpath_input_gateway}
107    Page Should Contain Textfield  ${xpath_input_subnetmask}
108    Page Should Contain Button  ${xpath_cancel_button}
109    Page Should Contain Button  ${xpath_add_button}
110
111
112Verify Existence Of All Fields In Static DNS
113    [Documentation]  Login to GUI and navigate to the settings sub-menu network page
114    ...  and confirm section static DNS contains all the fields.
115    [Tags]  Verify_Existence_Of_All_Fields_In_Static_DNS
116    [Teardown]  Run Keywords  Click Button  ${xpath_cancel_button}  AND
117    ...  Wait Until Keyword Succeeds  10 sec  5 sec
118    ...  Refresh GUI And Verify Element Value  ${xpath_network_heading}  Network
119
120    Wait Until Keyword Succeeds  30 sec  10 sec  Click Element  ${xpath_add_dns_ip_address_button}
121    Wait Until Page Contains  Add IP address  timeout=11s
122    Page Should Contain Textfield  ${xpath_input_static_dns}
123    Page Should Contain Button  ${xpath_cancel_button}
124    Page Should Contain Button  ${xpath_add_button}
125
126
127Configure And Verify DNS Server Via GUI
128    [Documentation]  Login to GUI Network page, add DNS server IP
129    ...  and verify that the page reflects server IP.
130    [Tags]  Configure_And_Verify_DNS_Server_Via_GUI
131    [Teardown]  Delete DNS Servers And Verify
132
133    Add DNS Servers And Verify  ${dns_server}
134
135
136Configure Static IPv4 Netmask Via GUI And Verify
137    [Documentation]  Login to GUI Network page, configure static IPv4 netmask and verify.
138    [Tags]  Configure_Static_IPv4_Netmask_Via_GUI_And_Verify
139    [Setup]  Redfish.Login
140    [Teardown]  Redfish.Logout
141    [Template]  Add Static IP Address And Verify
142
143    # ip_addresses      subnet_masks             gateway          expected_status
144    ${test_ipv4_addr}   ${lowest_netmask}        ${default_gateway}  Success
145    ${test_ipv4_addr}   ${more_byte_netmask}     ${default_gateway}  Invalid format
146    ${test_ipv4_addr}   ${alpha_netmask}         ${default_gateway}  Invalid format
147    ${test_ipv4_addr}   ${out_of_range_netmask}  ${default_gateway}  Invalid format
148    ${test_ipv4_addr}   ${test_subnet_mask}      ${default_gateway}  Success
149
150
151Configure And Verify Static IP Address
152    [Documentation]  Login to GUI Network page, configure static ip address and verify.
153    [Tags]  Configure_And_Verify_Static_IP_Address
154    [Setup]  Redfish.Login
155    [Teardown]  Redfish.Logout
156
157    Add Static IP Address And Verify  ${test_ipv4_addr}  ${test_subnet_mask}  ${default_gateway}  Success
158
159
160Configure And Verify Multiple Static IP Address
161    [Documentation]  Login to GUI Network page, configure multiple static IP address and verify.
162    [Setup]  Redfish.Login
163    [Teardown]  Redfish.Logout
164    [Tags]  Configure_And_Verify_Multiple_Static_IP_Address
165
166    Add Static IP Address And Verify  ${test_ipv4_addr}  ${test_subnet_mask}  ${default_gateway}  Success
167    Add Static IP Address And Verify  ${test_ipv4_addr_1}  ${test_subnet_mask}  ${default_gateway}  Success
168
169
170Configure And Verify Invalid Static IP Address
171    [Documentation]  Login to GUI Network page, configure invalid static IP address and verify.
172    [Tags]  Configure_And_Verify_Invalid_Static_IP_Address
173    [Setup]  Redfish.Login
174    [Teardown]  Redfish.Logout
175    [Template]  Add Static IP Address And Verify
176
177    # ip                 subnet_mask          gateway             status
178    ${out_of_range_ip}   ${test_subnet_mask}  ${default_gateway}  Invalid format
179    ${less_octet_ip}     ${test_subnet_mask}  ${default_gateway}  Invalid format
180    ${string_ip}         ${test_subnet_mask}  ${default_gateway}  Invalid format
181    ${negative_ip}       ${test_subnet_mask}  ${default_gateway}  Invalid format
182    ${hex_ip}            ${test_subnet_mask}  ${default_gateway}  Invalid format
183    ${spl_char_ip}       ${test_subnet_mask}  ${default_gateway}  Invalid format
184
185
186Configure Hostname Via GUI And Verify
187    [Documentation]  Login to GUI Network page, configure hostname and verify.
188    [Tags]  Configure_Hostname_Via_GUI_And_Verify
189    [Teardown]  Configure the Hostname Back And Verify
190
191    ${hostname}=  Get BMC Hostname
192    Set Suite Variable  ${hostname}
193    Configure And Verify Network Settings Via GUI  ${xpath_hostname}
194    ...  ${xpath_hostname_input}  ${test_hostname}
195
196    ${bmc_hostname}=  Get BMC Hostname
197    Should Be Equal As Strings  ${bmc_hostname}  ${test_hostname}
198
199
200*** Keywords ***
201
202Suite Setup Execution
203    [Documentation]  Do suite setup tasks.
204
205    Launch Browser And Login GUI
206    Wait Until Keyword Succeeds  1 min  15 sec
207    ...  Click Element  ${xpath_settings_menu}
208    Click Element  ${xpath_network_sub_menu}
209    Wait Until Keyword Succeeds  30 sec  10 sec  Location Should Contain  network
210    Wait Until Element Is Not Visible   ${xpath_page_loading_progress_bar}  timeout=30
211    ${default_gateway}=  Get BMC Default Gateway
212    Set Suite Variable  ${default_gateway}
213
214Configure the Hostname Back And Verify
215    [Documentation]  Configure the hostname back.
216
217    Configure And Verify Network Settings Via GUI
218    ...  ${xpath_hostname}  ${xpath_hostname_input}  ${hostname}
219    ${bmc_hostname_after}=  Get BMC Hostname
220    Should Be Equal As Strings  ${bmc_hostname_after}  ${hostname}
221
222Delete DNS Servers And Verify
223    [Documentation]  Login to GUI Network page,delete static name servers
224    ...  and verify that page does not reflect static name servers.
225
226    Page Should Contain Element  ${xpath_delete_dns_server}
227    Wait Until Element Is Enabled  ${xpath_delete_dns_server}
228    Click Button  ${xpath_delete_dns_server}
229    Wait Until Page Contains Element  ${xpath_add_dns_ip_address_button}  timeout=15
230    # Check if all name servers deleted on BMC.
231    ${nameservers}=  CLI Get Nameservers
232    Should Be Empty  ${nameservers}
233
234
235Add Static IP Address And Verify
236    [Documentation]  Add static IP address, subnet mask and
237    ...  gateway via GUI and verify.
238    [Arguments]  ${ip_address}  ${subnet_mask}  ${gateway_address}  ${expected_status}=error
239
240    # Description of argument(s):
241    # ip_address          IP address to be added (e.g. 10.7.7.7).
242    # subnet_mask         Subnet mask for the IP to be added (e.g. 255.255.0.0).
243    # gateway_address     Gateway address for the IP to be added (e.g. 10.7.7.1).
244    # expected_status     Expected status while adding static ipv4 address
245    # ....                (e.g. Invalid format / Field required).
246
247    Wait Until Keyword Succeeds  30 sec  10 sec  Click Element  ${xpath_add_static_ipv4_address_button}
248
249    Input Text  ${xpath_input_ip_address}  ${ip_address}
250    Input Text  ${xpath_input_subnetmask}  ${subnet_mask}
251    Input Text  ${xpath_input_gateway}  ${gateway_address}
252
253    Click Element  ${xpath_add_button}
254    Run Keyword If  '${expected_status}' == 'Success'
255    ...  Run Keywords  Wait Until Page Contains  ${ip_address}  timeout=40sec
256    ...  AND  Validate Network Config On BMC
257
258    ...  ELSE IF  '${expected_status}' == 'Invalid format'
259    ...  Run Keywords  Page Should Contain  Invalid format  AND
260    ...  Click Button  ${xpath_cancel_button}
261
262
263Configure And Verify Network Settings Via GUI
264    [Documentation]  Configure and verify network settings via GUI.
265    [Arguments]  ${xpath_nw_settings}  ${xpath_nw_settings_input_field}  ${input_value}
266
267    # Description of argument(s):
268    # xpath_nw_settings               xpath of the network settings.
269    # xpath_nw_settings_input_field   xpath of the network setting's input field.
270    # input_value                     Input value for configuration. E.g. hostname, IP etc.
271
272    Wait Until Keyword Succeeds  30 sec  10 sec  Click Element  ${xpath_nw_settings}
273    Input Text  ${xpath_nw_settings_input_field}  ${input_value}
274    Click Button  ${xpath_save_button}
275    Wait Until Page Contains  ${input_value}  timeout=30sec
276