]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Move AuthRedirectTest from httpserver_test to web_test where it belongs
authorBen Darnell <ben@bendarnell.com>
Wed, 25 Aug 2010 18:36:44 +0000 (11:36 -0700)
committerBen Darnell <ben@bendarnell.com>
Wed, 25 Aug 2010 18:36:44 +0000 (11:36 -0700)
tornado/test/httpserver_test.py
tornado/test/web_test.py

index ac7e5f5c80e447d1578774dcdc33a3aef35d7b2f..cf797093ad9d9501227f7f338ffe73d3154df04d 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 from tornado.testing import AsyncHTTPTestCase, LogTrapTestCase
-from tornado.web import authenticated, Application, RequestHandler
+from tornado.web import Application, RequestHandler
 import os
 import pycurl
 import re
@@ -12,41 +12,6 @@ class HelloWorldRequestHandler(RequestHandler):
     def get(self):
         self.finish("Hello world")
 
-class AuthRedirectRequestHandler(RequestHandler):
-    def initialize(self, login_url):
-        self.login_url = login_url
-
-    def get_login_url(self):
-        return self.login_url
-
-    @authenticated
-    def get(self):
-        # we'll never actually get here because the test doesn't follow redirects
-        self.send_error(500)
-
-class AuthRedirectTest(AsyncHTTPTestCase, LogTrapTestCase):
-    def get_app(self):
-        return Application([('/relative', AuthRedirectRequestHandler,
-                             dict(login_url='/login')),
-                            ('/absolute', AuthRedirectRequestHandler,
-                             dict(login_url='http://example.com/login'))])
-
-    def test_relative_auth_redirect(self):
-        self.http_client.fetch(self.get_url('/relative'), self.stop,
-                               follow_redirects=False)
-        response = self.wait()
-        self.assertEqual(response.code, 302)
-        self.assertEqual(response.headers['Location'], '/login?next=%2Frelative')
-
-    def test_absolute_auth_redirect(self):
-        self.http_client.fetch(self.get_url('/absolute'), self.stop,
-                               follow_redirects=False)
-        response = self.wait()
-        self.assertEqual(response.code, 302)
-        self.assertTrue(re.match(
-            'http://example.com/login\?next=http%3A%2F%2Flocalhost%3A[0-9]+%2Fabsolute',
-            response.headers['Location']), response.headers['Location'])
-
 class SSLTest(AsyncHTTPTestCase, LogTrapTestCase):
     def get_app(self):
         return Application([('/', HelloWorldRequestHandler)])
index a21c9ad7f6006ac56450636492ab8dd33fe61f7d..7f4a975d0c4d0070145fa011f0cfcb50f2ecf313 100644 (file)
@@ -1,5 +1,5 @@
-from tornado.testing import LogTrapTestCase
-from tornado.web import RequestHandler, _O
+from tornado.testing import LogTrapTestCase, AsyncHTTPTestCase
+from tornado.web import RequestHandler, _O, authenticated, Application
 
 import logging
 import re
@@ -43,3 +43,39 @@ class SecureCookieTest(LogTrapTestCase):
         handler._cookies['foo'] = '1234|5678%s|%s' % (timestamp, sig)
         # it gets rejected
         assert handler.get_secure_cookie('foo') is None
+
+
+class AuthRedirectRequestHandler(RequestHandler):
+    def initialize(self, login_url):
+        self.login_url = login_url
+
+    def get_login_url(self):
+        return self.login_url
+
+    @authenticated
+    def get(self):
+        # we'll never actually get here because the test doesn't follow redirects
+        self.send_error(500)
+
+class AuthRedirectTest(AsyncHTTPTestCase, LogTrapTestCase):
+    def get_app(self):
+        return Application([('/relative', AuthRedirectRequestHandler,
+                             dict(login_url='/login')),
+                            ('/absolute', AuthRedirectRequestHandler,
+                             dict(login_url='http://example.com/login'))])
+
+    def test_relative_auth_redirect(self):
+        self.http_client.fetch(self.get_url('/relative'), self.stop,
+                               follow_redirects=False)
+        response = self.wait()
+        self.assertEqual(response.code, 302)
+        self.assertEqual(response.headers['Location'], '/login?next=%2Frelative')
+
+    def test_absolute_auth_redirect(self):
+        self.http_client.fetch(self.get_url('/absolute'), self.stop,
+                               follow_redirects=False)
+        response = self.wait()
+        self.assertEqual(response.code, 302)
+        self.assertTrue(re.match(
+            'http://example.com/login\?next=http%3A%2F%2Flocalhost%3A[0-9]+%2Fabsolute',
+            response.headers['Location']), response.headers['Location'])