Skip to content

Commit

Permalink
CA-386281 CIFS username can be omitted in ISO SR
Browse files Browse the repository at this point in the history
ISOSR falling over when no username is given is a regression that looks
to have been introduced in commit
cbd7226 when the use of a credentials
file was removed.

The ISOSR unit tests were already covered cases of not having
credentials - as evinced by having "guest" in the expected mount
options. However, they were doing this in a rather confused way that hid
the bug by supplying a username regardless. Now only the credentials
tests do this.

Signed-off-by: Robin Newton <robin.newton@cloud.com>
  • Loading branch information
Robin Newton authored and MarkSymsCtx committed Jan 9, 2024
1 parent b7c7818 commit df24f36
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
7 changes: 3 additions & 4 deletions drivers/ISOSR.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,13 +546,12 @@ def appendCIFSMountOptions(self, mountcmd):

if not cifutils.containsCredentials(self.dconf, prefix="cifs"):
options.append('guest')
domain = None
else:
_, domain = cifutils.splitDomainAndUsername(self.dconf['username'])

options.append(self.getSMBVersion())

username, domain = (
cifutils.splitDomainAndUsername(self.dconf['username'])
)

if domain:
options.append('domain=' + domain)
except:
Expand Down
13 changes: 5 additions & 8 deletions tests/test_ISOSR.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,14 @@ class TestISOSR_overSMB(unittest.TestCase):

def create_smbisosr(self, location='\\aServer\aLocation', atype=None,
sr_uuid='asr_uuid', server='\\aServer',
serverpath='/aServerpath', username='aUsername',
password='aPassword', vers=None, options='',
serverpath='/aServerpath',
vers=None, options='',
dconf_update={}):
srcmd = mock.Mock()
srcmd.dconf = {
'location': location,
'server': server,
'serverpath': serverpath,
'username': username,
'password': password,
'options': options
}
if vers:
Expand Down Expand Up @@ -252,15 +250,15 @@ def test_attach_with_smb_credentials(self, context, _checkmount, pread,
Positive case, over XC/XE CLI with version 1.0.
"""
context.setup_error_codes()
update = {'cifspassword': 'winter2019'}
update = {'username': 'dot', 'cifspassword': 'winter2019'}
smbsr = self.create_smbisosr(atype='cifs', vers='1.0',
dconf_update=update)
_checkmount.side_effect = [False, True]
smbsr.attach(None)
pread.assert_called_with(['mount.cifs', '\\aServer\x07Location',
'/var/run/sr-mount/asr_uuid', '-o',
'cache=none,vers=1.0'], True,
new_env={'PASSWD': 'winter2019', 'USER': 'aUsername'})
new_env={'PASSWD': 'winter2019', 'USER': 'dot'})

@testlib.with_context
@mock.patch('util.makedirs')
Expand All @@ -274,9 +272,8 @@ def test_attach_with_smb_credentials_domain(self, context,
Positive case, over XC/XE CLI with version 1.0.
"""
context.setup_error_codes()
update = {'cifspassword': 'winter2019'}
update = {'username': r'citrix\jsmith', 'cifspassword': 'winter2019'}
smbsr = self.create_smbisosr(atype='cifs', vers='1.0',
username=r'citrix\jsmith',
dconf_update=update)
_checkmount.side_effect = [False, True]
smbsr.attach(None)
Expand Down

0 comments on commit df24f36

Please sign in to comment.