~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smtp_connection.py

  • Committer: James Henstridge
  • Date: 2009-03-24 07:29:23 UTC
  • mto: This revision was merged to the branch mainline in revision 4203.
  • Revision ID: james@jamesh.id.au-20090324072923-4l42qpdtur9nqsc5
Encode usernames and passwords as UTF-8 rather than ASCII.  While 
CRAM-MD5 gives no guidance on encodings, other authentication methods 
(e.g. SASL PLAIN) do.

Show diffs side-by-side

added added

removed removed

Lines of Context:
164
164
 
165
165
    def test_authenticate_with_byte_strings(self):
166
166
        user = 'joe'
167
 
        password = 'hispass'
 
167
        password = 'h\xC3\xACspass'
168
168
        factory = WideOpenSMTPFactory()
169
169
        conn = self.get_connection(
170
170
            '[DEFAULT]\nsmtp_username=%s\nsmtp_password=%s\n'
171
171
            % (user, password), smtp_factory=factory)
 
172
        self.assertEqual(u'h\xECspass', conn._smtp_password)
172
173
        conn._connect()
173
174
        self.assertEqual([('connect', 'localhost'),
174
175
                          ('ehlo',),
175
176
                          ('has_extn', 'starttls'),
176
177
                          ('login', user, password)], factory._calls)
177
 
        smtp_user, smtp_password = factory._calls[-1][1:]
178
 
        self.assertIsInstance(smtp_user, str)
 
178
        smtp_username, smtp_password = factory._calls[-1][1:]
 
179
        self.assertIsInstance(smtp_username, str)
179
180
        self.assertIsInstance(smtp_password, str)
180
181
 
181
182
    def test_create_connection(self):