Added new cases for get channel authentication capabilities

Modified existing testcase for get channel authentication capabilities
via ipmi cmd to support multiple active channels.

Added testcase to verify channel auth cap ipmi cmd for invalid channels
Getting invalid channels list from /usr/share/ipmi-providers/channel_config.json
file.

Added testcase to verify ipmi raw cmd with one extra byte and
also raw cmd with one byte less

Tested: Run robot ipmi/test_ipmi_general.robot

Signed-off-by: Nagarjun B  <nagarjunb@ami.com>
Change-Id: Ie881a0d847bff73d8a86dd5e67268b35fe346b47
diff --git a/ipmi/test_ipmi_general.robot b/ipmi/test_ipmi_general.robot
index 4a8c5a7..960f484 100644
--- a/ipmi/test_ipmi_general.robot
+++ b/ipmi/test_ipmi_general.robot
@@ -3,11 +3,13 @@
 Documentation    Module to test IPMI asset tag functionality.
 Resource         ../lib/ipmi_client.robot
 Resource         ../lib/openbmc_ffdc.robot
+Resource         ../lib/bmc_network_utils.robot
 Variables        ../data/ipmi_raw_cmd_table.py
 Variables        ../data/ipmi_variable.py
 Library          ../lib/bmc_network_utils.py
 Library          ../lib/ipmi_utils.py
 
+Suite Setup      IPMI General Test Suite Setup
 Test Teardown    FFDC On Test Case Fail
 
 *** Test Cases ***
@@ -152,21 +154,37 @@
 
 
 Test Get Channel Authentication Capabilities via IPMI
-    [Documentation]  Test get channel authentication capabilities via IPMI.
+    [Documentation]  Verify channel authentication capabilities via IPMI.
     [Tags]  Test_Get_Channel_Authentication_Capabilities_via_IPMI
+    [Template]  Verify Channel Auth Capabilities
 
-    ${channel_auth_cap}=  Get Channel Auth Capabilities  ${CHANNEL_NUMBER}
-    Rprint Vars  channel_auth_cap
+    FOR  ${channel}  IN   @{active_channel_list}
+        FOR  ${privilege}  IN   4  3  2
+            # Input Channel     Privilege Level
+            ${channel}          ${privilege}
+        END
+    END
 
-    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']
+
+Test Get Channel Authentication Capabilities IPMI Command For Invalid Channel
+    [Documentation]  Verify get channel authentication capabilities for invalid channel.
+    [Tags]  Test_Get_Channel_Authentication_Capabilities_IPMI_Command_For_Invalid_Channel
+    [Template]  Verify Channel Auth Capabilites For Invalid Channel
+
+    FOR  ${channel}  IN  @{inactive_channel_list}
+        # Input Channel
+        ${channel}
+    END
+
+
+Verify Get Channel Authentication Capablities IPMI Raw Command With Invalid Data Length
+    [Documentation]  Verify get channel authentication capablities IPMI raw command with invalid data length.
+    [Tags]  Verify_Get_Channel_Authentication_Capablities_IPMI_Raw_Command_With_Invalid_Data_Length
+    [Template]  Verify Channel Auth Command For Invalid Data Length
+
+    # Bytes
+    low
+    high
 
 
 Verify Set Session Privilege Level via IPMI Raw Command
@@ -245,6 +263,19 @@
 
 *** Keywords ***
 
+IPMI General Test Suite Setup
+    [Documentation]  Get active and inactive/invalid channels from channel_config.json file
+    ...              in list type and set it as suite variable.
+
+    # Get active channel list and set as suite variable.
+    @{active_channel_list}=  Get Active Ethernet Channel List
+    Set Suite Variable  @{active_channel_list}
+
+    # Get Inactive/Invalid channel list and set as suite variable.
+    @{inactive_channel_list}=  Get Invalid Channel Number List
+    Set Suite Variable  @{inactive_channel_list}
+
+
 Set Session Privilege Level And Verify
     [Documentation]   Set session privilege with given privilege level and verify the response with
     ...               expected level.
@@ -283,3 +314,56 @@
         ${led_value}=  Redfish.Get Attribute  ${system}  IndicatorLED
         Should Be True  '${led_value}' == '${expected_state}'
     END
+
+
+Verify Channel Auth Capabilities
+    [Documentation]  Verify authentication capabilities for given channel and privilege.
+    [Arguments]  ${channel}  ${privilege_level}
+
+    # Description of argument(s):
+    # channel           Interface channel number.
+    # privilege_level   User Privelege level (e.g. 4-Administator, 3-Operator, 2-Readonly).
+
+    # Python module:  get_channel_auth_capabilities(channel_number, privilege_level)
+    ${channel_auth_cap}=  Get Channel Auth Capabilities  ${channel}  ${privilege_level}
+    Rprint Vars  channel_auth_cap
+
+    Valid Value  channel_auth_cap['channel_number']  ['${channel}']
+    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']
+
+
+Verify Channel Auth Capabilites For Invalid Channel
+    [Documentation]  Verify authentication capabilities of invalid channels.
+    [Arguments]  ${channel}
+
+    # Description of argument(s):
+    # channel   Interface channel number.
+
+    ${channel_in_hex}=  Convert To Hex  ${channel}  prefix=0x
+    ${cmd}=  Catenate  ${IPMI_RAW_CMD['Get Channel Auth Cap']['get'][0]} ${channel_in_hex} 0x04
+
+    Verify Invalid IPMI Command  ${cmd}  0xcc
+
+
+Verify Channel Auth Command For Invalid Data Length
+   [Documentation]  Verify channel authentication command for invalid data length.
+   [Arguments]  ${byte_length}
+
+   # Description of argument(s):
+   # byte_length   high or low.
+   #               e.g. high - add extra byte to request data like "0x06 0x38 0x01 0x04 0x01".
+   #               low - reduce bytes in actual request data like "0x06 0x38".
+
+   ${req_cmd}=  Run Keyword If  '${byte_length}' == 'low'
+   ...  Catenate  ${IPMI_RAW_CMD['Get Channel Auth Cap']['get'][0]}  ${CHANNEL_NUMBER}
+   ...  ELSE
+   ...  Catenate  ${IPMI_RAW_CMD['Get Channel Auth Cap']['get'][0]}  ${CHANNEL_NUMBER} 0x04 0x01
+
+   Verify Invalid IPMI Command  ${req_cmd}  0xc7