xref: /openbmc/openbmc-test-automation/redfish/managers/test_certificate.robot (revision ed0c14ae7358b9de3b07da65ad285dd826faffe3)
1b4b8bb6fSRahul Maheshwari*** Settings ***
2b4b8bb6fSRahul MaheshwariDocumentation    Test certificate in OpenBMC.
3b4b8bb6fSRahul Maheshwari
4b4b8bb6fSRahul MaheshwariResource         ../../lib/resource.robot
5b4b8bb6fSRahul MaheshwariResource         ../../lib/bmc_redfish_resource.robot
6b4b8bb6fSRahul MaheshwariResource         ../../lib/openbmc_ffdc.robot
7b4b8bb6fSRahul MaheshwariResource         ../../lib/certificate_utils.robot
8bf17fab7SGeorge KeishingLibrary          String
9b4b8bb6fSRahul Maheshwari
106fb70d98SMatt FischerTest Tags       Certificate
11e48fd3e4SRahul Maheshwari
12b4b8bb6fSRahul MaheshwariSuite Setup      Suite Setup Execution
13109c2ce2SAnusha DathatriSuite Teardown   Suite Teardown
14b4b8bb6fSRahul MaheshwariTest Teardown    Test Teardown Execution
15b4b8bb6fSRahul Maheshwari
16b4b8bb6fSRahul Maheshwari
171e0f6a82SRahul Maheshwari*** Variables ***
181e0f6a82SRahul Maheshwari
191e0f6a82SRahul Maheshwari${invalid_value}  abc
2084ae0d37SZbigniew Kurzynski${ROOT_CA_FILE_PATH}  /etc/ssl/certs/authority/*
21b0d8da45SRahul Maheshwari${keybit_length}  ${2048}
221e0f6a82SRahul Maheshwari
23b4b8bb6fSRahul Maheshwari** Test Cases **
24b4b8bb6fSRahul Maheshwari
25b4b8bb6fSRahul MaheshwariVerify Server Certificate Replace
26b4b8bb6fSRahul Maheshwari    [Documentation]  Verify server certificate replace.
27b4b8bb6fSRahul Maheshwari    [Tags]  Verify_Server_Certificate_Replace
28b4b8bb6fSRahul Maheshwari    [Template]  Replace Certificate Via Redfish
29b4b8bb6fSRahul Maheshwari
30b4b8bb6fSRahul Maheshwari    # cert_type  cert_format                         expected_status
31b4b8bb6fSRahul Maheshwari    Server       Valid Certificate Valid Privatekey  ok
32b4b8bb6fSRahul Maheshwari    Server       Empty Certificate Valid Privatekey  error
33b4b8bb6fSRahul Maheshwari    Server       Valid Certificate Empty Privatekey  error
34b4b8bb6fSRahul Maheshwari    Server       Empty Certificate Empty Privatekey  error
35b4b8bb6fSRahul Maheshwari
36b4b8bb6fSRahul Maheshwari
37b4b8bb6fSRahul MaheshwariVerify Client Certificate Replace
38b4b8bb6fSRahul Maheshwari    [Documentation]  Verify client certificate replace.
39b4b8bb6fSRahul Maheshwari    [Tags]  Verify_Client_Certificate_Replace
40b4b8bb6fSRahul Maheshwari    [Template]  Replace Certificate Via Redfish
41b4b8bb6fSRahul Maheshwari
42b4b8bb6fSRahul Maheshwari    # cert_type  cert_format                         expected_status
43b4b8bb6fSRahul Maheshwari    Client       Valid Certificate Valid Privatekey  ok
44b4b8bb6fSRahul Maheshwari    Client       Empty Certificate Valid Privatekey  error
45b4b8bb6fSRahul Maheshwari    Client       Valid Certificate Empty Privatekey  error
46b4b8bb6fSRahul Maheshwari    Client       Empty Certificate Empty Privatekey  error
47b4b8bb6fSRahul Maheshwari
48b4b8bb6fSRahul Maheshwari
49c1f43eddSRahul MaheshwariVerify CA Certificate Replace
50c1f43eddSRahul Maheshwari    [Documentation]  Verify CA certificate replace.
51c1f43eddSRahul Maheshwari    [Tags]  Verify_CA_Certificate_Replace
52c1f43eddSRahul Maheshwari    [Template]  Replace Certificate Via Redfish
53c1f43eddSRahul Maheshwari
54c1f43eddSRahul Maheshwari    # cert_type  cert_format        expected_status
55c1f43eddSRahul Maheshwari    CA           Valid Certificate  ok
56c1f43eddSRahul Maheshwari    CA           Empty Certificate  error
57c1f43eddSRahul Maheshwari
58c1f43eddSRahul Maheshwari
59037a3431SRahul MaheshwariVerify Client Certificate Install
60037a3431SRahul Maheshwari    [Documentation]  Verify client certificate install.
61037a3431SRahul Maheshwari    [Tags]  Verify_Client_Certificate_Install
623ecd1a68SRahul Maheshwari    [Template]  Install And Verify Certificate Via Redfish
63037a3431SRahul Maheshwari
643ecd1a68SRahul Maheshwari    # cert_type  cert_format                         expected_status
653ecd1a68SRahul Maheshwari    Client       Valid Certificate Valid Privatekey  ok
663ecd1a68SRahul Maheshwari    Client       Empty Certificate Valid Privatekey  error
673ecd1a68SRahul Maheshwari    Client       Valid Certificate Empty Privatekey  error
683ecd1a68SRahul Maheshwari    Client       Empty Certificate Empty Privatekey  error
69037a3431SRahul Maheshwari
70037a3431SRahul Maheshwari
71479c9c59SRahul MaheshwariVerify CA Certificate Install
72479c9c59SRahul Maheshwari    [Documentation]  Verify CA certificate install.
73479c9c59SRahul Maheshwari    [Tags]  Verify_CA_Certificate_Install
74479c9c59SRahul Maheshwari    [Template]  Install And Verify Certificate Via Redfish
75479c9c59SRahul Maheshwari
76479c9c59SRahul Maheshwari    # cert_type  cert_format        expected_status
77479c9c59SRahul Maheshwari    CA           Valid Certificate  ok
78479c9c59SRahul Maheshwari    CA           Empty Certificate  error
79479c9c59SRahul Maheshwari
80479c9c59SRahul Maheshwari
81d35e6879SRahul MaheshwariVerify Maximum CA Certificate Install
82d35e6879SRahul Maheshwari    [Documentation]  Verify maximum CA certificate install.
83d35e6879SRahul Maheshwari    [Tags]  Verify_Maximum_CA_Certificate_Install
84d35e6879SRahul Maheshwari    [Teardown]  Run Keywords  FFDC On Test Case Fail  AND  Delete All CA Certificate Via Redfish
85d35e6879SRahul Maheshwari
86d35e6879SRahul Maheshwari    # Get CA certificate count from BMC.
874d430283Sganesanb    ${cert_list}=  Redfish_Utils.Get Member List  /redfish/v1/Managers/${MANAGER_ID}/Truststore/Certificates
88d35e6879SRahul Maheshwari    ${cert_count}=  Get Length  ${cert_list}
89d35e6879SRahul Maheshwari
90d35e6879SRahul Maheshwari    # Install CA certificate to reach maximum count of 10.
91d35e6879SRahul Maheshwari    FOR  ${INDEX}  IN RANGE  ${cert_count}  10
92d35e6879SRahul Maheshwari      Install And Verify Certificate Via Redfish  CA  Valid Certificate  ok  ${FALSE}
93d35e6879SRahul Maheshwari      ${cert_count}=  Evaluate  ${cert_count} + 1
94d35e6879SRahul Maheshwari    END
95d35e6879SRahul Maheshwari
96d35e6879SRahul Maheshwari    # Verify error while installing 11th CA certificate.
97d35e6879SRahul Maheshwari    Install And Verify Certificate Via Redfish  CA  Valid Certificate  error  ${FALSE}
98d35e6879SRahul Maheshwari
99d35e6879SRahul Maheshwari
10016b3c7bfSGeorge KeishingVerify Error While Uploading Same CA Certificate
1018ba1ebdfSRahul Maheshwari    [Documentation]  Verify error while uploading same CA certificate two times.
10216b3c7bfSGeorge Keishing    [Tags]  Verify_Error_While_Uploading_Same_CA_Certificate
1038ba1ebdfSRahul Maheshwari
1048ba1ebdfSRahul Maheshwari    # Create certificate file for uploading.
1058ba1ebdfSRahul Maheshwari    ${cert_file_path}=  Generate Certificate File Via Openssl  Valid Certificate  365
1068ba1ebdfSRahul Maheshwari    ${bytes}=  OperatingSystem.Get Binary File  ${cert_file_path}
1078ba1ebdfSRahul Maheshwari    ${file_data}=  Decode Bytes To String  ${bytes}  UTF-8
1088ba1ebdfSRahul Maheshwari
1098ba1ebdfSRahul Maheshwari    # Install CA certificate.
1108ba1ebdfSRahul Maheshwari    Install Certificate File On BMC  ${REDFISH_CA_CERTIFICATE_URI}  ok  data=${file_data}
1118ba1ebdfSRahul Maheshwari
1128ba1ebdfSRahul Maheshwari    # Adding delay after certificate installation.
1138ba1ebdfSRahul Maheshwari    Sleep  30s
1148ba1ebdfSRahul Maheshwari
1158ba1ebdfSRahul Maheshwari    # Check error while uploading same certificate.
1168ba1ebdfSRahul Maheshwari    Install Certificate File On BMC  ${REDFISH_CA_CERTIFICATE_URI}  error  data=${file_data}
1178ba1ebdfSRahul Maheshwari
1188ba1ebdfSRahul Maheshwari
119fa95b09eSRahul MaheshwariVerify Server Certificate View Via Openssl
120fa95b09eSRahul Maheshwari    [Documentation]  Verify server certificate via openssl command.
121fa95b09eSRahul Maheshwari    [Tags]  Verify_Server_Certificate_View_Via_Openssl
122fa95b09eSRahul Maheshwari
123fa95b09eSRahul Maheshwari    ${cert_file_path}=  Generate Certificate File Via Openssl  Valid Certificate Valid Privatekey
124bf17fab7SGeorge Keishing    ${bytes}=  OperatingSystem.Get Binary File  ${cert_file_path}
125bf17fab7SGeorge Keishing    ${file_data}=  Decode Bytes To String  ${bytes}  UTF-8
126fa95b09eSRahul Maheshwari
127fa95b09eSRahul Maheshwari    ${certificate_dict}=  Create Dictionary
1284d430283Sganesanb    ...  @odata.id=/redfish/v1/Managers/${MANAGER_ID}/NetworkProtocol/HTTPS/Certificates/1
129fa95b09eSRahul Maheshwari    ${payload}=  Create Dictionary  CertificateString=${file_data}
130fa95b09eSRahul Maheshwari    ...  CertificateType=PEM  CertificateUri=${certificate_dict}
131fa95b09eSRahul Maheshwari
132fa95b09eSRahul Maheshwari    ${resp}=  redfish.Post  /redfish/v1/CertificateService/Actions/CertificateService.ReplaceCertificate
13385c22656Sganesanb    ...  body=${payload}  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
134fa95b09eSRahul Maheshwari
135fa95b09eSRahul Maheshwari    Wait Until Keyword Succeeds  2 mins  15 secs  Verify Certificate Visible Via OpenSSL  ${cert_file_path}
136fa95b09eSRahul Maheshwari
137fa95b09eSRahul Maheshwari
1381e0f6a82SRahul MaheshwariVerify CSR Generation For Server Certificate
1391e0f6a82SRahul Maheshwari    [Documentation]  Verify CSR generation for server certificate.
1401e0f6a82SRahul Maheshwari    [Tags]  Verify_CSR_Generation_For_Server_Certificate
1411e0f6a82SRahul Maheshwari    [Template]  Generate CSR Via Redfish
1421e0f6a82SRahul Maheshwari
1431e0f6a82SRahul Maheshwari    # csr_type  key_pair_algorithm  key_bit_length  key_curv_id  expected_status
1448d31f15eSganesanb    Server      RSA                 ${keybit_length}         ${EMPTY}     ok
1451e0f6a82SRahul Maheshwari    Server      EC                  ${EMPTY}                 prime256v1   ok
1461e0f6a82SRahul Maheshwari    Server      EC                  ${EMPTY}                 secp521r1    ok
1471e0f6a82SRahul Maheshwari    Server      EC                  ${EMPTY}                 secp384r1    ok
1481e0f6a82SRahul Maheshwari
1491e0f6a82SRahul Maheshwari
1501e0f6a82SRahul MaheshwariVerify CSR Generation For Client Certificate
1511e0f6a82SRahul Maheshwari    [Documentation]  Verify CSR generation for client certificate.
1521e0f6a82SRahul Maheshwari    [Tags]  Verify_CSR_Generation_For_Client_Certificate
1531e0f6a82SRahul Maheshwari    [Template]  Generate CSR Via Redfish
1541e0f6a82SRahul Maheshwari
1551e0f6a82SRahul Maheshwari    # csr_type  key_pair_algorithm  key_bit_length  key_curv_id  expected_status
1568d31f15eSganesanb    Client      RSA                 ${keybit_length}         ${EMPTY}     ok
1571e0f6a82SRahul Maheshwari    Client      EC                  ${EMPTY}                 prime256v1   ok
1581e0f6a82SRahul Maheshwari    Client      EC                  ${EMPTY}                 secp521r1    ok
1591e0f6a82SRahul Maheshwari    Client      EC                  ${EMPTY}                 secp384r1    ok
1601e0f6a82SRahul Maheshwari
1611e0f6a82SRahul Maheshwari
1621e0f6a82SRahul MaheshwariVerify CSR Generation For Server Certificate With Invalid Value
1631e0f6a82SRahul Maheshwari    [Documentation]  Verify error while generating CSR for server certificate with invalid value.
1641e0f6a82SRahul Maheshwari    [Tags]  Verify_CSR_Generation_For_Server_Certificate_With_Invalid_Value
1651e0f6a82SRahul Maheshwari    [Template]  Generate CSR Via Redfish
1661e0f6a82SRahul Maheshwari
1671e0f6a82SRahul Maheshwari    # csr_type  key_pair_algorithm  key_bit_length    key_curv_id       expected_status
1688d31f15eSganesanb    Server      ${invalid_value}    ${keybit_length}           prime256v1        error
1691e0f6a82SRahul Maheshwari    Server      RAS                 ${invalid_value}           ${EMPTY}          error
1701e0f6a82SRahul Maheshwari    Server      EC                  ${EMPTY}                   ${invalid_value}  error
1711e0f6a82SRahul Maheshwari
1721e0f6a82SRahul Maheshwari
1731e0f6a82SRahul MaheshwariVerify CSR Generation For Client Certificate With Invalid Value
1741e0f6a82SRahul Maheshwari    [Documentation]  Verify error while generating CSR for client certificate with invalid value.
1751e0f6a82SRahul Maheshwari    [Tags]  Verify_CSR_Generation_For_Client_Certificate_With_Invalid_Value
1761e0f6a82SRahul Maheshwari    [Template]  Generate CSR Via Redfish
1771e0f6a82SRahul Maheshwari
1788d31f15eSganesanb    Client      ${invalid_value}    ${keybit_length}           prime256v1        error
1791e0f6a82SRahul Maheshwari    Client      RSA                 ${invalid_value}           ${EMPTY}          error
1801e0f6a82SRahul Maheshwari    Client      EC                  ${EMPTY}                   ${invalid_value}  error
1811e0f6a82SRahul Maheshwari
1821e0f6a82SRahul Maheshwari
183bc855641SAnusha DathatriVerify Expired Certificate Install
184bc855641SAnusha Dathatri    [Documentation]  Verify installation of expired certificate.
185bc855641SAnusha Dathatri    [Tags]  Verify_Expired_Certificate_Install
186bc855641SAnusha Dathatri    [Setup]  Run Keywords  Get Current BMC Date  AND  Modify BMC Date
187bc855641SAnusha Dathatri    [Template]  Install And Verify Certificate Via Redfish
188bc855641SAnusha Dathatri    [Teardown]  Run Keywords  FFDC On Test Case Fail  AND  Restore BMC Date
189e20d18d4SAnusha Dathatri
190bc855641SAnusha Dathatri    # cert_type  cert_format          expected_status
1919832b8e7Srramyasr-in    Client       Expired Certificate  ok
1929832b8e7Srramyasr-in    CA           Expired Certificate  ok
193e20d18d4SAnusha Dathatri
194e20d18d4SAnusha Dathatri
195bc855641SAnusha DathatriVerify Expired Certificate Replace
196bc855641SAnusha Dathatri    [Documentation]  Verify replacing the certificate with an expired one.
197bc855641SAnusha Dathatri    [Tags]  Verify_Expired_Certificate_Replace
198bc855641SAnusha Dathatri    [Setup]  Run Keywords  Get Current BMC Date  AND  Modify BMC Date
199bc855641SAnusha Dathatri    [Template]  Replace Certificate Via Redfish
200bc855641SAnusha Dathatri    [Teardown]  Run Keywords  FFDC On Test Case Fail  AND  Restore BMC Date
201e20d18d4SAnusha Dathatri
202bc855641SAnusha Dathatri    # cert_type  cert_format          expected_status
2039832b8e7Srramyasr-in    Server       Expired Certificate  ok
204e20d18d4SAnusha Dathatri
205e20d18d4SAnusha Dathatri
206bc855641SAnusha DathatriVerify Not Yet Valid Certificate Install
207bc855641SAnusha Dathatri    [Documentation]  Verify installation of not yet valid certificates.
208bc855641SAnusha Dathatri    [Tags]  Verify_Not_Yet_Valid_Certificate_Install
209bc855641SAnusha Dathatri    [Setup]  Run Keywords  Get Current BMC Date  AND  Modify BMC Date
210bc855641SAnusha Dathatri    [Template]  Install And Verify Certificate Via Redfish
211bc855641SAnusha Dathatri    [Teardown]  Run Keywords  FFDC On Test Case Fail  AND  Restore BMC Date
2121a7a6b5fSAnusha Dathatri
213bc855641SAnusha Dathatri    # cert_type  cert_format                expected_status
214bc855641SAnusha Dathatri    Client       Not Yet Valid Certificate  ok
215bc855641SAnusha Dathatri    CA           Not Yet Valid Certificate  ok
216bc855641SAnusha Dathatri
217bc855641SAnusha Dathatri
218bc855641SAnusha DathatriVerify Not Yet Valid Certificate Replace
219bc855641SAnusha Dathatri    [Documentation]  Verify replacing certificate with a not yet valid one.
220bc855641SAnusha Dathatri    [Tags]  Verify_Not_Yet_Valid_Certificate_Replace
221bc855641SAnusha Dathatri    [Setup]  Run Keywords  Get Current BMC Date  AND  Modify BMC Date
222bc855641SAnusha Dathatri    [Template]  Replace Certificate Via Redfish
223bc855641SAnusha Dathatri    [Teardown]  Run Keywords  FFDC On Test Case Fail  AND  Restore BMC Date
224bc855641SAnusha Dathatri
225bc855641SAnusha Dathatri    # cert_type  cert_format                expected_status
226bc855641SAnusha Dathatri    Server       Not Yet Valid Certificate  ok
227bc855641SAnusha Dathatri    Client       Not Yet Valid Certificate  ok
228bc855641SAnusha Dathatri    CA           Not Yet Valid Certificate  ok
229bc855641SAnusha Dathatri
2301a7a6b5fSAnusha Dathatri
231027f6075STony LeeVerify Certificates Location Via Redfish
232027f6075STony Lee    [Documentation]  Verify the location of certificates via Redfish.
233027f6075STony Lee    [Tags]  Verify_Certificates_Location_Via_Redfish
234027f6075STony Lee
235027f6075STony Lee    ${cert_id}=  Install And Verify Certificate Via Redfish
236027f6075STony Lee    ...  CA  Valid Certificate  ok
237027f6075STony Lee
238027f6075STony Lee    ${resp}=  Redfish.Get  /redfish/v1/CertificateService/CertificateLocations
239027f6075STony Lee    ${Links}=  Get From Dictionary  ${resp.dict}  Links
240027f6075STony Lee
241027f6075STony Lee    ${match_cert}=  Catenate
2424d430283Sganesanb    ...  /redfish/v1/Managers/${MANAGER_ID}/Truststore/Certificates/${cert_id}
243027f6075STony Lee    ${match}=  Set Variable  ${False}
244027f6075STony Lee
245027f6075STony Lee    FOR  ${Certificates_dict}  IN  @{Links['Certificates']}
246027f6075STony Lee       Continue For Loop If
247027f6075STony Lee       ...  "${Certificates_dict['@odata.id']}}" != "${match_cert}}"
248027f6075STony Lee       ${match}=  Set Variable  ${True}
249027f6075STony Lee    END
250027f6075STony Lee
251027f6075STony Lee    Should Be Equal  ${match}  ${True}
252027f6075STony Lee    ...  msg=Verify the location of certificates via Redfish fail.
253027f6075STony Lee
254027f6075STony Lee
255b4b8bb6fSRahul Maheshwari*** Keywords ***
256b4b8bb6fSRahul Maheshwari
257109c2ce2SAnusha DathatriGet Current BMC Date
258109c2ce2SAnusha Dathatri    [Documentation]  Get current BMC date.
259109c2ce2SAnusha Dathatri
260109c2ce2SAnusha Dathatri    ${cli_date_time}=  CLI Get BMC DateTime
261109c2ce2SAnusha Dathatri    Set Test Variable  ${cli_date_time}
262109c2ce2SAnusha Dathatri
263109c2ce2SAnusha DathatriRestore BMC Date
264109c2ce2SAnusha Dathatri    [Documentation]  Restore BMC date to its prior value.
265109c2ce2SAnusha Dathatri
2664d430283Sganesanb    Redfish.Patch  ${REDFISH_BASE_URI}Managers/${MANAGER_ID}  body={'DateTime': '${cli_date_time}'}
267*ed0c14aeSrramyasr-in    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
268037a3431SRahul Maheshwari
269b4b8bb6fSRahul Maheshwari
2701e0f6a82SRahul MaheshwariGenerate CSR Via Redfish
2711e0f6a82SRahul Maheshwari    [Documentation]  Generate CSR using Redfish.
2721e0f6a82SRahul Maheshwari    [Arguments]  ${cert_type}  ${key_pair_algorithm}  ${key_bit_length}  ${key_curv_id}  ${expected_status}
2731e0f6a82SRahul Maheshwari
2741e0f6a82SRahul Maheshwari    # Description of argument(s):
2751e0f6a82SRahul Maheshwari    # cert_type           Certificate type ("Server" or "Client").
2761e0f6a82SRahul Maheshwari    # key_pair_algorithm  CSR key pair algorithm ("EC" or "RSA")
2771e0f6a82SRahul Maheshwari    # key_bit_length      CSR key bit length ("2048").
2781e0f6a82SRahul Maheshwari    # key_curv_id         CSR key curv id ("prime256v1" or "secp521r1" or "secp384r1").
2791e0f6a82SRahul Maheshwari    # expected_status     Expected status of certificate replace Redfish
2801e0f6a82SRahul Maheshwari    #                     request ("ok" or "error").
2811e0f6a82SRahul Maheshwari
2821e0f6a82SRahul Maheshwari    ${certificate_uri}=  Set Variable If
2831e0f6a82SRahul Maheshwari    ...  '${cert_type}' == 'Server'  ${REDFISH_HTTPS_CERTIFICATE_URI}/
2841e0f6a82SRahul Maheshwari    ...  '${cert_type}' == 'Client'  ${REDFISH_LDAP_CERTIFICATE_URI}/
2851e0f6a82SRahul Maheshwari
2861e0f6a82SRahul Maheshwari    ${certificate_dict}=  Create Dictionary  @odata.id=${certificate_uri}
2871e0f6a82SRahul Maheshwari    ${payload}=  Create Dictionary  City=Austin  CertificateCollection=${certificate_dict}
2888e6ebd25Srramyasr-in    ...  CommonName=${OPENBMC_HOST}  Country=US  Organization=xyz
2891e0f6a82SRahul Maheshwari    ...  OrganizationalUnit=ISL  State=AU  KeyBitLength=${key_bit_length}
2901e0f6a82SRahul Maheshwari    ...  KeyPairAlgorithm=${key_pair_algorithm}  KeyCurveId=${key_curv_id}
2911e0f6a82SRahul Maheshwari
2921e0f6a82SRahul Maheshwari    # Remove not applicable field for CSR generation.
2931e0f6a82SRahul Maheshwari    Run Keyword If  '${key_pair_algorithm}' == 'EC'  Remove From Dictionary  ${payload}  KeyBitLength
2941e0f6a82SRahul Maheshwari    ...  ELSE IF  '${key_pair_algorithm}' == 'RSA'  Remove From Dictionary  ${payload}  KeyCurveId
2951e0f6a82SRahul Maheshwari
2961e0f6a82SRahul Maheshwari    ${expected_resp}=  Set Variable If  '${expected_status}' == 'ok'  ${HTTP_OK}
2971e0f6a82SRahul Maheshwari    ...  '${expected_status}' == 'error'  ${HTTP_INTERNAL_SERVER_ERROR}, ${HTTP_BAD_REQUEST}
2981e0f6a82SRahul Maheshwari    ${resp}=  redfish.Post  /redfish/v1/CertificateService/Actions/CertificateService.GenerateCSR
2991e0f6a82SRahul Maheshwari    ...  body=${payload}  valid_status_codes=[${expected_resp}]
3001e0f6a82SRahul Maheshwari
3011e0f6a82SRahul Maheshwari    # Delay added between two CSR generation request.
3021e0f6a82SRahul Maheshwari    Sleep  5s
3031e0f6a82SRahul Maheshwari
3041e0f6a82SRahul Maheshwari
305b4b8bb6fSRahul MaheshwariSuite Setup Execution
306b4b8bb6fSRahul Maheshwari    [Documentation]  Do suite setup tasks.
307b4b8bb6fSRahul Maheshwari
308b4b8bb6fSRahul Maheshwari    # Create certificate sub-directory in current working directory.
309b4b8bb6fSRahul Maheshwari    Create Directory  certificate_dir
310109c2ce2SAnusha Dathatri    Redfish.Login
311b4b8bb6fSRahul Maheshwari
312b4b8bb6fSRahul Maheshwari
313b4b8bb6fSRahul MaheshwariTest Teardown Execution
314b4b8bb6fSRahul Maheshwari    [Documentation]  Do the post test teardown.
315b4b8bb6fSRahul Maheshwari
316b4b8bb6fSRahul Maheshwari    FFDC On Test Case Fail
317109c2ce2SAnusha Dathatri
318109c2ce2SAnusha DathatriSuite Teardown
319109c2ce2SAnusha Dathatri    [Documentation]  Do suite teardown tasks.
320109c2ce2SAnusha Dathatri
321109c2ce2SAnusha Dathatri    Redfish.Logout
322