1 #
   2 # CDDL HEADER START
   3 #
   4 # The contents of this file are subject to the terms of the
   5 # Common Development and Distribution License (the "License").
   6 # You may not use this file except in compliance with the License.
   7 #
   8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9 # or http://www.opensolaris.org/os/licensing.
  10 # See the License for the specific language governing permissions
  11 # and limitations under the License.
  12 #
  13 # When distributing Covered Code, include this CDDL HEADER in each
  14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15 # If applicable, add the following below this CDDL HEADER, with the
  16 # fields enclosed by brackets "[]" replaced with your own identifying
  17 # information: Portions Copyright [yyyy] [name of copyright owner]
  18 #
  19 # CDDL HEADER END
  20 #
  21 
  22 #
  23 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #
  26 
  27 #
  28 # A test purpose file to test functionality of chap authentication
  29 #
  30 
  31 # __stc_assertion_start
  32 #
  33 # ID: iscsi_auth_006
  34 #
  35 # DESCRIPTION:
  36 #       Attempt to establish TCP connection and discovery the LU with
  37 #       bi-directional "CHAP" authentication configured when any
  38 #       uni-directional authentication fails and
  39 #       verify its failure on initiator host
  40 #
  41 # STRATEGY:
  42 #       Setup:
  43 #               Create target portal group with specified tag 1 and ip address
  44 #               Create target node with tpgt 1 with specified auth-method of
  45 #                   "chap" authentication
  46 #               Modify initiator node authentication property with specified
  47 #                   chap user1 and secret1 on initiator host by iscsiadm
  48 #                   modify initiator-node option
  49 #               Modify the specified initiator node authentication property on
  50 #                   target host by the same chap user1 and secret1 on initiator
  51 #                   host by itadm modify-initiator option
  52 #               Modify target node authentication property with specified
  53 #                   chap user3 and secret3 on target host by itadm modify-target
  54 #                   option
  55 #               Modify the specified target node authentication property on
  56 #                   initiator host by the same chap user4 and secret4 on target
  57 #                   host by iscsiadm modify target-param option
  58 #               Create a LU on target host by zfs file system
  59 #               Create the view of LU by default to all target and host groups
  60 #               Setup initiator node to enable "SendTarget" method
  61 #               Setup SendTarget with discovery address on initiator host
  62 #       Test:
  63 #               Check that device path of specified LU can NOT be visible by
  64 #                   iscsi initiator node
  65 #               Check that iscsi initiator node has no active connection
  66 #       Cleanup:
  67 #               Delete the target portal group
  68 #               Delete the target node
  69 #               Delete the configuration information in initiator and target
  70 #
  71 #       STRATEGY_NOTES:
  72 #
  73 # TESTABILITY: explicit
  74 #
  75 # AUTHOR: john.gu@sun.com
  76 #
  77 # REVIEWERS:
  78 #
  79 # ASSERTION_SOURCE:
  80 #
  81 # TEST_AUTOMATION_LEVEL: automated
  82 #
  83 # STATUS: IN_PROGRESS
  84 #
  85 # COMMENTS:
  86 #
  87 # __stc_assertion_end
  88 #
  89 function iscsi_auth_006
  90 {
  91         cti_pass
  92 
  93         tc_id="iscsi_auth_006"
  94 
  95         tc_desc="Attempt to establish TCP connection and discovery the LU with"
  96         tc_desc="${tc_desc} bi-directional CHAP authentication configured when"
  97         tc_desc="${tc_desc} any uni-directional authentication fails and verify"
  98         tc_desc="${tc_desc} its failure on initiator host"
  99         print_test_case $tc_id - $tc_desc
 100 
 101         stmsboot_enable_mpxio $ISCSI_IHOST
 102 
 103         typeset portal_list
 104         set -A portal_list $(get_portal_list ${ISCSI_THOST})
 105 
 106         typeset t="${IQN_TARGET}.${TARGET[1]}"
 107         # Create target and target protal group
 108         itadm_create POS tpg 1 "${portal_list[0]}"
 109         itadm_create POS target -n ${t} -t 1 -a chap
 110 
 111         # Set initiator chap properities on initiator host
 112         iscsiadm_modify POS "${ISCSI_IHOST}" initiator-node -C "123456789012" 
 113         iscsiadm_modify POS "${ISCSI_IHOST}" initiator-node -H "i_chap_user" 
 114 
 115         # Set initiator chap properities on target host
 116         typeset i_node_name="$(iscsiadm_i_node_name_get ${ISCSI_IHOST})"
 117         itadm_create POS initiator -s "123456789012" "${i_node_name}" 
 118         itadm_modify POS initiator -u "i_chap_user" "${i_node_name}" 
 119 
 120         # Set target chap properities on target host
 121         itadm_modify POS target -s "120123456789" "${t}" 
 122         itadm_modify POS target -u "t_chap_user" "${t}" 
 123 
 124         # Set target chap properities on initiator host
 125         iscsiadm_modify POS "${ISCSI_IHOST}" target-param -C "120123456789_2" ${t}
 126         iscsiadm_modify POS "${ISCSI_IHOST}" target-param -H "t_chap_user_2" ${t}
 127         iscsiadm_modify POS "${ISCSI_IHOST}" target-param -B "enable" ${t}
 128         iscsiadm_modify POS "${ISCSI_IHOST}" target-param -a "CHAP" ${t}
 129 
 130         #Create lu      
 131         build_fs zdsk
 132         fs_zfs_create -V 1g $ZP/${VOL[0]}    
 133         sbdadm_create_lu POS -s 1024k $DEV_ZVOL/$ZP/${VOL[0]}
 134 
 135         typeset guid
 136         eval guid=\$LU_${VOL[0]}_GUID
 137         # Add view
 138         stmfadm_add POS view "${guid}"
 139         # Online lu
 140         stmfadm_online POS lu "${guid}"
 141         # Online target
 142         stmfadm_online POS target "${IQN_TARGET}.${TARGET[1]}"
 143 
 144         # Set discover address
 145         iscsiadm_add POS ${ISCSI_IHOST} discovery-address "${portal_list[0]}"
 146 
 147         # Enable sendTargets discovery method
 148         iscsiadm_modify POS ${ISCSI_IHOST} discovery -t enable
 149 
 150         # Verify the lun on initiator host
 151         iscsiadm_verify ${ISCSI_IHOST} lun
 152 
 153         tp_cleanup
 154         clean_fs zdsk
 155         initiator_cleanup "${ISCSI_IHOST}"
 156 }
 157