1412
1412
'SMTP %(user)s@%(host)s:%(port)d password: ',
1413
1413
'smtp', port=10025)
1415
def test_ssh_password_emits_warning(self):
1416
conf = config.AuthenticationConfig(_file=StringIO(
1424
entered_password = 'typed-by-hand'
1425
stdout = tests.StringIOWrapper()
1426
ui.ui_factory = tests.TestUIFactory(stdin=entered_password + '\n',
1429
# Since the password defined in the authentication config is ignored,
1430
# the user is prompted
1431
self.assertEquals(entered_password,
1432
conf.get_password('ssh', 'bar.org', user='jim'))
1433
self.assertContainsRe(
1434
self._get_log(keep_log_file=True),
1435
'password ignored in section \[ssh with password\]')
1437
def test_ssh_without_password_doesnt_emit_warning(self):
1438
conf = config.AuthenticationConfig(_file=StringIO(
1445
entered_password = 'typed-by-hand'
1446
stdout = tests.StringIOWrapper()
1447
ui.ui_factory = tests.TestUIFactory(stdin=entered_password + '\n',
1450
# Since the password defined in the authentication config is ignored,
1451
# the user is prompted
1452
self.assertEquals(entered_password,
1453
conf.get_password('ssh', 'bar.org', user='jim'))
1454
# No warning shoud be emitted since there is no password. We are only
1456
self.assertNotContainsRe(
1457
self._get_log(keep_log_file=True),
1458
'password ignored in section \[ssh with password\]')
1416
1461
# FIXME: Once we have a way to declare authentication to all test servers, we
1417
1462
# can implement generic tests.