Changeset 61
- Timestamp:
- 03/13/07 00:36:57
- Files:
-
- AuthKit/branches/0.4/AuthKit.egg-info/SOURCES.txt (modified) (1 diff)
- AuthKit/branches/0.4/AuthKit.egg-info/requires.txt (modified) (3 diffs)
- AuthKit/branches/0.4/authkit/authenticate/__init__.py (modified) (5 diffs)
- AuthKit/branches/0.4/authkit/authenticate/auth_tkt.py (modified) (1 diff)
- AuthKit/branches/0.4/authkit/authenticate/form.py (modified) (4 diffs)
- AuthKit/branches/0.4/authkit/authenticate/redirect.py (modified) (1 diff)
- AuthKit/branches/0.4/authkit/authorize.py (modified) (2 diffs)
- AuthKit/branches/0.4/authkit/permissions.py (modified) (1 diff)
- AuthKit/branches/0.4/examples/docs/AuthKit.egg-info (deleted)
- AuthKit/branches/0.4/examples/docs/basic.py (modified) (3 diffs)
- AuthKit/branches/0.4/examples/docs/digest.py (modified) (2 diffs)
- AuthKit/branches/0.4/examples/docs/form.py (modified) (2 diffs)
- AuthKit/branches/0.4/examples/docs/forward.py (modified) (4 diffs)
- AuthKit/branches/0.4/examples/docs/index.html (deleted)
- AuthKit/branches/0.4/examples/docs/passurl.py (modified) (2 diffs)
- AuthKit/branches/0.4/examples/docs/redirect.py (modified) (1 diff)
- AuthKit/branches/0.4/setup.py (modified) (1 diff)
- AuthKit/branches/0.4/test/test.ini (deleted)
- AuthKit/branches/0.4/test/test.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
AuthKit/branches/0.4/AuthKit.egg-info/SOURCES.txt
r59 r61 64 64 examples/docs/passurl.py 65 65 examples/docs/redirect.py 66 examples/pylons/AuthDemo/README.txt67 examples/pylons/AuthDemo/development.ini68 examples/pylons/AuthDemo/setup.cfg69 examples/pylons/AuthDemo/setup.py70 examples/pylons/AuthDemo/AuthDemo.egg-info/PKG-INFO71 examples/pylons/AuthDemo/AuthDemo.egg-info/SOURCES.txt72 examples/pylons/AuthDemo/AuthDemo.egg-info/dependency_links.txt73 examples/pylons/AuthDemo/AuthDemo.egg-info/entry_points.txt74 examples/pylons/AuthDemo/AuthDemo.egg-info/paste_deploy_config.ini_tmpl75 examples/pylons/AuthDemo/AuthDemo.egg-info/paster_plugins.txt76 examples/pylons/AuthDemo/AuthDemo.egg-info/requires.txt77 examples/pylons/AuthDemo/AuthDemo.egg-info/top_level.txt78 examples/pylons/AuthDemo/authdemo/__init__.py79 examples/pylons/AuthDemo/authdemo/websetup.py80 examples/pylons/AuthDemo/authdemo/config/__init__.py81 examples/pylons/AuthDemo/authdemo/config/environment.py82 examples/pylons/AuthDemo/authdemo/config/middleware.py83 examples/pylons/AuthDemo/authdemo/config/routing.py84 examples/pylons/AuthDemo/authdemo/controllers/__init__.py85 examples/pylons/AuthDemo/authdemo/controllers/account.py86 examples/pylons/AuthDemo/authdemo/controllers/error.py87 examples/pylons/AuthDemo/authdemo/controllers/hello.py88 examples/pylons/AuthDemo/authdemo/controllers/template.py89 examples/pylons/AuthDemo/authdemo/docs/index.txt90 examples/pylons/AuthDemo/authdemo/i18n/__init__.py91 examples/pylons/AuthDemo/authdemo/lib/__init__.py92 examples/pylons/AuthDemo/authdemo/lib/app_globals.py93 examples/pylons/AuthDemo/authdemo/lib/base.py94 examples/pylons/AuthDemo/authdemo/lib/database.py95 examples/pylons/AuthDemo/authdemo/lib/helpers.py96 examples/pylons/AuthDemo/authdemo/models/__init__.py97 examples/pylons/AuthDemo/authdemo/models/forms/__init__.py98 examples/pylons/AuthDemo/authdemo/models/forms/build.py99 examples/pylons/AuthDemo/authdemo/models/forms/schema.py100 examples/pylons/AuthDemo/authdemo/public/assets/bad.gif101 examples/pylons/AuthDemo/authdemo/public/assets/good.gif102 examples/pylons/AuthDemo/authdemo/public/assets/loading.gif103 examples/pylons/AuthDemo/authdemo/public/assets/passurl_icon.png104 examples/pylons/AuthDemo/authdemo/public/script/signup.js105 examples/pylons/AuthDemo/authdemo/public/script/MochiKit/MochiKit.js106 examples/pylons/AuthDemo/authdemo/public/script/MochiKit/__package__.js107 examples/pylons/AuthDemo/authdemo/public/style/default.css108 examples/pylons/AuthDemo/authdemo/templates/autohandler109 examples/pylons/AuthDemo/authdemo/templates/home.myt110 examples/pylons/AuthDemo/authdemo/templates/authkit/alreadyout.myt111 examples/pylons/AuthDemo/authdemo/templates/authkit/autohandler112 examples/pylons/AuthDemo/authdemo/templates/authkit/change_password.myt113 examples/pylons/AuthDemo/authdemo/templates/authkit/confirm.myt114 examples/pylons/AuthDemo/authdemo/templates/authkit/email_confirm_msg.myt115 examples/pylons/AuthDemo/authdemo/templates/authkit/email_password_reminder_msg.myt116 examples/pylons/AuthDemo/authdemo/templates/authkit/field_layout.myc117 examples/pylons/AuthDemo/authdemo/templates/authkit/index.myt118 examples/pylons/AuthDemo/authdemo/templates/authkit/list_personas.myt119 examples/pylons/AuthDemo/authdemo/templates/authkit/new_email_sent.myt120 examples/pylons/AuthDemo/authdemo/templates/authkit/password_reminder.myt121 examples/pylons/AuthDemo/authdemo/templates/authkit/password_reminder_sent.myt122 examples/pylons/AuthDemo/authdemo/templates/authkit/policy.myt123 examples/pylons/AuthDemo/authdemo/templates/authkit/redirect.myt124 examples/pylons/AuthDemo/authdemo/templates/authkit/register_new_email.myt125 examples/pylons/AuthDemo/authdemo/templates/authkit/registration_sent.myt126 examples/pylons/AuthDemo/authdemo/templates/authkit/reminder_sent.myt127 examples/pylons/AuthDemo/authdemo/templates/authkit/signedout.myt128 examples/pylons/AuthDemo/authdemo/templates/authkit/signin.myt129 examples/pylons/AuthDemo/authdemo/templates/authkit/signup.myt130 examples/pylons/AuthDemo/authdemo/templates/authkit/sites.myt131 examples/pylons/AuthDemo/authdemo/templates/authkit/update_details.myt132 examples/pylons/AuthDemo/authdemo/templates/authkit/update_persona.myt133 examples/pylons/AuthDemo/authdemo/templates/authkit/verify.myt134 examples/pylons/AuthDemo/authdemo/templates/openid/consumer/autohandler135 examples/pylons/AuthDemo/authdemo/templates/openid/consumer/content.myt136 examples/pylons/AuthDemo/authdemo/tests/__init__.py137 examples/pylons/AuthDemo/authdemo/tests/test_models.py138 examples/pylons/AuthDemo/authdemo/tests/functional/__init__.py139 examples/pylons/PassURLConsumer/README.txt140 examples/pylons/PassURLConsumer/development.ini141 examples/pylons/PassURLConsumer/setup.cfg142 examples/pylons/PassURLConsumer/setup.py143 examples/pylons/PassURLConsumer/PassURLConsumer.egg-info/PKG-INFO144 examples/pylons/PassURLConsumer/PassURLConsumer.egg-info/SOURCES.txt145 examples/pylons/PassURLConsumer/PassURLConsumer.egg-info/dependency_links.txt146 examples/pylons/PassURLConsumer/PassURLConsumer.egg-info/entry_points.txt147 examples/pylons/PassURLConsumer/PassURLConsumer.egg-info/paste_deploy_config.ini_tmpl148 examples/pylons/PassURLConsumer/PassURLConsumer.egg-info/paster_plugins.txt149 examples/pylons/PassURLConsumer/PassURLConsumer.egg-info/requires.txt150 examples/pylons/PassURLConsumer/PassURLConsumer.egg-info/top_level.txt151 examples/pylons/PassURLConsumer/passurlconsumer/__init__.py152 examples/pylons/PassURLConsumer/passurlconsumer/websetup.py153 examples/pylons/PassURLConsumer/passurlconsumer/config/__init__.py154 examples/pylons/PassURLConsumer/passurlconsumer/config/environment.py155 examples/pylons/PassURLConsumer/passurlconsumer/config/middleware.py156 examples/pylons/PassURLConsumer/passurlconsumer/config/routing.py157 examples/pylons/PassURLConsumer/passurlconsumer/controllers/__init__.py158 examples/pylons/PassURLConsumer/passurlconsumer/controllers/error.py159 examples/pylons/PassURLConsumer/passurlconsumer/controllers/openid_consumer.py160 examples/pylons/PassURLConsumer/passurlconsumer/controllers/template.py161 examples/pylons/PassURLConsumer/passurlconsumer/docs/index.txt162 examples/pylons/PassURLConsumer/passurlconsumer/i18n/__init__.py163 examples/pylons/PassURLConsumer/passurlconsumer/lib/__init__.py164 examples/pylons/PassURLConsumer/passurlconsumer/lib/app_globals.py165 examples/pylons/PassURLConsumer/passurlconsumer/lib/base.py166 examples/pylons/PassURLConsumer/passurlconsumer/lib/helpers.py167 examples/pylons/PassURLConsumer/passurlconsumer/models/__init__.py168 examples/pylons/PassURLConsumer/passurlconsumer/public/index.html169 examples/pylons/PassURLConsumer/passurlconsumer/templates/autohandler170 examples/pylons/PassURLConsumer/passurlconsumer/templates/openid/autohandler171 examples/pylons/PassURLConsumer/passurlconsumer/templates/openid/content.myt172 examples/pylons/PassURLConsumer/passurlconsumer/tests/__init__.py173 examples/pylons/PassURLConsumer/passurlconsumer/tests/test_models.py174 examples/pylons/PassURLConsumer/passurlconsumer/tests/functional/__init__.py175 66 ez_setup/README.txt 176 67 ez_setup/__init__.py 177 test/test.ini178 68 test/test.py AuthKit/branches/0.4/AuthKit.egg-info/requires.txt
r59 r61 1 Paste>=1.1 2 PasteDeploy>=1.1 1 Paste>=1.3,<=1.4 2 nose>=0.9.2,<=1.0 3 PasteDeploy>=1.1,<=1.4 3 4 python-openid>=1.1,<=1.2 4 python-yadis==1.0.1 5 python-urljr==1.0.0 6 elementtree>=1.2 7 8 [beaker] 9 Beaker 5 python-yadis==1.0.1,<=1.1 6 python-urljr==1.0.0,<=1.1 7 elementtree>=1.2,<=1.3 8 beaker>=0.6.2,<0.7 10 9 11 10 [pudge] … … 15 14 16 15 [full] 17 Pylons>=0.9 18 SQLAlchemy>=0.3.2 19 DBUtils>=0.9.2 20 Beaker 16 Pylons>=0.9,<=1.0 17 SQLAlchemy>=0.3.2,<=0.4 18 DBUtils>=0.9.2,<=1.0 21 19 pudge==dev 22 20 buildutils==dev … … 24 22 25 23 [pylons] 26 Pylons>=0.9 24 Pylons>=0.9,<=1.0 27 25 28 26 [mysql] 29 SQLAlchemy>=0.3.2 30 DBUtils>=0.9.2 27 SQLAlchemy>=0.3.2,<=0.4 28 DBUtils>=0.9.2,<=1.0 AuthKit/branches/0.4/authkit/authenticate/__init__.py
r60 r61 44 44 from pkg_resources import iter_entry_points, load_entry_point 45 45 from paste.deploy.converters import asbool 46 from paste.httpexceptions import HTTPExceptionHandler 46 47 47 48 # … … 535 536 536 537 # 538 # Setup the httpexceptions middleware 539 # 540 541 # class AddHTTPExceptionMiddleware: 542 # def __init__(self, app): 543 # self.app = app 544 # def __call__(self, environ, start_response): 545 # if not environ.has_key("paste.expected_exceptions"): 546 # self.app = HTTPExceptionHandler(self.app) 547 # return self.app(environ, start_response) 548 549 app = HTTPExceptionHandler(app) 550 551 552 # 537 553 # Configure the config files 538 554 # … … 721 737 raise NotImplementedError('No %r method has been implemented'%method) 722 738 723 from authkit.authorize import authorize 724 725 def test_app(environ, start_response): 739 from authkit.authorize import authorize_request 740 from authkit.permissions import RemoteUser 741 742 def sample_app(environ, start_response): 726 743 """ 727 744 A sample WSGI application that returns a 401 status code when the path … … 739 756 """ 740 757 if environ['PATH_INFO']=='/private': 741 authorize (environ, RemoteUser())758 authorize_request(environ, RemoteUser()) 742 759 if environ['PATH_INFO'] == '/signout': 743 760 start_response('200 OK', [('Content-type', 'text/plain')]) … … 751 768 else: 752 769 start_response('200 OK', [('Content-type', 'text/plain')]) 753 return ['You Have Access To This Page.\n\nHere is the environment...\n\n%s: %s\n'%(k,v) for k,v in environ.items()] 754 770 result = ['You Have Access To This Page.\n\nHere is the environment...\n\n'] 771 for k,v in environ.items(): 772 result.append('%s: %s\n'%(k,v)) 773 return result 774 AuthKit/branches/0.4/authkit/authenticate/auth_tkt.py
r59 r61 294 294 cookie_value = '' 295 295 log.debug("Our cookie %r value is therefore %r", self.cookie_name, cookie_value) 296 remote_addr = environ.get('HTTP_X_FORWARDED_FOR', environ ['REMOTE_ADDR'])296 remote_addr = environ.get('HTTP_X_FORWARDED_FOR', environ.get('REMOTE_ADDR','0.0.0.0')) 297 297 log.debug("Remote addr %r, value %r, include_ip %r", remote_addr, cookie_value, self.include_ip) 298 298 AuthKit/branches/0.4/authkit/authenticate/form.py
r59 r61 14 14 template = """\ 15 15 <html> 16 <head><title>Please Login!</title></head>16 <head><title>Please Sign In</title></head> 17 17 <body> 18 <h1>Please Login</h1>18 <h1>Please Sign In</h1> 19 19 <form action="%s" method="post"> 20 20 <dl> … … 62 62 63 63 content = self.template % construct_url(environ) 64 start_response(" 200 OK",[('Content-Type', 'text/html'),64 start_response("401 Unauthorized",[('Content-Type', 'text/html'), 65 65 ('Content-Length', str(len(content)))]) 66 66 return [content] … … 76 76 app, 77 77 'paste.auth_tkt.set_user', 78 missing_error='Missing the key %(key)s from the environ. Have you added the cookie method after the form method?') 78 missing_error='Missing the key %(key)s from the environ. Have you added the cookie method after the form method?' 79 ) 79 80 80 81 template_conf = strip_base(auth_conf, 'template.') … … 95 96 return app 96 97 97 if __name__ == 'main':98 from paste.httpserver import serve99 from authkit.authenticate import middleware, test_app100 101 app = middleware(102 test_app,103 method='new_form',104 cookie_secret='secret encryption string',105 users_setup = """106 Username1:password1107 username2:password2108 """,109 cookie_signout = '/signout',110 custom_methods = {111 'new_form': make_new_form_middleware112 },113 new_form_option = 'Just an example!',114 )115 serve(app, host='0.0.0.0', port=8080)116 AuthKit/branches/0.4/authkit/authenticate/redirect.py
r59 r61 1 from authkit.authenticate import middleware , test_app1 from authkit.authenticate import middleware 2 2 from authkit.authenticate.multi import MultiHandler, status_checker 3 3 AuthKit/branches/0.4/authkit/authorize.py
r60 r61 25 25 26 26 from paste import httpexceptions 27 from authkit.permissions import PermissionSetupError 28 from authkit.authorize import NotAuthenticatedError, NotAuthorizedError 27 #from authkit.permissions import NotAuthenticatedError, NotAuthorizedError 28 29 class PermissionSetupError(Exception): 30 pass 29 31 30 32 # … … 164 166 'Try using the authkit.authorize.middleware or the authorize decorator.' 165 167 ) 166 if permission.require_response: 168 #if permission.require_response: 169 # raise error 170 #else: 171 try: 172 def dummy_app(environ, start_response): 173 if not start_response == _PermissionStartResponse: 174 raise _FiddledWith('Fiddled with start_response %r'%start_response) 175 start_response( 176 '1000 Test Response For Permissions Check', 177 [('Content-type','text/plain')] 178 ) 179 return _PermissionList('''Dummy response from permission check.''') 180 181 if not isinstance( 182 permission.check( 183 dummy_app, 184 environ, 185 _PermissionStartResponse 186 ), 187 _PermissionList 188 ): 189 raise _FiddledWith('Fiddled with response') 190 except _FiddledWith: 167 191 raise error 168 else:169 try:170 def dummy_app(environ, start_response):171 if not start_response == _PermissionStartResponse:172 raise _FiddledWith('Fiddled with start_response %r'%start_response)173 start_response(174 '1000 Test Response For Permissions Check',175 [('Content-type','text/plain')]176 )177 return _PermissionList('''Dummy response from permission check.''')178 179 if not isinstance(180 permission.check(181 dummy_app,182 environ,183 _PermissionStartResponse184 ),185 _PermissionList186 ):187 raise _FiddledWith('Fiddled with response')188 except _FiddledWith:189 raise error190 192 191 193 def authorized(environ, permission): AuthKit/branches/0.4/authkit/permissions.py
r60 r61 31 31 # 32 32 33 class PermissionSetupError(Exception):34 pass35 33 36 34 class Permission: AuthKit/branches/0.4/examples/docs/basic.py
r59 r61 1 from authkit.authenticate import middleware, test_app 2 1 from authkit.authenticate import middleware, sample_app 3 2 4 3 def valid(environ, username, password): … … 6 5 7 6 app = middleware( 8 test_app,7 sample_app, 9 8 setup_method='basic', 10 9 basic_realm='Test Realm', … … 12 11 ) 13 12 14 from paste.httpserver import serve 15 serve(app, host='0.0.0.0', port=8080) 13 if __name__ == '__main__': 14 from paste.httpserver import serve 15 serve(app, host='0.0.0.0', port=8080) 16 AuthKit/branches/0.4/examples/docs/digest.py
r59 r61 1 from authkit.authenticate import middleware, test_app1 from authkit.authenticate import middleware, sample_app 2 2 from authkit.authenticate.digest import digest_password 3 3 … … 7 7 8 8 app = middleware( 9 test_app,10 setup_method='digest', 11 digest_realm='Test Realm', 9 sample_app, 10 setup_method='digest', 11 digest_realm='Test Realm', 12 12 digest_authenticate_function=digest 13 13 ) 14 14 15 from paste.httpserver import serve 16 serve(app, host='0.0.0.0', port=8080) 15 if __name__ == '__main__': 16 from paste.httpserver import serve 17 serve(app, host='0.0.0.0', port=8080) 18 AuthKit/branches/0.4/examples/docs/form.py
r59 r61 1 from paste.httpserver import serve 2 from authkit.authenticate import middleware, test_app 1 from authkit.authenticate import middleware, sample_app 3 2 4 3 app = middleware( 5 test_app,4 sample_app, 6 5 setup_method='form,cookie', 7 6 cookie_secret='secret encryption string', … … 13 12 #cookie_params_name = 'test' 14 13 ) 15 serve(app, host='0.0.0.0', port=8080) 14 15 if __name__ == '__main__': 16 from paste.httpserver import serve 17 serve(app, host='0.0.0.0', port=8080) 18 AuthKit/branches/0.4/examples/docs/forward.py
r59 r61 1 def test_app(environ, start_response): 1 from authkit.authenticate import middleware 2 3 def sample_app(environ, start_response): 2 4 """ 3 5 A sample WSGI application that returns a 401 status code when the path … … 36 38 """ 37 39 if not environ.get('QUERY_STRING'): 38 start_response('200 OK', [('Content-type', 'text/html')]) 39 return [page%'<p>Please sign in</p>'] 40 start_response( 41 '200 Sign in required', 42 [('Content-type', 'text/html')] 43 ) 44 return [page%'<p>Please Sign In</p>'] 40 45 else: 41 46 # Quick and dirty sign in check, do it properly in your code … … 52 57 53 58 start_response('200 OK', [('Content-type', 'text/plain')]) 54 return ['%s: %s\n'%(k,v) for k,v in environ.items()] 55 56 from paste.httpserver import serve 57 from authkit.authenticate import middleware, digest 59 result = ['You Have Access To This Page.\n\nHere is the environment...\n\n'] 60 for k,v in environ.items(): 61 result.append('%s: %s\n'%(k,v)) 62 return result 63 58 64 59 65 app = middleware( 60 test_app,66 sample_app, 61 67 setup_method='forward,cookie', 62 68 forward_internalpath = '/signin', … … 64 70 cookie_secret = 'somesecret', 65 71 ) 66 serve(app, host='0.0.0.0', port=8080) 72 73 if __name__ == '__main__': 74 from paste.httpserver import serve 75 serve(app, host='0.0.0.0', port=8080) 76 AuthKit/branches/0.4/examples/docs/passurl.py
r59 r61 1 from paste.httpserver import serve 2 from authkit.authenticate import middleware, test_app 1 from authkit.authenticate import middleware, sample_app 3 2 4 3 app = middleware( 5 test_app,4 sample_app, 6 5 setup_method='passurl,cookie', 7 6 passurl_path_signedin='/private', … … 12 11 ) 13 12 14 serve(app, host='0.0.0.0', port=8080) 13 if __name__ == '__main__': 14 from paste.httpserver import serve 15 serve(app, host='0.0.0.0', port=8080) AuthKit/branches/0.4/examples/docs/redirect.py
r59 r61 1 from paste.httpserver import serve 2 from authkit.authenticate import middleware, test_app 1 from authkit.authenticate import middleware, sample_app 3 2 4 3 app = middleware( 5 test_app,4 sample_app, 6 5 setup_method='redirect,cookie', 7 redirect_url='http:// google.com',6 redirect_url='http://3aims.com', 8 7 cookie_secret='asdasd' 9 8 ) 10 11 serve(app, host='0.0.0.0', port=8080) 9 if __name__ == '__main__': 10 from paste.httpserver import serve 11 serve(app, host='0.0.0.0', port=8080) AuthKit/branches/0.4/setup.py
r59 r61 65 65 include_package_data=True, 66 66 zip_safe=False, 67 test_suite = 'nose.collector', 67 68 install_requires = [ 68 "Paste>=1.1", 69 "PasteDeploy>=1.1", 69 "Paste>=1.3,<=1.4", 70 "nose>=0.9.2,<=1.0", 71 "PasteDeploy>=1.1,<=1.4", 70 72 "python-openid>=1.1,<=1.2", 71 "python-yadis==1.0.1", 72 "python-urljr==1.0.0", 73 "elementtree>=1.2" 73 "python-yadis==1.0.1,<=1.1", 74 "python-urljr==1.0.0,<=1.1", 75 "elementtree>=1.2,<=1.3", 76 "beaker>=0.6.2,<0.7", 74 77 ], 75 78 extras_require = { 76 'pylons': ["Pylons>=0.9"], 77 'mysql': ["SQLAlchemy>=0.3.2", "DBUtils>=0.9.2"], 78 'beaker': ["Beaker"], 79 'full': ["Pylons>=0.9", "SQLAlchemy>=0.3.2", "DBUtils>=0.9.2", "Beaker", "pudge==dev", "buildutils==dev", "pygments==0.6"], 79 'pylons': ["Pylons>=0.9,<=1.0"], 80 'mysql': ["SQLAlchemy>=0.3.2,<=0.4", "DBUtils>=0.9.2,<=1.0"], 81 'full': ["Pylons>=0.9,<=1.0", "SQLAlchemy>=0.3.2,<=0.4", "DBUtils>=0.9.2,<=1.0", "pudge==dev", "buildutils==dev", "pygments==0.6"], 80 82 'pudge': ["pudge==dev", "buildutils==dev", "pygments==0.6"], 81 83 }, AuthKit/branches/0.4/test/test.py
r60 r61 1 from authkit.authenticate import middleware, test_app 1 """ 2 Very basic tests which so no more than check each of the authentication 3 methods to ensure that an unprotected page is accessible and that a 4 protected page triggers the a sign in. 5 6 Note: Should the Form and Forward methods return 401 or 200 when they 7 generate an HTML page for the user to sign in? 8 """ 9 10 import sys 11 import os 12 13 from authkit.authenticate import middleware, sample_app 2 14 from paste.fixture import * 3 15 4 def simple_app(environ, start_response): 5 return test_app(environ, start_response) 16 sys.path.append(os.getcwd()+'/examples/docs') 17 18 from form import app as form_app 19 from basic import app as basic_app 20 from digest import app as digest_app 21 from forward import app as forward_app 22 from passurl import app as passurl_app 23 from redirect import app as redirect_app 24 25 def assertEqual(a,b): 26 if a != b: 27 raise AssertionError('%s != %s'%(a,b)) 28 29 apps = [ 30 form_app, 31 basic_app, 32 digest_app, 33 forward_app, 34 passurl_app, 35 redirect_app, 36 ] 6 37 7 38 def test_ok(): 8 app = TestApp(simple_app)9 res = app.get('')10 assert res.header('content-type') == 'text/plain'11 assert res.full_status == '200 OK'12 assert 'signed in' in res39 for app in apps: 40 res = TestApp(app).get('') 41 assertEqual(res.header('content-type'), 'text/plain') 42 assertEqual(res.full_status, '200 OK') 43 assert 'You Have Access To This Page.' in res 13 44 45 def test_fail(): 46 for app in [basic_app, digest_app]: 47 res = TestApp(app).get('/private', status=401) 48 assertEqual(res.header('content-type'),'text/plain') 49 assertEqual(res.full_status, '401 Unauthorized') 50 #raise Exception(res) 51 assert 'This server could not verify that you are' in res 52 53 def test_form_fail(): 54 res = TestApp(form_app).get('/private', status=401) 55 assertEqual(res.header('content-type'),'text/html') 56 assertEqual(res.full_status, '401 Unauthorized') 57 assert 'Please Sign In' in res 58 59 def test_forward_fail(): 60 res = TestApp(forward_app).get('/private') 61 assertEqual(res.header('content-type'),'text/html') 62 # XXX Not sure about this but using a 401 triggers an infinite loop 63 # of redirects. 64 assertEqual(res.full_status, '200 Sign in required') 65 assert 'Please Sign In' in res 66 67 def test_passurl_fail(): 68 res = TestApp(passurl_app).get('/private') 69 assertEqual(res.header('content-type'),'text/html') 70 assertEqual(res.full_status, '200 OK') 71 assert 'Please Sign In' in res 72 73 def test_redirect_fail(): 74 res = TestApp(redirect_app).get('/private', status=302) 75 assertEqual(res.header('Location'),'http://3aims.com') 76 assertEqual(res.full_status, '302 Found') 77 78
