Merge lp:~gz/lp-dev-utils/smtp_authentication_prompt into lp:lp-dev-utils

Proposed by Martin Packman
Status: Merged
Approved by: Graham Binns
Approved revision: 118
Merged at revision: 119
Proposed branch: lp:~gz/lp-dev-utils/smtp_authentication_prompt
Merge into: lp:lp-dev-utils
Diff against target: 48 lines (+15/-7)
1 file modified
ec2test/testrunner.py (+15/-7)
To merge this branch: bzr merge lp:~gz/lp-dev-utils/smtp_authentication_prompt
Reviewer Review Type Date Requested Status
Graham Binns (community) code Approve
Review via email: mp+112291@code.launchpad.net

Description of the change

At the moment ec2 land sends your local smtp configuration bazaar.conf to the instance and there is some logic for checking it looks sane, only the server is required. Technically smtp doesn't demand a username and password, but bzrlib.smtp_connection does, and running an open relay accessible to EC2 would be daft. So, in practice not having either set works fine with bzrlib, which prompts for them, but with ec2 you just get no feedback from your test run and the proposal doesn't land.

This branch makes ec2test use the same logic locally as bzr uses, falling back to AuthenticationConfig which will prompt, when gathering the config to forward to ec2. As it doesn't connect and send email right then, a problem will still manifest only as a lack of email, but this should at least be a better hint that email configuration is at issue.

No tests, but I have run this locally and it prompted me for my password as expected.

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) wrote :

[1]

23 + self.log("Careful, only connects from instance and a typo"
24 + " means no feedback from tests.\n")

I can guarantee that someone's going to complain about this being
opaque, so let's change it to:

 "Enter your SMTP password carefully; if it's wrong the EC2 instance will
 fail silently."

review: Approve (code)
119. By Martin Packman

Clearer output message and idiomatic wrapping as suggested in review.

Revision history for this message
Martin Packman (gz) wrote :

Thanks! That's a much clearer statement to output. Have tweaked it a little more and rewrapped.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ec2test/testrunner.py'
2--- ec2test/testrunner.py 2012-05-04 10:15:01 +0000
3+++ ec2test/testrunner.py 2012-06-27 09:13:28 +0000
4@@ -16,7 +16,7 @@
5
6 from bzrlib.branch import Branch
7 from bzrlib.bzrdir import BzrDir
8-from bzrlib.config import GlobalConfig
9+from bzrlib.config import AuthenticationConfig, GlobalConfig
10 from bzrlib.errors import UncommittedChanges
11 from bzrlib.plugins.pqm.pqm_submit import (
12 NoPQMSubmissionAddress,
13@@ -299,8 +299,18 @@
14 'configured in bzr. See the SMTP server information '
15 'here: https://wiki.canonical.com/EmailSetup .'
16 'This server must be reachable from the EC2 instance.')
17+ auth = AuthenticationConfig()
18 self._smtp_username = config.get_user_option('smtp_username')
19+ if self._smtp_username is None:
20+ self._smtp_username = auth.get_user("smtp", self._smtp_server)
21 self._smtp_password = config.get_user_option('smtp_password')
22+ if self._smtp_password is None:
23+ self.log(
24+ "Getting SMTP password, which may prompt.\n"
25+ "Input carefully; with a bad value the EC2 instance will"
26+ " fail silently.\n")
27+ self._smtp_password = auth.get_password(
28+ "smtp", self._smtp_server, self._smtp_username)
29 self._from_email = config.username()
30 if not self._from_email:
31 raise ValueError(
32@@ -351,12 +361,10 @@
33 'email = %s\n' % (self._from_email.encode('utf-8'),))
34 bazaar_conf_file.write(
35 'smtp_server = %s\n' % (self._smtp_server,))
36- if self._smtp_username:
37- bazaar_conf_file.write(
38- 'smtp_username = %s\n' % (self._smtp_username,))
39- if self._smtp_password:
40- bazaar_conf_file.write(
41- 'smtp_password = %s\n' % (self._smtp_password,))
42+ bazaar_conf_file.write(
43+ 'smtp_username = %s\n' % (self._smtp_username,))
44+ bazaar_conf_file.write(
45+ 'smtp_password = %s\n' % (self._smtp_password,))
46 bazaar_conf_file.close()
47 # Copy remote ec2-remote over
48 self.log('Copying remote.py to remote machine.\n')

Subscribers

People subscribed via source and target branches