PageRenderTime 91ms CodeModel.GetById 88ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/regressiontests/utils/http.py

https://code.google.com/p/mango-py/
Python | 23 lines | 13 code | 3 blank | 7 comment | 0 complexity | aad4dd91c36019cd611bc66bca5b32a9 MD5 | raw file
 1from django.utils import http
 2from django.utils import unittest
 3
 4class TestUtilsHttp(unittest.TestCase):
 5
 6    def test_same_origin_true(self):
 7        # Identical
 8        self.assertTrue(http.same_origin('http://foo.com/', 'http://foo.com/'))
 9        # One with trailing slash - see #15617
10        self.assertTrue(http.same_origin('http://foo.com', 'http://foo.com/'))
11        self.assertTrue(http.same_origin('http://foo.com/', 'http://foo.com'))
12        # With port
13        self.assertTrue(http.same_origin('https://foo.com:8000', 'https://foo.com:8000/'))
14
15    def test_same_origin_false(self):
16        # Different scheme
17        self.assertFalse(http.same_origin('http://foo.com', 'https://foo.com'))
18        # Different host
19        self.assertFalse(http.same_origin('http://foo.com', 'http://goo.com'))
20        # Different host again
21        self.assertFalse(http.same_origin('http://foo.com', 'http://foo.com.evil.com'))
22        # Different port
23        self.assertFalse(http.same_origin('http://foo.com:8000', 'http://foo.com:8001'))