72
73
class AccountViewsUnauthenticatedTestCase(SSOBaseTestCase):
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
79
patcher = mock.patch.object(decorators, 'disable_cookie_check', False)
81
self.addCleanup(patcher.stop)
74
83
def test_index_unauthenticated(self):
84
self.ensure_cookie_check_enabled()
75
86
r = self.client.get(reverse('account-index'))
76
88
self.assertEqual(r.status_code, 200)
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"
80
94
response = self.client.get(reverse('account-index'),
81
95
HTTP_ACCEPT=accept)
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'])
86
102
def test_index_html(self):
103
self.ensure_cookie_check_enabled()
87
105
response = self.client.get(reverse('account-index'))
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'])