1*** Settings ***
2Documentation   Test BMC multiple network interface functionalities via GUI.
3
4Resource        ../../lib/gui_resource.robot
5Resource        ../../../lib/resource.robot
6Resource        ../../../lib/certificate_utils.robot
7
8Suite Setup     Suite Setup Execution
9Test Teardown   FFDC On Test Case Fail
10
11Force Tags      Multiple_Interfaces
12
13*** Variables ***
14
15${bmc_url}                     https://${OPENBMC_HOST}:${HTTPS_PORT}
16${bmc_url_1}                   https://${OPENBMC_HOST_1}:${HTTPS_PORT}
17${LDAP_FILE_PATH}              ${EMPTY}
18${CA_FILE_PATH}                ${EMPTY}
19
20${xpath_add_new_certificate}   //*[contains(text(), ' Add new certificate ')]
21${xpath_certificate_type}      //*[@id="certificate-type"]
22${xpath_upload_file}           //*[@id="certificate-file"]
23${xpath_load_certificate}      //button[text()=' Add ']
24${xpath_close_poup}            //*[@class="close ml-auto mb-1"]
25
26*** Test Cases ***
27
28Verify BMC GUI Is Accessible Via Both Network Interfaces
29    [Documentation]  Verify BMC GUI is accessible via both network interfaces.
30    [Tags]  Verify_BMC_GUI_Is_Accessible_Via_Both_Network_Interfaces
31    [Teardown]  Close All Browsers
32
33    Start Virtual Display
34    ${browser_ID}=  Open Browser  ${bmc_url}  alias=tab1
35    Set Window Size  1920  1080
36    ${browser_ID}=  Open Browser  ${bmc_url_1}  alias=tab2
37    Set Window Size  1920  1080
38    Switch Browser  tab1
39    Run Keywords  Login GUI  AND  Logout GUI
40    Switch Browser  tab2
41    Run Keywords  Login GUI  AND  Logout GUI
42
43
44Load Certificates Via Eth1 IP Address And Verify
45    [Documentation]  Verify ability to load LDAP certificate using eth1 IP address.
46    [Tags]  Load_Certificates_Via_Eth1_IP_Address_And_Verify
47    [Template]  Load Certificates On BMC Via GUI
48
49    # bmc_url     certificate_type  file_path
50    ${bmc_url_1}  Client            ${LDAP_FILE_PATH}
51    ${bmc_url_1}  CA                ${CA_FILE_PATH}
52
53
54*** keywords ***
55
56Suite Setup Execution
57    [Documentation]  Do suite setup task.
58
59    Valid Value  OPENBMC_HOST_1
60
61    # Check both interfaces are configured and reachable.
62    Ping Host  ${OPENBMC_HOST}
63    Ping Host  ${OPENBMC_HOST_1}
64
65
66Load Certificates On BMC Via GUI
67    [Documentation]  Load certificate on BMC via GUI.
68    [Arguments]  ${bmc_url}  ${certificate_type}  ${file_path}  ${delete_cert}=${True}
69    [Teardown]  Run Keywords  Logout GUI  AND  Close Browser
70
71    # Description of argument(s):
72    # bmc_url            Openbmc GUI URL to be open.
73    # certificate_type   Certificate type.
74    #                    (e.g. "LDAP Certificate" or "CA Certificate").
75    # file_path          Certificate file path (e.g. "/home/folder/file.pem").
76
77    ${path}  ${ext}=  Split Extension  ${file_path}
78    Run Keyword If  '${certificate_type}' == 'CA' and '${delete_cert}' == '${True}'
79    ...  Delete All CA Certificate Via Redfish
80    ...  ELSE IF  '${certificate_type}' == 'Client' and '${delete_cert}' == '${True}'
81    ...  Delete Certificate Via BMC CLI  ${certificate_type}
82
83    Set Test Variable  ${obmc_gui_url}  https://${OPENBMC_HOST_1}:${HTTPS_PORT}
84    Launch Browser And Login GUI
85    Navigate To SSL Certificate Page
86    Sleep  10s
87    Click Element  ${xpath_add_new_certificate}
88
89    Wait Until Page Contains Element  ${xpath_certificate_type}  timeout=20s
90    Run Keyword If  '${certificate_type}' == 'CA'
91    ...  Select From List By Label  ${xpath_certificate_type}  CA Certificate
92    ...  ELSE IF  '${certificate_type}' == 'Client'
93    ...  Select From List By Label  ${xpath_certificate_type}  LDAP Certificate
94
95    Choose File  ${xpath_upload_file}  ${file_path}
96    Click Element  ${xpath_load_certificate}
97
98    Run Keyword If  '${ext}' !='pem'   Wait Until Page Contains  Error adding certificate.
99
100    Run Keyword If  '${certificate_type}' == 'CA'
101    ...  Wait Until Page Contains  Successfully added CA Certificate.
102    ...  ELSE IF  '${certificate_type}' == 'Client'
103    ...  Wait Until Page Contains  Successfully added LDAP Certificate.
104    Click Element  ${xpath_close_poup}
105
106
107Navigate To SSL Certificate Page
108    [Documentation]  Navigate to SSL Certificate page.
109
110    Click Element  ${xpath_secuity_and_accesss_menu}
111    Click Element  ${xpath_certificates_sub_menu}
112    Wait Until Keyword Succeeds  30 sec  10 sec  Location Should Contain  certificates
113    Wait Until Element Is Not Visible   ${xpath_page_loading_progress_bar}  timeout=30
114