New test cases and Modification on Managers

Changes:
     - Added New test case:
       Enable NTP Protocol And Verify
       Disable NTP Protocol And Verify
       Configure NTP SSH And IPMI Settings And Verify

Added on managers/test_bmc_protocol_settings.robot

Tested: Ran and Tested on BMC Environment

Change-Id: Ib1070a0f3c18e8b4b2d08b502f1e6530526f17fd
Signed-off-by: Nandakumar Babu <nandakumarb@ami.com>
diff --git a/lib/protocol_setting_utils.robot b/lib/protocol_setting_utils.robot
index d6be5a9..eea89e4 100644
--- a/lib/protocol_setting_utils.robot
+++ b/lib/protocol_setting_utils.robot
@@ -115,6 +115,23 @@
     Sleep  ${NETWORK_TIMEOUT}s
 
 
+Enable NTP Protocol
+    [Documentation]  Enable or disable NTP protocol.
+    [Arguments]  ${enable_value}=${True}
+
+    # Description of argument(s}:
+    # enable_value  Enable or disable NTP, e.g. (true, false).
+
+    ${ntp_state}=  Create Dictionary  ProtocolEnabled=${enable_value}
+    ${data}=  Create Dictionary  NTP=${ntp_state}
+
+    Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}  body=&{data}
+    ...  valid_status_codes=[${HTTP_NO_CONTENT}]
+
+    # Wait for timeout for new values to take effect.
+    Sleep  ${NETWORK_TIMEOUT}s
+
+
 Verify IPMI Works
     [Documentation]  Run IPMI command and return status.
     [Arguments]  ${sub_cmd}  ${host}=${OPENBMC_HOST}
@@ -138,3 +155,15 @@
     ${resp}=  Redfish.Get  ${REDFISH_NW_PROTOCOL_URI}
     Should Be Equal As Strings  ${resp.dict['IPMI']['ProtocolEnabled']}  ${state}
     ...  msg=Protocol states are not matching.
+
+
+Verify NTP Protocol State
+    [Documentation]  verify NTP protocol state.
+    [Arguments]  ${state}=${True}
+
+    # Description of argument(s}:
+    # state  Enable or disable NTP, e.g. (true, false)
+
+    ${resp}=  Redfish.Get  ${REDFISH_NW_PROTOCOL_URI}
+    Should Be Equal As Strings  ${resp.dict['NTP']['ProtocolEnabled']}  ${state}
+    ...  msg=Protocol states are not matching.
\ No newline at end of file
diff --git a/redfish/managers/test_bmc_protocol_settings.robot b/redfish/managers/test_bmc_protocol_settings.robot
index ff05963..f15129d 100644
--- a/redfish/managers/test_bmc_protocol_settings.robot
+++ b/redfish/managers/test_bmc_protocol_settings.robot
@@ -164,6 +164,27 @@
     ...  msg=IPMI commands are working after disabling IPMI.
 
 
+Enable NTP Protocol And Verify
+    [Documentation]  Enable NTP protocol and verify.
+    [Tags]  Enable_NTP_Protocol_And_Verify
+
+    Enable NTP Protocol  ${True}
+
+    # Check if NTP is really enabled via Redfish.
+    Verify NTP Protocol State  ${True}
+
+
+Disable NTP Protocol And Verify
+    [Documentation]  Disable NTP protocol and verify.
+    [Tags]  Disable_NTP_Protocol_And_Verify
+
+    # Disable NTP interface.
+    Enable NTP Protocol  ${False}
+
+    # Check if NTP is really disabled via Redfish.
+    Verify NTP Protocol State  ${False}
+
+
 Enable IPMI Protocol And Check Persistency On BMC Reboot
     [Documentation]  Set the IPMI protocol attribute to True, reset BMC, and verify
     ...              that the setting persists.
@@ -204,7 +225,7 @@
 Configure SSH And IPMI Settings And Verify
     [Documentation]  Set the SSH and IPMI protocol attribute to True/False, and verify.
     [Tags]  Configure_SSH_And_IPMI_Settings_And_Verify
-    [Template]  Set SSH And IPMI Protocol
+    [Template]  Set SSH IPMI And NTP Protocol
     [Teardown]  Run Keywords  FFDC On Test Case Fail
     ...  AND  Enable SSH Protocol  ${True}
 
@@ -219,7 +240,7 @@
     [Documentation]  Set the SSH and IPMI protocol attribute to True/False, and verify
     ...  it's persistency after BMC reboot.
     [Tags]  Configure_SSH_And_IPMI_Settings_And_Verify_Persistency_On_BMC_Reboot
