PageRenderTime 26ms CodeModel.GetById 16ms RepoModel.GetById 0ms 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
Possible License(s): BSD-3-Clause
  1. from django.utils import http
  2. from django.utils import unittest
  3. class TestUtilsHttp(unittest.TestCase):
  4. def test_same_origin_true(self):
  5. # Identical
  6. self.assertTrue(http.same_origin('http://foo.com/', 'http://foo.com/'))
  7. # One with trailing slash - see #15617
  8. self.assertTrue(http.same_origin('http://foo.com', 'http://foo.com/'))
  9. self.assertTrue(http.same_origin('http://foo.com/', 'http://foo.com'))
  10. # With port
  11. self.assertTrue(http.same_origin('https://foo.com:8000', 'https://foo.com:8000/'))
  12. def test_same_origin_false(self):
  13. # Different scheme
  14. self.assertFalse(http.same_origin('http://foo.com', 'https://foo.com'))
  15. # Different host
  16. self.assertFalse(http.same_origin('http://foo.com', 'http://goo.com'))
  17. # Different host again
  18. self.assertFalse(http.same_origin('http://foo.com', 'http://foo.com.evil.com'))
  19. # Different port
  20. self.assertFalse(http.same_origin('http://foo.com:8000', 'http://foo.com:8001'))