Fixing Jenkins job failure
[integration/csit.git] / tests / oom-platform-cert-service / certservice / resources / cert-service-keywords.robot
index 4d05af7..4bda619 100644 (file)
@@ -3,7 +3,6 @@
 Resource          ../../../common.robot
 Resource          ./cert-service-properties.robot
 Library              RequestsLibrary
-Library           HttpLibrary.HTTP
 Library           Collections
 Library           Process
 Library           DateTime
@@ -12,6 +11,7 @@ Library           ../libraries/P12ArtifactsValidator.py  ${MOUNT_PATH}
 Library           ../libraries/JksArtifactsValidator.py  ${MOUNT_PATH}
 Library           ../libraries/PemArtifactsValidator.py  ${MOUNT_PATH}
 Library           ../libraries/ResponseParser.py
+Library           json
 
 *** Keywords ***
 
@@ -30,8 +30,9 @@ Run Healthcheck
 Validate Recieved Response
     [Documentation]  Validare message that has been received
     [Arguments]  ${resp}  ${key}  ${expected_value}
-    ${json}=    Parse Json      ${resp.content}
+    ${json}=    Evaluate     json.loads(r"""${resp.content}""", strict=False)    json
     ${value}=  Get From Dictionary  ${json}  ${key}
+    Log To Console    ${value}
     Should Be Equal As Strings    ${value}    ${expected_value}
 
 Send Get Request And Validate Response
@@ -57,7 +58,7 @@ Send Get Request with Header And Expect Success
 Check Message Recieved On Success
     [Documentation]  Check if correct messsage has been sent on successful request
     [Arguments]  ${content}
-    ${resp_content}=  Parse Json  ${content}
+    ${resp_content}=    Evaluate     json.loads(r"""${content}""", strict=False)    json
     Dictionary Should Contain Key  ${resp_content}  certificateChain
     @{list}=  Get From Dictionary  ${resp_content}  certificateChain
     List Should Contain Certificates  @{list}
@@ -107,6 +108,29 @@ Send Initialization Request And Certification Request And Expect Success
     ...  ${update_csr_file}  ${update_pk_file}  200
     Verify Certification Request Sent By Cert Service  ${start_time}
 
+Send Initialization Request And Key Update Request With Wrong Old Private Key And Expect Error
+    [Documentation]   Send initialization request and then key update request to passed urls and expect status code 500
+    [Arguments]   ${path}  ${update_path}   ${csr_file}  ${pk_file}  ${update_csr_file}  ${update_pk_file}  ${wrong_old_pk_file}
+    ${start_time}=  Get Current Timestamp For Docker Log
+    ${old_cert}=  Send Certificate Initialization Request And Return Certificate  ${path}  ${csr_file}  ${pk_file}
+    ${resp}=  Send Certificate Update Request And Return Response  ${update_path}  ${update_csr_file}  ${update_pk_file}  ${old_cert}  ${wrong_old_pk_file}
+    Should Be Equal As Strings         ${resp.status_code}  500
+    Verify Key Update Request Sent By Cert Service  ${start_time}
+
+Send Update Request With Wrong Header And Expect Error
+    [Documentation]   Send update request to passed url and expect wrong header response
+    [Arguments]  ${update_path}  ${update_csr_file}  ${update_pk_file}  ${old_cert_base64}  ${old_pk_file}
+    ${resp}=  Send Certificate Update Request And Return Response  ${update_path}  ${update_csr_file}  ${update_pk_file}  ${old_cert_base64}  ${old_pk_file}
+    Should Be Equal As Strings         ${resp.status_code}  400
+
+Send Update Request With Missing Header And Expect Error
+    [Documentation]   Send update request to passed url and expect wrong header response
+    [Arguments]  ${update_path}  ${update_csr_file}  ${update_pk_file}  ${old_cert_base64}  ${old_pk_file}  ${header_to_remove}
+    ${headers}=  Create Header for Certificate Update  ${update_csr_file}  ${update_pk_file}  ${old_cert_base64}  ${old_pk_file}
+    Remove From Dictionary  ${headers}  ${header_to_remove}
+    ${resp}=  Get Request  ${https_valid_cert_session}  ${update_path}  headers=${headers}
+    Should Be Equal As Strings         ${resp.status_code}  400
+
 Send Initialization Request And Update Request And Check Status Code
     [Documentation]   Send certificate update request and check status code
     [Arguments]   ${path}  ${update_path}   ${csr_file}  ${pk_file}  ${update_csr_file}  ${update_pk_file}  ${expected_status_code}
@@ -119,7 +143,7 @@ Send Certificate Initialization Request And Return Certificate
     [Arguments]   ${path}  ${csr_file}  ${pk_file}
     [Return]    ${base64Certificate}
     ${resp}=   Send Get Request with Header  ${path}  ${csr_file}  ${pk_file}
-    ${json}=    Parse Json      ${resp.content}
+    ${json}=    Evaluate     json.loads(r"""${resp.content}""", strict=False)    json
     ${base64Certificate}=    Parse Response    ${json}
 
 Send Certificate Update Request And Return Response