mirror of
https://git.linux-kernel.at/oliver/ivatar.git
synced 2025-11-18 22:18:02 +00:00
Redir to deadbeef if hash is wrong
This commit is contained in:
@@ -61,5 +61,8 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods
|
|||||||
"""
|
"""
|
||||||
Test incorrect digest
|
Test incorrect digest
|
||||||
"""
|
"""
|
||||||
response = self.client.get('/avatar/%s' % 'x'*65)
|
response = self.client.get('/avatar/%s' % 'x'*65, follow=True)
|
||||||
self.assertEqual(response.status_code, 200, 'no 200 ok?')
|
self.assertRedirects(
|
||||||
|
response=response,
|
||||||
|
expected_url='/static/img/deadbeef.png',
|
||||||
|
msg_prefix='Why does an invalid hash not redirect to deadbeef?')
|
||||||
|
|||||||
@@ -24,11 +24,7 @@ urlpatterns = [ # pylint: disable=invalid-name
|
|||||||
url(r'avatar/$', AvatarImageView.as_view(), name='avatar_view'),
|
url(r'avatar/$', AvatarImageView.as_view(), name='avatar_view'),
|
||||||
url(
|
url(
|
||||||
r'avatar/(?P<digest>\w*)',
|
r'avatar/(?P<digest>\w*)',
|
||||||
TemplateView.as_view(
|
RedirectView.as_view(url='/static/img/deadbeef.png'), name='invalid_hash'),
|
||||||
template_name='error.html',
|
|
||||||
extra_context={
|
|
||||||
'errormessage': 'Incorrect digest length',
|
|
||||||
})),
|
|
||||||
url(
|
url(
|
||||||
r'gravatarproxy/(?P<digest>\w*)',
|
r'gravatarproxy/(?P<digest>\w*)',
|
||||||
GravatarProxyView.as_view(), name='gravatarproxy'),
|
GravatarProxyView.as_view(), name='gravatarproxy'),
|
||||||
|
|||||||
Reference in New Issue
Block a user