witten
/
luminotes
Archived
1
0
Fork 0

Updated unit tests for redirect upon non-http / request when logged in.

Also updated INSTALL with info about Apache configuration.
This commit is contained in:
Dan Helfman 2007-08-03 19:43:16 +00:00
parent ccb81d18ee
commit 4356336f6b
3 changed files with 36 additions and 9 deletions

20
INSTALL
View File

@ -46,18 +46,26 @@ Then you'll need to configure your web server to forward requests for
non-static pages to CherryPy. These instructions are for Apache, but in
theory, Luminotes should work with just about any web server.
In your Apache configuration file, enable mod_rewrite and add the following
rewrite rules:
In your Apache configuration file, enable mod_rewrite and mod_proxy, then add
the following rewrite rules to the settings for your VirtualHost:
RewriteEngine on
RewriteRule ^/favicon.ico /path/to/luminotes/static/images/favicon.ico [L]
RewriteRule ^/static/(.*) /path/to/luminotes/static/$1 [L]
RewriteRule ^(.*) http://127.0.0.1:8081$1 [P]
You should change the paths to point to wherever Luminotes happens to be
installed. These rules cause Apache to serve static files itself, while
passing through requests for dynamic pages to the CherryPy web server running
locally.
You should change the paths in the rules above to point to wherever Luminotes
happens to be installed. These rules cause Apache to serve static files
itself, while passing through requests for dynamic pages to the CherryPy web
server running locally.
If you want to use SSL, add these same rules to the settings for your
SSL-enabled VirtualHost as well, but change the IP in the last rule from
127.0.0.1 to 127.0.0.2. This hack allows the Luminotes server to distinguish
between SSL and non-SSL requests by looking at the proxy IP. Without this,
Luminotes would have no way of knowing whether a particular request was
encrypted when received by Apache. (There are ways to do this in a less hacky
manner with Apache 2, but not Apache 1.)
To actually start the production mode server, run:

View File

@ -17,6 +17,8 @@ class Test_controller( object ):
u"global": {
u"luminotes.http_url" : u"http://luminotes.com",
u"luminotes.https_url" : u"https://luminotes.com",
u"luminotes.http_proxy_ip" : u"127.0.0.1",
u"luminotes.https_proxy_ip" : u"127.0.0.2",
},
}
@ -34,7 +36,7 @@ class Test_controller( object ):
cherrypy.server.stop()
self.scheduler.shutdown()
def http_get( self, http_path, headers = None, session_id = None):
def http_get( self, http_path, headers = None, session_id = None, pretend_https = False ):
"""
Perform an HTTP GET with the given path on the test server. Return the result dict as returned
by the invoked method.
@ -45,7 +47,12 @@ class Test_controller( object ):
if session_id:
headers.append( ( u"Cookie", "session_id=%s" % session_id ) ) # will break if unicode is used for the value
request = cherrypy.server.request( u"127.0.0.1", u"127.0.0.5" )
if pretend_https:
proxy_ip = self.settings[ "global" ].get( u"luminotes.https_proxy_ip" )
else:
proxy_ip = self.settings[ "global" ].get( u"luminotes.http_proxy_ip" )
request = cherrypy.server.request( ( proxy_ip, 1234 ), u"127.0.0.5" )
response = request.run( "GET %s HTTP/1.0" % http_path, headers = headers, rfile = StringIO() )
session_id = response.simple_cookie.get( u"session_id" )
if session_id: session_id = session_id.value
@ -84,7 +91,7 @@ class Test_controller( object ):
if session_id:
headers.append( ( u"Cookie", "session_id=%s" % session_id ) ) # will break if unicode is used for the value
request = cherrypy.server.request( u"127.0.0.1", u"127.0.0.5" )
request = cherrypy.server.request( ( u"127.0.0.1", 1234 ), u"127.0.0.5" )
response = request.run( "POST %s HTTP/1.0" % http_path, headers = headers, rfile = StringIO( post_data ) )
session_id = response.simple_cookie.get( u"session_id" )
if session_id: session_id = session_id.value

View File

@ -38,6 +38,18 @@ class Test_root( Test_controller ):
assert result.get( u"redirect" )
assert result.get( u"redirect" ).startswith( self.settings[ u"global" ][ u"luminotes.https_url" ] )
def test_index_with_https_after_login( self ):
self.login()
result = self.http_get(
"/",
session_id = self.session_id,
pretend_https = True,
)
assert result
assert result.get( u"redirect" ) is None
def test_next_id( self ):
result = self.http_get( "/next_id" )