-    [Template]  Set SSH And IPMI Protocol
+    [Template]  Set SSH IPMI And NTP Protocol
     [Teardown]  Run Keywords  FFDC On Test Case Fail
     ...  AND  Enable SSH Protocol  ${True}
 
@@ -230,6 +251,21 @@
     ${False}     ${False}    ${True}
 
 
+Configure NTP SSH And IPMI Settings And Verify
+    [Documentation]  Set NTP, SSH and IPMI protocol attribute to True/False, and verify.
+    [Tags]  Configure_NTP_And_SSH_And_IPMI_Settings_And_Verify
+    [Template]  Set SSH IPMI And NTP Protocol
+    [Teardown]  Run Keywords  FFDC On Test Case Fail
+    ...  AND  Enable SSH Protocol  ${True}
+
+    #ssh_state   ipmi_state   persistency_check   ntp_state
+    ${True}      ${False}     ${False}            ${False}
+    ${False}     ${True}      ${False}            ${False}
+    ${False}     ${True}      ${False}            ${True}
+    ${False}     ${False}     ${False}            ${False}
+    ${True}      ${True}      ${False}            ${True}
+
+
 *** Keywords ***
 
 Suite Setup Execution
@@ -242,18 +278,25 @@
     Sleep  ${NETWORK_TIMEOUT}s
 
 
-Set SSH And IPMI Protocol
-    [Documentation]  Set SSH and IPMI protocol state.
-    [Arguments]  ${ssh_state}  ${ipmi_state}  ${persistency_check}=${False}
+Set SSH IPMI And NTP Protocol
+    [Documentation]  Set SSH, IPMI and NTP protocol state.
+    [Arguments]  ${ssh_state}  ${ipmi_state}  ${persistency_check}=${False}  ${ntp_state}=''
 
     # Description of argument(s):
     # ssh_state          State of SSH to be set (e.g. True, False).
     # ipmi_state         State of IPMI to be set (e.g. True, False).
+    # ntp_state          State of NTP to be set (e.g. True, False).
     # persistency_check  Persistency check (e.g. True, False).
 
     ${ssh_protocol_state}=  Create Dictionary  ProtocolEnabled=${ssh_state}
     ${ipmi_protocol_state}=  Create Dictionary  ProtocolEnabled=${ipmi_state}
-    ${data}=  Create Dictionary  SSH=${ssh_protocol_state}  IPMI=${ipmi_protocol_state}
+
+    IF  ${ntp_state} != ''
+        ${ntp_protocol_state}=  Create Dictionary  ProtocolEnabled=${ntp_state}
+        ${data}=  Create Dictionary  SSH=${ssh_protocol_state}  IPMI=${ipmi_protocol_state}  NTP=${ntp_protocol_state}
+    ELSE
+        ${data}=  Create Dictionary  SSH=${ssh_protocol_state}  IPMI=${ipmi_protocol_state}
+    END
 
     Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}  body=&{data}
     ...  valid_status_codes=[${HTTP_NO_CONTENT}]
@@ -264,16 +307,18 @@
     IF  ${persistency_check} == ${True}
         Redfish OBMC Reboot (off)  stack_mode=skip
     END
-    Verify Protocol State  ${ssh_state}  ${ipmi_state}
+
+    Verify Protocol State  ${ssh_state}  ${ipmi_state}  ${ntp_state}
 
 
 Verify Protocol State
-    [Documentation]  Verify SSH and IPMI protocol state.
-    [Arguments]  ${ssh_state}  ${ipmi_state}
+    [Documentation]  Verify SSH, IPMI and NTP protocol state.
+    [Arguments]  ${ssh_state}  ${ipmi_state}  ${ntp_state}=''
 
     # Description of argument(s):
     # ssh_state     State of SSH to be verified (e.g. True, False).
     # ipmi_state    State of IPMI to be verified (e.g. True, False).
+    # ntp_state     State of NTP to be verified (e.g. True, False).
 
     # Verify SSH state value.
     ${status}=  Run Keyword And Return Status
@@ -284,6 +329,12 @@
     # Verify IPMI state value.
     ${status}=  Run Keyword And Return Status
     ...  Verify IPMI Works  lan print
-
     Should Be Equal As Strings  ${status}  ${ipmi_state}
     ...  msg=IPMI states are not matching.
+
+    # Verify NTP state value via Redfish.
+    IF  ${ntp_state} != ''
+        ${resp}=  Redfish.Get  ${REDFISH_NW_PROTOCOL_URI}
+        Should Be Equal As Strings  ${resp.dict['NTP']['ProtocolEnabled']}  ${ntp_state}
+        ...  msg=NTP protocol states are not matching.
+    END