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_010
34 #
35 # DESCRIPTION:
36 # Verify that CHAP authentication configured by default setting works
37 # properly
38 #
39 # STRATEGY:
40 # Setup:
41 # Modify the default auth-method is "chap" authentication
42 # by itadm modify-defaults option on target host
43 # Create target portal group with specified tag 1 and ip address
44 # Create target node with tpgt 1 and auth-method default specified
45 # Modify initiator node authentication property with the specified
46 # chap user and secret on target host by
47 # iscsiadm modify initiator-node option
48 # Modify the specified initiator node authentication property on
49 # target host with the wrong chap user and secret with
50 # configured on target host by itadm modify-initiator option
51 # Create a LU on target host by zfs file system
52 # Create the view of LU by default to all target and host groups
53 # Setup initiator node to enable "chap" authentication by
54 # iscsiadm modify initiator-node
55 # Setup initiator node to enable "SendTarget" method
56 # Setup SendTarget with discovery address on initiator host
57 # Test:
58 # Check that device path of specified LU can be NOT visible by
59 # iscsi initiator node
60 # Check that iscsi initiator node has no active connection
61 # Modify the default auth-method is "none" authentication
62 # by itadm modify-defaults option on target host
63 # Check that device path of specified LU can be visible by
64 # iscsi initiator node
65 # Check that iscsi initiator node has at least 1 active connection
66
67 # Cleanup:
68 # Delete the target portal group
69 # Delete the target node
70 # Delete the configuration information in initiator and target
71 #
72 # STRATEGY_NOTES:
73 #
74 # TESTABILITY: explicit
75 #
76 # AUTHOR: john.gu@sun.com
77 #
78 # REVIEWERS:
79 #
80 # ASSERTION_SOURCE:
81 #
82 # TEST_AUTOMATION_LEVEL: automated
83 #
84 # STATUS: IN_PROGRESS
85 #
86 # COMMENT
87 #
88 # __stc_assertion_end
89 #
90 function iscsi_auth_010
91 {
92 cti_pass
93
94 tc_id="iscsi_auth_010"
95
96 tc_desc="Verify that CHAP authentication configured by default setting"
97 tc_desc="${tc_desc} works properly "
98 print_test_case $tc_id - $tc_desc
99
100 stmsboot_enable_mpxio $ISCSI_IHOST
101
102 # Modify the default auth-method
103 itadm_modify POS defaults -a chap
104
105 typeset portal_list
106 set -A portal_list $(get_portal_list ${ISCSI_THOST})
107 typeset t="${IQN_TARGET}.${TARGET[1]}"
108 # Create target and target protal group
109 itadm_create POS tpg 1 "${portal_list[0]}"
110 itadm_create POS target -n ${t} -t 1 -a default
111
112 # Set initiator chap properities on initiator host
113 iscsiadm_modify POS "${ISCSI_IHOST}" initiator-node -C "123456789012"
114 iscsiadm_modify POS "${ISCSI_IHOST}" initiator-node -H "i_chap_user"
115 iscsiadm_modify POS "${ISCSI_IHOST}" initiator-node -a "CHAP"
116
117 # Set initiator chap properities on target host
118 typeset i_node_name="$(iscsiadm_i_node_name_get ${ISCSI_IHOST})"
119 itadm_create POS initiator -s "123456789012" "${i_node_name}"
120 itadm_modify POS initiator -u "i_chap_user" "${i_node_name}"
121
122 #Create lu
123 build_fs zdsk
124 fs_zfs_create -V 1g $ZP/${VOL[0]}
125 sbdadm_create_lu POS -s 1024k $DEV_ZVOL/$ZP/${VOL[0]}
126
127 typeset guid
128 eval guid=\$LU_${VOL[0]}_GUID
129 # Add view
130 stmfadm_add POS view "${guid}"
131
132 # Set discover address
133 iscsiadm_add POS ${ISCSI_IHOST} discovery-address \
134 "${portal_list[0]}"
135
136 # Enable sendTargets discovery method
137 iscsiadm_modify POS ${ISCSI_IHOST} discovery -t enable
138
139 # Verify the lun on initiator host
140 # Verify device path and connections
141 iscsiadm_verify ${ISCSI_IHOST} lun # First verify
142
143 # Modify the default auth-method
144 itadm_modify POS defaults -a none
145 iscsiadm_modify POS "${ISCSI_IHOST}" initiator-node -a "none"
146
147 itadm_modify POS initiator -s "123456789000" "${i_node_name}"
148 itadm_modify POS initiator -u "i_chap_user_wrong" "${i_node_name}"
149
150 # Enable sendTargets discovery method
151 iscsiadm_modify POS ${ISCSI_IHOST} discovery -t enable
152
153 # Verify the lun on initiator host
154 # Verify device path and connections
155 iscsiadm_verify ${ISCSI_IHOST} lun # Second verify
156
157 tp_cleanup
158 clean_fs zdsk
159 initiator_cleanup "${ISCSI_IHOST}"
160
161 }