Exemple #1
0
    def test_redirect_stripping_query_string(self):
        # Create a redirect which includes a query string
        redirect_with_query_string = models.Redirect(
            old_path='/redirectme?foo=Bar',
            redirect_link='/with-query-string-only')
        redirect_with_query_string.save()

        # ... and another redirect without the query string
        redirect_without_query_string = models.Redirect(
            old_path='/redirectme', redirect_link='/without-query-string')
        redirect_without_query_string.save()

        # Navigate to the redirect with the query string
        r_matching_qs = self.client.get('/redirectme/?foo=Bar')
        self.assertRedirects(r_matching_qs,
                             '/with-query-string-only',
                             status_code=301,
                             fetch_redirect_response=False)

        # Navigate to the redirect with a different query string
        # This should strip out the query string and match redirect_without_query_string
        r_no_qs = self.client.get('/redirectme/?utm_source=irrelevant')
        self.assertRedirects(r_no_qs,
                             '/without-query-string',
                             status_code=301,
                             fetch_redirect_response=False)
    def setUp(self):
        # Create a redirect to edit
        self.redirect = models.Redirect(old_path='/test', redirect_link='http://www.test.com/')
        self.redirect.save()

        # Login
        self.login()
    def test_redirect_with_encoded_url(self):
        redirect = models.Redirect(old_path='/t%C3%A9sting-%C3%BCnicode', redirect_link='/redirectto')
        redirect.save()

        # Navigate to it
        response = self.client.get('/t%C3%A9sting-%C3%BCnicode/')

        self.assertRedirects(response, '/redirectto', status_code=301, fetch_redirect_response=False)
Exemple #4
0
    def setUp(self):
        # Create a redirect to edit
        self.redirect = models.Redirect(old_path="/test",
                                        redirect_link="http://www.test.com/")
        self.redirect.save()

        # Login
        self.user = self.login()
    def test_basic_redirect(self):
        # Create a redirect
        redirect = models.Redirect(old_path='/redirectme', redirect_link='/redirectto')
        redirect.save()

        # Navigate to it
        response = self.client.get('/redirectme/')

        # Check that we were redirected
        self.assertRedirects(response, '/redirectto', status_code=301, fetch_redirect_response=False)
    def test_temporary_redirect(self):
        # Create a redirect
        redirect = models.Redirect(old_path='/redirectme', redirect_link='/redirectto', is_permanent=False)
        redirect.save()

        # Navigate to it
        response = self.client.get('/redirectme/')

        # Check that we were redirected temporarily
        self.assertRedirects(response, '/redirectto', status_code=302, fetch_redirect_response=False)
Exemple #7
0
    def test_redirect_with_unicode_in_url(self):
        redirect = models.Redirect(
            old_path="/tésting-ünicode", redirect_link="/redirectto"
        )
        redirect.save()

        # Navigate to it
        response = self.client.get("/tésting-ünicode/")

        self.assertRedirects(
            response, "/redirectto", status_code=301, fetch_redirect_response=False
        )