Mark cppcheck executable.
[darkhttpd] / devel / test_forward.py
1 #!/usr/bin/env python
2 # This is run by the "cover" script.
3 import unittest
4 from test import TestHelper, Conn, parse
5
6 class TestForward(TestHelper):
7 def test_forward_root(self):
8 resp = Conn().get("/", req_hdrs = { "Host": "example.com" })
9 status, hdrs, body = parse(resp)
10 self.assertContains(status, "301 Moved Permanently")
11 expect = "http://www.example.com/"
12 self.assertEquals(hdrs["Location"], expect)
13 self.assertContains(body, expect)
14
15 def test_forward_relative(self):
16 resp = Conn().get("/foo/bar",
17 req_hdrs = { "Host": "secure.example.com" })
18 status, hdrs, body = parse(resp)
19 self.assertContains(status, "301 Moved Permanently")
20 expect = "https://www.example.com/secure/foo/bar"
21 self.assertEquals(hdrs["Location"], expect)
22 self.assertContains(body, expect)
23
24 if __name__ == '__main__':
25 unittest.main()
26
27 # vim:set ts=4 sw=4 et: