Windows: case insensitive path comparisons

While Windows paths are case insensitive, some checks performed in the
SMBFS driver as well as its parent class are not, breaking the driver's
logic.

We're most affected by the fact that some of the Windows API functions
disregard path case sensitivity, always returning uppercase strings in
some situations.

This change adds a helper function that compares paths having the os
type in mind and uses it throughout the remotefs and smbfs modules.

Change-Id: Icfef1c8b9ae011d2b463aa5c1fb7f512388c8f88
Closes-Bug: #1694648
This commit is contained in:
Lucian Petrut
2017-06-23 15:19:14 +03:00
parent 30b501f48d
commit 1076e1bd67
5 changed files with 38 additions and 12 deletions

View File

@@ -65,6 +65,7 @@ class ExecuteTestCase(test.TestCase):
root_helper=mock_helper)
@ddt.ddt
class GenericUtilsTestCase(test.TestCase):
def test_as_int(self):
test_obj_int = '2'
@@ -282,6 +283,21 @@ class GenericUtilsTestCase(test.TestCase):
self.assertEqual('sudo cinder-rootwrap /path/to/conf',
utils.get_root_helper())
@ddt.data({'path_a': 'test', 'path_b': 'test', 'exp_eq': True})
@ddt.data({'path_a': 'test', 'path_b': 'other', 'exp_eq': False})
@ddt.unpack
@mock.patch('os.path.normcase')
def test_paths_normcase_equal(self, mock_normcase, path_a,
path_b, exp_eq):
# os.path.normcase will lower the path string on Windows
# while doing nothing on other platforms.
mock_normcase.side_effect = lambda x: x
result = utils.paths_normcase_equal(path_a, path_b)
self.assertEqual(exp_eq, result)
mock_normcase.assert_has_calls([mock.call(path_a), mock.call(path_b)])
class TemporaryChownTestCase(test.TestCase):
@mock.patch('os.stat')