from flask import Request

from aleph.views.util import extract_next_url
from aleph.tests.util import TestCase


class ViewUtilTest(TestCase):

    def setUp(self):
        super(ViewUtilTest, self).setUp()

    def test_extract_next_url_blank(self):
        req = Request.from_values('')
        self.assertEqual('http://localhost:5000/', extract_next_url(req))

    def test_extract_next_url_unsafe(self):
        req = Request.from_values('/?next={}'.format(self.fake.url()))
        self.assertEqual('http://localhost:5000/', extract_next_url(req))

    def test_extract_next_url_safe(self):
        req = Request.from_values('/?next=/help')

        self.assertEqual('/help', extract_next_url(req))

@@ -581,32 +581,71 @@
 url_safe(self):%0A
+        headers = %7B'Referer': '/blah'%7D%0A
         req = Re
@@ -676,18 +676,34 @@
 t=/help'
+, headers=headers
 )
-%0A
 %0A       

Make extract_next_url fail