~stephen-stewart/canonical-identity-provider/ubuntuone-account-layout

« back to all changes in this revision

Viewing changes to webui/tests/test_views_account.py

  • Committer: Tarmac
  • Author(s): Michael Nelson
  • Date: 2013-04-23 15:55:43 UTC
  • mfrom: (816.1.5 no-cookies-for-login)
  • Revision ID: tarmac-20130423155543-h5pm7d4mnzh3wi6a
[r=ricardokirkner] Never 302 for the account-index '/' view.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
    patch_settings,
39
39
)
40
40
from identityprovider.utils import validate_launchpad_password
 
41
from webui import decorators
41
42
 
42
43
 
43
44
class AccountEmailsViewTestCase(AuthenticatedTestCase):
71
72
 
72
73
class AccountViewsUnauthenticatedTestCase(SSOBaseTestCase):
73
74
 
 
75
    def ensure_cookie_check_enabled(self):
 
76
        # Make sure the tests don't run with cookie checks disabled
 
77
        # otherwise checking that the redirect doesn't happen is
 
78
        # useless.
 
79
        patcher = mock.patch.object(decorators, 'disable_cookie_check', False)
 
80
        patcher.start()
 
81
        self.addCleanup(patcher.stop)
 
82
 
74
83
    def test_index_unauthenticated(self):
 
84
        self.ensure_cookie_check_enabled()
 
85
 
75
86
        r = self.client.get(reverse('account-index'))
 
87
 
76
88
        self.assertEqual(r.status_code, 200)
77
89
 
78
90
    def test_index_xrds(self):
 
91
        self.ensure_cookie_check_enabled()
79
92
        accept = "application/xrds+xml; q=1, text/html; q=0.9"
 
93
 
80
94
        response = self.client.get(reverse('account-index'),
81
95
                                   HTTP_ACCEPT=accept)
 
96
 
 
97
        self.assertEqual(response.status_code, 200)
82
98
        self.assertTrue('Accept' in response['Vary'].split(','))
83
99
        self.assertFalse('X-XRDS-Location' in response)
84
100
        self.assertTrue('application/xrds+xml' in response['Content-Type'])
85
101
 
86
102
    def test_index_html(self):
 
103
        self.ensure_cookie_check_enabled()
 
104
 
87
105
        response = self.client.get(reverse('account-index'))
 
106
 
 
107
        self.assertEqual(response.status_code, 200)
88
108
        self.assertTrue('Accept' in response['Vary'].split(','))
89
109
        self.assertTrue('X-XRDS-Location' in response)
90
110
        self.assertTrue('text/html' in response['Content-Type'])