2478
2478
def test_file_urls_are_normalized(self):
2479
2479
store = self.get_store('foo.conf')
2480
matcher = config.LocationMatcher(store, 'file:///dir/subdir')
2481
self.assertEquals('/dir/subdir', matcher.location)
2480
if sys.platform == 'win32':
2481
expected_url = 'file:///C:/dir/subdir'
2482
expected_location = 'C:/dir/subdir'
2484
expected_url = 'file:///dir/subdir'
2485
expected_location = '/dir/subdir'
2486
matcher = config.LocationMatcher(store, expected_url)
2487
self.assertEquals(expected_location, matcher.location)
2484
2490
class TestStackGet(tests.TestCase):
3016
3022
def test_username_defaults_prompts(self):
3017
3023
# HTTP prompts can't be tested here, see test_http.py
3018
self._check_default_username_prompt('FTP %(host)s username: ', 'ftp')
3019
self._check_default_username_prompt(
3020
'FTP %(host)s:%(port)d username: ', 'ftp', port=10020)
3021
self._check_default_username_prompt(
3022
'SSH %(host)s:%(port)d username: ', 'ssh', port=12345)
3024
self._check_default_username_prompt(u'FTP %(host)s username: ', 'ftp')
3025
self._check_default_username_prompt(
3026
u'FTP %(host)s:%(port)d username: ', 'ftp', port=10020)
3027
self._check_default_username_prompt(
3028
u'SSH %(host)s:%(port)d username: ', 'ssh', port=12345)
3024
3030
def test_username_default_no_prompt(self):
3025
3031
conf = config.AuthenticationConfig()
3031
3037
def test_password_default_prompts(self):
3032
3038
# HTTP prompts can't be tested here, see test_http.py
3033
3039
self._check_default_password_prompt(
3034
'FTP %(user)s@%(host)s password: ', 'ftp')
3035
self._check_default_password_prompt(
3036
'FTP %(user)s@%(host)s:%(port)d password: ', 'ftp', port=10020)
3037
self._check_default_password_prompt(
3038
'SSH %(user)s@%(host)s:%(port)d password: ', 'ssh', port=12345)
3040
u'FTP %(user)s@%(host)s password: ', 'ftp')
3041
self._check_default_password_prompt(
3042
u'FTP %(user)s@%(host)s:%(port)d password: ', 'ftp', port=10020)
3043
self._check_default_password_prompt(
3044
u'SSH %(user)s@%(host)s:%(port)d password: ', 'ssh', port=12345)
3039
3045
# SMTP port handling is a bit special (it's handled if embedded in the
3041
3047
# FIXME: should we: forbid that, extend it to other schemes, leave
3042
3048
# things as they are that's fine thank you ?
3043
self._check_default_password_prompt('SMTP %(user)s@%(host)s password: ',
3045
self._check_default_password_prompt('SMTP %(user)s@%(host)s password: ',
3046
'smtp', host='bar.org:10025')
3047
self._check_default_password_prompt(
3048
'SMTP %(user)s@%(host)s:%(port)d password: ',
3049
self._check_default_password_prompt(
3050
u'SMTP %(user)s@%(host)s password: ', 'smtp')
3051
self._check_default_password_prompt(
3052
u'SMTP %(user)s@%(host)s password: ', 'smtp', host='bar.org:10025')
3053
self._check_default_password_prompt(
3054
u'SMTP %(user)s@%(host)s:%(port)d password: ', 'smtp', port=10025)
3051
3056
def test_ssh_password_emits_warning(self):
3052
3057
conf = config.AuthenticationConfig(_file=StringIO(