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