xref: /spdk/test/iscsi_tgt/chap/chap_mutual_not_set.sh (revision 868be8ed2183344cd7786f0f41d9056d14de3563)
1#!/usr/bin/env bash
2#  SPDX-License-Identifier: BSD-3-Clause
3#  Copyright (C) 2018 Intel Corporation
4#  All rights reserved.
5#
6
7testdir=$(readlink -f $(dirname $0))
8rootdir=$(readlink -f $testdir/../../..)
9source $rootdir/test/common/autotest_common.sh
10source $rootdir/test/iscsi_tgt/common.sh
11source $rootdir/test/iscsi_tgt/chap/chap_common.sh
12
13USER="chapo"
14MUSER="mchapo"
15PASS="123456789123"
16MPASS="321978654321"
17
18#initialize test:
19iscsitestinit
20#set up iscsi target
21set_up_iscsi_target
22
23#configure target to require chap authentication: add muser+mpassword but dont ask to use it with -m:
24echo "configuring target for authentication"
25config_chap_credentials_for_target -t 1 -u $USER -s $PASS -r $MUSER -m $MPASS -d -l
26echo "executing discovery without adding credential to initiator - we expect failure"
27#configure  initiator credentials:
28echo "configuring initiator with biderectional authentication"
29config_chap_credentials_for_initiator -t 1 -u $USER -s $PASS -r $MUSER -m $MPASS -d -l -b
30echo "executing discovery - target should not be discovered since the -m option was not used"
31rc=0
32iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$ISCSI_PORT || rc=$?
33if [ $rc -eq 0 ]; then
34	echo "[ERROR] - target should not be discovered since the -m option was not used"
35	exit 1
36fi
37echo "configuring target for authentication with the -m option"
38config_chap_credentials_for_target -t 2 -u $USER -s $PASS -r $MUSER -m $MPASS -d -l -b
39echo "executing discovery:"
40rc=0
41iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$ISCSI_PORT || rc=$?
42if [ $rc -ne 0 ]; then
43	echo "[ERROR] - now that we have set the -m option - we should be able to discover."
44	exit 1
45fi
46echo "executing login:"
47rc=0
48iscsiadm -m node -l -p $TARGET_IP:$ISCSI_PORT || rc=$?
49if [ $rc -ne 0 ]; then
50	echo "[ERROR] - now that we have set the -m option - we should be able to login."
51	exit 1
52fi
53
54echo "DONE"
55default_initiator_chap_credentials
56
57trap - SIGINT SIGTERM EXIT
58
59killprocess $pid
60
61iscsitestfini
62