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