Changeset 1910
- Timestamp:
- 03/07/08 16:19:28
- Files:
-
- trunk/cherrypy/test/test_static.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/test/test_static.py
r1839 r1910 25 25 return "This is a DYNAMIC page" 26 26 dynamic.exposed = True 27 28 27 28 29 cherrypy.config.update({'environment': 'test_suite'}) 30 29 31 root = Root() 30 32 root.static = Static() 31 33 32 conf = {34 rootconf = { 33 35 '/static': { 34 36 'tools.staticdir.on': True, … … 51 53 }, 52 54 } 55 rootApp = cherrypy.Application(root) 56 rootApp.merge(rootconf) 53 57 54 cherrypy.tree.mount(root, config=conf) 55 cherrypy.config.update({'environment': 'test_suite'}) 58 test_app_conf = { 59 '/test': { 60 'tools.staticdir.index': 'index.html', 61 'tools.staticdir.on': True, 62 'tools.staticdir.root': curdir, 63 'tools.staticdir.dir': 'static', 64 }, 65 } 66 testApp = cherrypy.Application(Static()) 67 testApp.merge(test_app_conf) 68 69 vhost = cherrypy._cpwsgi.VirtualHost(rootApp, {'virt.net': testApp}) 70 cherrypy.tree.graft(vhost) 71 56 72 57 73 def teardown_server(): … … 92 108 # we just check the content 93 109 self.assertMatchesBody('^Dummy stylesheet') 94 110 111 def test_fallthrough(self): 95 112 # Test that NotFound will then try dynamic handlers (see [878]). 96 113 self.getPage("/static/dynamic") … … 102 119 self.assertHeader('Content-Type', 'text/html') 103 120 self.assertBody('You want the Baron? You can have the Baron!') 104 121 122 def test_index(self): 105 123 # Check a directory via "staticdir.index". 106 124 self.getPage("/docroot/") … … 114 132 self.assertBody("This resource can be found at <a href='%s/docroot/'>" 115 133 "%s/docroot/</a>." % (self.base(), self.base())) 116 134 135 def test_config_errors(self): 117 136 # Check that we get an error if no .file or .dir 118 137 self.getPage("/error/thing.html") … … 120 139 self.assertInBody("TypeError: staticdir() takes at least 2 " 121 140 "arguments (0 given)") 122 141 142 def test_security(self): 123 143 # Test up-level security 124 144 self.getPage("/static/../../test/style.css") 125 145 self.assertStatus((400, 403)) 126 146 147 def test_modif(self): 127 148 # Test modified-since on a reasonably-large file 128 149 self.getPage("/static/dirback.jpg") … … 139 160 self.assertNoHeader("Content-Disposition") 140 161 self.assertBody("") 162 163 def test_755_vhost(self): 164 self.getPage("/test/", [('Host', 'virt.net')]) 165 self.assertStatus(200) 166 self.getPage("/test", [('Host', 'virt.net')]) 167 self.assertStatus((302, 303)) 168 self.assertHeader('Location', 'http://virt.net/test/') 141 169 142 170

