Set local system date to test certificates

Local system date is used to generate the validity of a certificate. Hence
keeping BMC date in sync with local system date makes more sense and avoids
unexpected behavior of testcases.

Signed-off-by: Anusha Dathatri <adathatr@in.ibm.com>
Change-Id: Iaf13e12618e479f32be55c8a235bf6b636a38879
diff --git a/redfish/managers/test_certificate.robot b/redfish/managers/test_certificate.robot
index e45a96c..ab23d19 100644
--- a/redfish/managers/test_certificate.robot
+++ b/redfish/managers/test_certificate.robot
@@ -187,6 +187,7 @@
     [Teardown]  Run Keywords  FFDC On Test Case Fail  AND
     ...  Restore BMC Date
 
+    Modify BMC Date
     Install And Verify Certificate Via Redfish  Client  Expired Certificate  error
 
 
@@ -197,6 +198,7 @@
     [Teardown]  Run Keywords  FFDC On Test Case Fail  AND
     ...  Restore BMC Date
 
+    Modify BMC Date
     Install And Verify Certificate Via Redfish  CA  Expired Certificate  error
 
 
@@ -227,7 +229,7 @@
     ...  '${cert_type}' == 'Client'  ${REDFISH_LDAP_CERTIFICATE_URI}
     ...  '${cert_type}' == 'CA'  ${REDFISH_CA_CERTIFICATE_URI}
 
-    Run Keyword If  '${cert_format}' == 'Expired Certificate'  Modify BMC Date
+    Run Keyword If  '${cert_format}' == 'Expired Certificate'  Modify BMC Date  future
 
     ${cert_id}=  Install Certificate File On BMC  ${certificate_uri}  ${expected_status}  data=${file_data}
     Logging  Installed certificate id: ${cert_id}
@@ -244,15 +246,22 @@
 
 Modify BMC Date
     [Documentation]  Modify date in BMC.
-    [Arguments]  ${date_set_type}=future
+    [Arguments]  ${date_set_type}=current
 
     # Description of argument(s):
-    # date_set_type    Set BMC date to a future or old date by 375 days.
+    # date_set_type    Set BMC date to a current, future, old date by 375 days.
+    #                  current - Sets date to local system date.
+    #                  future - Sets to a future date from current date.
+    #                  old - Sets to a old date from current date.
 
     Redfish Power Off  stack_mode=skip
-    ${new_time}=  Run Keyword If  '${date_set_type}' == 'future'
-    ...  Add Time To Date  ${cli_date_time}  375 days
-    ...  ELSE  Subtract Time From Date  ${cli_date_time}  375 days
+    ${current_date_time}=  Get Current Date
+    ${new_time}=  Run Keyword If  '${date_set_type}' == 'current'  Set Variable  ${current_date_time}
+    ...  ELSE IF  '${date_set_type}' == 'future'
+    ...  Add Time To Date  ${current_date_time}  375 days
+    ...  ELSE IF  '${date_set_type}' == 'old'
+    ...  Subtract Time From Date  ${current_date_time}  375 days
+
     # Enable manaual mode.
     Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}
     ...  body={'NTP':{'ProtocolEnabled': ${False}}}