|
|
9a0544 |
commit fab797fcf5e4c8e09e4cde45647951acd764415e
|
|
|
9a0544 |
Author: Tomas Bzatek <tbzatek@redhat.com>
|
|
|
9a0544 |
Date: Mon Oct 10 13:58:15 2022 +0200
|
|
|
9a0544 |
|
|
|
9a0544 |
tests: Add bad auth test for iscsi
|
|
|
9a0544 |
|
|
|
9a0544 |
This tests that the auth info is properly set for each login call,
|
|
|
9a0544 |
overriding previously set auth info with no trace.
|
|
|
9a0544 |
|
|
|
9a0544 |
diff --git a/src/tests/dbus-tests/test_30_iscsi.py b/src/tests/dbus-tests/test_30_iscsi.py
|
|
|
9a0544 |
index 34bdfc4b..6ac8386b 100644
|
|
|
9a0544 |
--- a/src/tests/dbus-tests/test_30_iscsi.py
|
|
|
9a0544 |
+++ b/src/tests/dbus-tests/test_30_iscsi.py
|
|
|
9a0544 |
@@ -284,3 +284,61 @@ class UdisksISCSITest(udiskstestcase.UdisksTestCase):
|
|
|
9a0544 |
# make sure the session object is no longer on dbus
|
|
|
9a0544 |
objects = udisks.GetManagedObjects(dbus_interface='org.freedesktop.DBus.ObjectManager')
|
|
|
9a0544 |
self.assertNotIn(session_path, objects.keys())
|
|
|
9a0544 |
+
|
|
|
9a0544 |
+ def test_login_noauth_badauth(self):
|
|
|
9a0544 |
+ """
|
|
|
9a0544 |
+ Test auth info override
|
|
|
9a0544 |
+ """
|
|
|
9a0544 |
+ manager = self.get_object('/Manager')
|
|
|
9a0544 |
+ nodes, _ = manager.DiscoverSendTargets(self.address, self.port, self.no_options,
|
|
|
9a0544 |
+ dbus_interface=self.iface_prefix + '.Manager.ISCSI.Initiator',
|
|
|
9a0544 |
+ timeout=self.iscsi_timeout)
|
|
|
9a0544 |
+
|
|
|
9a0544 |
+ node = next((node for node in nodes if node[0] == self.noauth_iqn), None)
|
|
|
9a0544 |
+ self.assertIsNotNone(node)
|
|
|
9a0544 |
+
|
|
|
9a0544 |
+ (iqn, tpg, host, port, iface) = node
|
|
|
9a0544 |
+ self.assertEqual(iqn, self.noauth_iqn)
|
|
|
9a0544 |
+ self.assertEqual(host, self.address)
|
|
|
9a0544 |
+ self.assertEqual(port, self.port)
|
|
|
9a0544 |
+
|
|
|
9a0544 |
+ self.addCleanup(self._force_lougout, self.noauth_iqn)
|
|
|
9a0544 |
+
|
|
|
9a0544 |
+ # first attempt - wrong password
|
|
|
9a0544 |
+ options = dbus.Dictionary(signature='sv')
|
|
|
9a0544 |
+ options['username'] = self.initiator
|
|
|
9a0544 |
+ msg = 'Login failed: initiator reported error'
|
|
|
9a0544 |
+ with six.assertRaisesRegex(self, dbus.exceptions.DBusException, msg):
|
|
|
9a0544 |
+ options['password'] = '12345'
|
|
|
9a0544 |
+ manager.Login(iqn, tpg, host, port, iface, options,
|
|
|
9a0544 |
+ dbus_interface=self.iface_prefix + '.Manager.ISCSI.Initiator',
|
|
|
9a0544 |
+ timeout=self.iscsi_timeout)
|
|
|
9a0544 |
+
|
|
|
9a0544 |
+ # second atttempt - no password
|
|
|
9a0544 |
+ manager.Login(iqn, tpg, host, port, iface, self.no_options,
|
|
|
9a0544 |
+ dbus_interface=self.iface_prefix + '.Manager.ISCSI.Initiator',
|
|
|
9a0544 |
+ timeout=self.iscsi_timeout)
|
|
|
9a0544 |
+
|
|
|
9a0544 |
+ devs = glob.glob('/dev/disk/by-path/*%s*' % iqn)
|
|
|
9a0544 |
+ self.assertEqual(len(devs), 1)
|
|
|
9a0544 |
+
|
|
|
9a0544 |
+ # check if the block device have 'Symlinks' property updated
|
|
|
9a0544 |
+ disk_name = os.path.realpath(devs[0]).split('/')[-1]
|
|
|
9a0544 |
+ disk_obj = self.get_object('/block_devices/' + disk_name)
|
|
|
9a0544 |
+ dbus_path = str(disk_obj.object_path)
|
|
|
9a0544 |
+ self.assertIsNotNone(disk_obj)
|
|
|
9a0544 |
+
|
|
|
9a0544 |
+ symlinks = self.get_property_raw(disk_obj, '.Block', 'Symlinks')
|
|
|
9a0544 |
+ self.assertIn(self.str_to_ay(devs[0]), symlinks)
|
|
|
9a0544 |
+
|
|
|
9a0544 |
+ manager.Logout(iqn, tpg, host, port, iface, self.no_options,
|
|
|
9a0544 |
+ dbus_interface=self.iface_prefix + '.Manager.ISCSI.Initiator',
|
|
|
9a0544 |
+ timeout=self.iscsi_timeout)
|
|
|
9a0544 |
+
|
|
|
9a0544 |
+ devs = glob.glob('/dev/disk/by-path/*%s*' % iqn)
|
|
|
9a0544 |
+ self.assertEqual(len(devs), 0)
|
|
|
9a0544 |
+
|
|
|
9a0544 |
+ # make sure the disk is no longer on dbus
|
|
|
9a0544 |
+ udisks = self.get_object('')
|
|
|
9a0544 |
+ objects = udisks.GetManagedObjects(dbus_interface='org.freedesktop.DBus.ObjectManager')
|
|
|
9a0544 |
+ self.assertNotIn(dbus_path, objects.keys())
|