'Test with an invalid ?next=http://example.com parameter.'

@mock.patch.object(Site.objects, 'get_current')
def test_login_invalid_next_parameter(self, get_current):

    get_current.return_value.domain = 'testserver.com'
    invalid_next = 'http://foobar.com/evil/'
    valid_next = reverse('home', locale=settings.LANGUAGE_CODE)
    url = urlparams(reverse('users.login'), next=invalid_next)
    response = self.client.get(url, follow=True)
    eq_(200, response.status_code)
    doc = pq(response.content)
    eq_(valid_next, doc('#login    input[name="next"]')[0].attrib['value'])
    response = self.client.post(reverse('users.login'), {'username': self.u.username, 'password': 'testpass', 'next': invalid_next})
    eq_(302, response.status_code)
    eq_((('http://testserver' + valid_next) + '?fpa=1'), response['location'])
