~roadmr/canonical-identity-provider/suspend-admin-action

« back to all changes in this revision

Viewing changes to src/webui/tests/test_views_account.py

  • Committer: Ubuntu One Auto Copilot
  • Author(s): Daniel Manrique
  • Date: 2018-04-04 19:45:47 UTC
  • mfrom: (1613.2.5 mail-on-pwd-change)
  • Revision ID: otto-copilot@canonical.com-20180404194547-r9pt5v0xkijs3clz
Send e-mail when user changes their password.

This is controlled by a gargoyle switch in case it misbehaves.

Merged from https://code.launchpad.net/~roadmr/canonical-identity-provider/mail-on-pwd-change/+merge/342474

Show diffs side-by-side

added added

removed removed

Lines of Context:
243
243
        r = self.client.post(self.url, data)
244
244
        self.assertEqual(r.status_code, 302)
245
245
 
 
246
    def test_index_edit_displayname_no_email(self):
 
247
        data = {'displayname': "New Display Name",
 
248
                'preferred_email': self.account.preferredemail.id}
 
249
        r = self.client.post(self.url, data)
 
250
        self.assertEqual(r.status_code, 302)
 
251
        # no mail when editing this attribute
 
252
        self.assertEqual(len(mail.outbox), 0)
 
253
 
246
254
    def test_index_edit_with_token(self):
247
255
        ctx = {'token': 'a' * 16}
248
256
        r = self.client.get(reverse('account-edit', kwargs=ctx))
401
409
        # new session is set up
402
410
        session_token_key = self.client.session.get(SESSION_TOKEN_KEY)
403
411
        self.assertEqual(session_token_key, oauth_tokens[0].pk)
 
412
        # Email was sent
 
413
        self.assertEqual(len(mail.outbox), 1)
 
414
        email = mail.outbox[0]
 
415
        my_email = self.account.preferredemail.email
 
416
        self.assertEqual(email.to, [my_email])
 
417
        self.assertIn('Password change notification',
 
418
                      email.subject)
 
419
        self.assertIn(
 
420
            'your Ubuntu One password has been changed successfully.',
 
421
            email.body)
404
422
 
405
423
    def test_index_edit_password_with_leaked_password(self):
406
424
        self.factory.make_leaked_credential(