Added vmi certificate stage2 testcases and supporting library functions

Changes-
     added testcases:
     -Get_Concurrent_Root_Certificate_Requests_From_Multiple_Admins
     -Get_Concurrent_CSR_Requests_From_Multiple_Admins
     -Get_Concurrent_Corrupted_CSR_Requests_From_Multiple_Admins
     library functions:
     -execute_keyword_args
     -execute_process_multi_keyword

Change-Id: I9cd8266ba4213eb6a476b9666beb512872f87dde
Signed-off-by: shrsuman123 <shrsuman@in.ibm.com>
diff --git a/openpower/ext_interfaces/test_vmicert_management.robot b/openpower/ext_interfaces/test_vmicert_management.robot
index 88129be..ab4280a 100644
--- a/openpower/ext_interfaces/test_vmicert_management.robot
+++ b/openpower/ext_interfaces/test_vmicert_management.robot
@@ -2,6 +2,7 @@
 
 Documentation    VMI certificate exchange tests.
 
+Library          ../../lib/jobs_processing.py
 Resource         ../../lib/resource.robot
 Resource         ../../lib/bmc_redfish_resource.robot
 Resource         ../../lib/openbmc_ffdc.robot
@@ -23,8 +24,7 @@
 &{USERS}          Administrator=${ADMIN}  Operator=${OPERATOR}  ReadOnly=${ReadOnly}
 ...               NoAccess=${NoAccess}
 ${VMI_BASE_URI}   /ibm/v1/
-${CSR_FILE}       csr_server.csr
-${CSR_KEY}        csr_server.key
+
 
 *** Test Cases ***
 
@@ -140,12 +140,58 @@
     # Request root certificate from NoAccess user.
     noaccess_user         TestPwd123           ${False}      ${True}    ${HTTP_FORBIDDEN}
 
+Get Concurrent Root Certificate Requests From Multiple Admin Users
+    [Documentation]  Get multiple concurrent root certificate requests from multiple admins
+    ...  and verify no errors.
+    [Tags]  Get_Concurrent_Root_Certificate_Requests_From_Multiple_Admin_Users
+
+    FOR  ${i}  IN RANGE  ${5}
+        ${dict}=  Execute Process Multi Keyword  ${5}
+        ...  Get Root Certificate ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
+        ...  Get Root Certificate ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
+        ...  Get Root Certificate ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
+        Dictionary Should Not Contain Value  ${dict}  False
+        ...  msg=One or more operations has failed.
+    END
+
+Get Concurrent CSR Requests From Multiple Admin Users
+    [Documentation]  Get multiple concurrent csr requests from multiple admins and verify no errors.
+    [Tags]  Get_Concurrent_CSR_Requests_From_Multiple_Admin_Users
+
+    FOR  ${i}  IN RANGE  ${5}
+        ${dict}=  Execute Process Multi Keyword  ${5}
+        ...  Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
+        ...  Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
+        ...  Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
+        ...  Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
+        Dictionary Should Not Contain Value  ${dict}  False
+        ...  msg=One or more operations has failed.
+    END
+
+Get Concurrent Corrupted CSR Requests From Multiple Admin Users
+    [Documentation]  Get multiple concurrent corrupted csr requests from multiple admins and verify no errors.
+    [Tags]  Get_Concurrent_Corrupted_CSR_Requests_From_Multiple_Admin_Users
+
+    FOR  ${i}  IN RANGE  ${5}
+        ${dict}=  Execute Process Multi Keyword  ${5}
+        ...  Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_INTERNAL_SERVER_ERROR}
+        ...  Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_INTERNAL_SERVER_ERROR}
+        ...  Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_INTERNAL_SERVER_ERROR}
+        Dictionary Should Not Contain Value  ${dict}  False
+        ...  msg=One or more operations has failed.
+    END
+
 *** Keywords ***
 
 Generate CSR String
     [Documentation]  Generate a csr string.
 
     # Note: Generates and returns csr string.
+    ${csr_gen_time} =  Get Current Date Time
+    ${CSR_FILE}=  Catenate  SEPARATOR=_  ${csr_gen_time}  csr_server.csr
+    ${CSR_KEY}=   Catenate  SEPARATOR=_  ${csr_gen_time}  csr_server.key
+    Set Test Variable  ${CSR_FILE}
+    Set Test Variable  ${CSR_KEY}
     ${ssl_cmd}=  Set Variable  openssl req -new -newkey rsa:2048 -nodes -keyout ${CSR_KEY} -out ${CSR_FILE}
     ${ssl_sub}=  Set Variable
     ...  -subj "/C=XY/ST=Abcd/L=Efgh/O=ABC/OU=Systems/CN=abc.com/emailAddress=xyz@xx.ABC.com"
@@ -181,6 +227,7 @@
     Set To Dictionary  ${data}  data  ${csr_data}
 
     ${resp}=  Post Request  openbmc  ${cert_uri}  &{data}  headers=${headers}
+    Log to console  ${resp.content}
 
     [Return]  ${resp}
 
@@ -285,10 +332,12 @@
 
     # create a crt file with certificate string
     ${signed_cert}=  Set Variable  ${cert["Certificate"]}
+    ${testcert_gen_time} =  Get Current Date Time
+    ${test_cert_file}=   Catenate  SEPARATOR=_  ${testcert_gen_time}  test_certificate.cert
 
-    Create File  test_certificate.crt  ${signed_cert}
-    ${subject_signed_csr}=  Get Subject  test_certificate.crt  False
-    ${pubKey_signed_csr}=  Get Public Key  test_certificate.crt  False
+    Create File  ${test_cert_file}  ${signed_cert}
+    ${subject_signed_csr}=  Get Subject   ${test_cert_file}  False
+    ${pubKey_signed_csr}=  Get Public Key  ${test_cert_file}  False
 
     Should be equal as strings    ${subject_signed_csr}    ${subject_csr}
     Should be equal as strings    ${pubKey_signed_csr}     ${pubKey_csr}
@@ -297,14 +346,17 @@
 Suite Setup Execution
     [Documentation]  Suite setup execution.
 
+    Remove Files  *.csr  *.key  *.cert
     # Create different user accounts.
     Redfish.Login
+    Redfish Power On
     Create Users With Different Roles  users=${USERS}  force=${True}
 
 
 Suite Teardown Execution
     [Documentation]  Suite teardown execution.
 
+    Remove Files  *.csr  *.key  *.cert
     Delete BMC Users Via Redfish  users=${USERS}
     Delete All Sessions
     Redfish.Logout