Add case to test get channel authentication capabilities

Signed-off-by: Tony Lee <tony.lee@quantatw.com>
Change-Id: I30f23cc07adcdc92e2b26b30564c0aec6efe5067
diff --git a/ipmi/test_ipmi_general.robot b/ipmi/test_ipmi_general.robot
index bb69e0f..181261f 100644
--- a/ipmi/test_ipmi_general.robot
+++ b/ipmi/test_ipmi_general.robot
@@ -146,3 +146,21 @@
 
     Valid Value  access_mode_ipmi_conf_map['${channel_info_ipmi['non-volatile_settings']['access_mode']}']
     ...  ['${channel_nv_data_config['${CHANNEL_NUMBER}']['access_mode']}']
+
+
+Test Get Channel Authentication Capabilities via IPMI
+    [Documentation]  Test get channel authentication capabilities via IPMI.
+    [Tags]  Test_Get_Channel_Authentication_Capabilities_via_IPMI
+
+    ${channel_auth_cap}=  Get Channel Auth Capabilities  ${CHANNEL_NUMBER}
+    Rprint Vars  channel_auth_cap
+
+    Valid Value  channel_auth_cap['channel_number']  ['${CHANNEL_NUMBER}']
+    Valid Value  channel_auth_cap['kg_status']  ['default (all zeroes)']
+    Valid Value  channel_auth_cap['per_message_authentication']  ['enabled']
+    Valid Value  channel_auth_cap['user_level_authentication']  ['enabled']
+    Valid Value  channel_auth_cap['non-null_user_names_exist']  ['yes']
+    Valid Value  channel_auth_cap['null_user_names_exist']  ['no']
+    Valid Value  channel_auth_cap['anonymous_login_enabled']  ['no']
+    Valid Value  channel_auth_cap['channel_supports_ipmi_v1.5']  ['no']
+    Valid Value  channel_auth_cap['channel_supports_ipmi_v2.0']  ['yes']
diff --git a/lib/ipmi_utils.py b/lib/ipmi_utils.py
index 156b32a..910db87 100644
--- a/lib/ipmi_utils.py
+++ b/lib/ipmi_utils.py
@@ -689,3 +689,29 @@
     cmd_buf = "user list " + str(channel_number)
     stdout, stderr, rc = execute_ipmi_cmd(cmd_buf, "external", print_output=0)
     return vf.outbuf_to_report(stdout)
+
+
+def get_channel_auth_capabilities(channel_number=1):
+    r"""
+    Get the channel authentication capabilities and return as a dictionary.
+
+    Example:
+
+    channel_auth_cap:
+        [channel_number]:                               2
+        [ipmi_v1.5__auth_types]:
+        [kg_status]:                                    default (all zeroes)
+        [per_message_authentication]:                   enabled
+        [user_level_authentication]:                    enabled
+        [non-null_user_names_exist]:                    yes
+        [null_user_names_exist]:                        no
+        [anonymous_login_enabled]:                      no
+        [channel_supports_ipmi_v1.5]:                   no
+        [channel_supports_ipmi_v2.0]:                   yes
+    """
+
+    status, ret_values = \
+        grk.run_key_u("Run IPMI Standard Command  channel authcap " + str(channel_number) + " 4")
+    result = vf.key_value_outbuf_to_dict(ret_values, process_indent=1)
+
+    return result