Changeset 61

Show
Ignore:
Timestamp:
03/13/07 00:36:57
Author:
thejimmyg
Message:

Fixed some bugs and introduced a basic test suite

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • AuthKit/branches/0.4/AuthKit.egg-info/SOURCES.txt

    r59 r61  
    6464examples/docs/passurl.py 
    6565examples/docs/redirect.py 
    66 examples/pylons/AuthDemo/README.txt 
    67 examples/pylons/AuthDemo/development.ini 
    68 examples/pylons/AuthDemo/setup.cfg 
    69 examples/pylons/AuthDemo/setup.py 
    70 examples/pylons/AuthDemo/AuthDemo.egg-info/PKG-INFO 
    71 examples/pylons/AuthDemo/AuthDemo.egg-info/SOURCES.txt 
    72 examples/pylons/AuthDemo/AuthDemo.egg-info/dependency_links.txt 
    73 examples/pylons/AuthDemo/AuthDemo.egg-info/entry_points.txt 
    74 examples/pylons/AuthDemo/AuthDemo.egg-info/paste_deploy_config.ini_tmpl 
    75 examples/pylons/AuthDemo/AuthDemo.egg-info/paster_plugins.txt 
    76 examples/pylons/AuthDemo/AuthDemo.egg-info/requires.txt 
    77 examples/pylons/AuthDemo/AuthDemo.egg-info/top_level.txt 
    78 examples/pylons/AuthDemo/authdemo/__init__.py 
    79 examples/pylons/AuthDemo/authdemo/websetup.py 
    80 examples/pylons/AuthDemo/authdemo/config/__init__.py 
    81 examples/pylons/AuthDemo/authdemo/config/environment.py 
    82 examples/pylons/AuthDemo/authdemo/config/middleware.py 
    83 examples/pylons/AuthDemo/authdemo/config/routing.py 
    84 examples/pylons/AuthDemo/authdemo/controllers/__init__.py 
    85 examples/pylons/AuthDemo/authdemo/controllers/account.py 
    86 examples/pylons/AuthDemo/authdemo/controllers/error.py 
    87 examples/pylons/AuthDemo/authdemo/controllers/hello.py 
    88 examples/pylons/AuthDemo/authdemo/controllers/template.py 
    89 examples/pylons/AuthDemo/authdemo/docs/index.txt 
    90 examples/pylons/AuthDemo/authdemo/i18n/__init__.py 
    91 examples/pylons/AuthDemo/authdemo/lib/__init__.py 
    92 examples/pylons/AuthDemo/authdemo/lib/app_globals.py 
    93 examples/pylons/AuthDemo/authdemo/lib/base.py 
    94 examples/pylons/AuthDemo/authdemo/lib/database.py 
    95 examples/pylons/AuthDemo/authdemo/lib/helpers.py 
    96 examples/pylons/AuthDemo/authdemo/models/__init__.py 
    97 examples/pylons/AuthDemo/authdemo/models/forms/__init__.py 
    98 examples/pylons/AuthDemo/authdemo/models/forms/build.py 
    99 examples/pylons/AuthDemo/authdemo/models/forms/schema.py 
    100 examples/pylons/AuthDemo/authdemo/public/assets/bad.gif 
    101 examples/pylons/AuthDemo/authdemo/public/assets/good.gif 
    102 examples/pylons/AuthDemo/authdemo/public/assets/loading.gif 
    103 examples/pylons/AuthDemo/authdemo/public/assets/passurl_icon.png 
    104 examples/pylons/AuthDemo/authdemo/public/script/signup.js 
    105 examples/pylons/AuthDemo/authdemo/public/script/MochiKit/MochiKit.js 
    106 examples/pylons/AuthDemo/authdemo/public/script/MochiKit/__package__.js 
    107 examples/pylons/AuthDemo/authdemo/public/style/default.css 
    108 examples/pylons/AuthDemo/authdemo/templates/autohandler 
    109 examples/pylons/AuthDemo/authdemo/templates/home.myt 
    110 examples/pylons/AuthDemo/authdemo/templates/authkit/alreadyout.myt 
    111 examples/pylons/AuthDemo/authdemo/templates/authkit/autohandler 
    112 examples/pylons/AuthDemo/authdemo/templates/authkit/change_password.myt 
    113 examples/pylons/AuthDemo/authdemo/templates/authkit/confirm.myt 
    114 examples/pylons/AuthDemo/authdemo/templates/authkit/email_confirm_msg.myt 
    115 examples/pylons/AuthDemo/authdemo/templates/authkit/email_password_reminder_msg.myt 
    116 examples/pylons/AuthDemo/authdemo/templates/authkit/field_layout.myc 
    117 examples/pylons/AuthDemo/authdemo/templates/authkit/index.myt 
    118 examples/pylons/AuthDemo/authdemo/templates/authkit/list_personas.myt 
    119 examples/pylons/AuthDemo/authdemo/templates/authkit/new_email_sent.myt 
    120 examples/pylons/AuthDemo/authdemo/templates/authkit/password_reminder.myt 
    121 examples/pylons/AuthDemo/authdemo/templates/authkit/password_reminder_sent.myt 
    122 examples/pylons/AuthDemo/authdemo/templates/authkit/policy.myt 
    123 examples/pylons/AuthDemo/authdemo/templates/authkit/redirect.myt 
    124 examples/pylons/AuthDemo/authdemo/templates/authkit/register_new_email.myt 
    125 examples/pylons/AuthDemo/authdemo/templates/authkit/registration_sent.myt 
    126 examples/pylons/AuthDemo/authdemo/templates/authkit/reminder_sent.myt 
    127 examples/pylons/AuthDemo/authdemo/templates/authkit/signedout.myt 
    128 examples/pylons/AuthDemo/authdemo/templates/authkit/signin.myt 
    129 examples/pylons/AuthDemo/authdemo/templates/authkit/signup.myt 
    130 examples/pylons/AuthDemo/authdemo/templates/authkit/sites.myt 
    131 examples/pylons/AuthDemo/authdemo/templates/authkit/update_details.myt 
    132 examples/pylons/AuthDemo/authdemo/templates/authkit/update_persona.myt 
    133 examples/pylons/AuthDemo/authdemo/templates/authkit/verify.myt 
    134 examples/pylons/AuthDemo/authdemo/templates/openid/consumer/autohandler 
    135 examples/pylons/AuthDemo/authdemo/templates/openid/consumer/content.myt 
    136 examples/pylons/AuthDemo/authdemo/tests/__init__.py 
    137 examples/pylons/AuthDemo/authdemo/tests/test_models.py 
    138 examples/pylons/AuthDemo/authdemo/tests/functional/__init__.py 
    139 examples/pylons/PassURLConsumer/README.txt 
    140 examples/pylons/PassURLConsumer/development.ini 
    141 examples/pylons/PassURLConsumer/setup.cfg 
    142 examples/pylons/PassURLConsumer/setup.py 
    143 examples/pylons/PassURLConsumer/PassURLConsumer.egg-info/PKG-INFO 
    144 examples/pylons/PassURLConsumer/PassURLConsumer.egg-info/SOURCES.txt 
    145 examples/pylons/PassURLConsumer/PassURLConsumer.egg-info/dependency_links.txt 
    146 examples/pylons/PassURLConsumer/PassURLConsumer.egg-info/entry_points.txt 
    147 examples/pylons/PassURLConsumer/PassURLConsumer.egg-info/paste_deploy_config.ini_tmpl 
    148 examples/pylons/PassURLConsumer/PassURLConsumer.egg-info/paster_plugins.txt 
    149 examples/pylons/PassURLConsumer/PassURLConsumer.egg-info/requires.txt 
    150 examples/pylons/PassURLConsumer/PassURLConsumer.egg-info/top_level.txt 
    151 examples/pylons/PassURLConsumer/passurlconsumer/__init__.py 
    152 examples/pylons/PassURLConsumer/passurlconsumer/websetup.py 
    153 examples/pylons/PassURLConsumer/passurlconsumer/config/__init__.py 
    154 examples/pylons/PassURLConsumer/passurlconsumer/config/environment.py 
    155 examples/pylons/PassURLConsumer/passurlconsumer/config/middleware.py 
    156 examples/pylons/PassURLConsumer/passurlconsumer/config/routing.py 
    157 examples/pylons/PassURLConsumer/passurlconsumer/controllers/__init__.py 
    158 examples/pylons/PassURLConsumer/passurlconsumer/controllers/error.py 
    159 examples/pylons/PassURLConsumer/passurlconsumer/controllers/openid_consumer.py 
    160 examples/pylons/PassURLConsumer/passurlconsumer/controllers/template.py 
    161 examples/pylons/PassURLConsumer/passurlconsumer/docs/index.txt 
    162 examples/pylons/PassURLConsumer/passurlconsumer/i18n/__init__.py 
    163 examples/pylons/PassURLConsumer/passurlconsumer/lib/__init__.py 
    164 examples/pylons/PassURLConsumer/passurlconsumer/lib/app_globals.py 
    165 examples/pylons/PassURLConsumer/passurlconsumer/lib/base.py 
    166 examples/pylons/PassURLConsumer/passurlconsumer/lib/helpers.py 
    167 examples/pylons/PassURLConsumer/passurlconsumer/models/__init__.py 
    168 examples/pylons/PassURLConsumer/passurlconsumer/public/index.html 
    169 examples/pylons/PassURLConsumer/passurlconsumer/templates/autohandler 
    170 examples/pylons/PassURLConsumer/passurlconsumer/templates/openid/autohandler 
    171 examples/pylons/PassURLConsumer/passurlconsumer/templates/openid/content.myt 
    172 examples/pylons/PassURLConsumer/passurlconsumer/tests/__init__.py 
    173 examples/pylons/PassURLConsumer/passurlconsumer/tests/test_models.py 
    174 examples/pylons/PassURLConsumer/passurlconsumer/tests/functional/__init__.py 
    17566ez_setup/README.txt 
    17667ez_setup/__init__.py 
    177 test/test.ini 
    17868test/test.py 
  • AuthKit/branches/0.4/AuthKit.egg-info/requires.txt

    r59 r61  
    1 Paste>=1.1 
    2 PasteDeploy>=1.1 
     1Paste>=1.3,<=1.4 
     2nose>=0.9.2,<=1.0 
     3PasteDeploy>=1.1,<=1.4 
    34python-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 
     5python-yadis==1.0.1,<=1.1 
     6python-urljr==1.0.0,<=1.1 
     7elementtree>=1.2,<=1.3 
     8beaker>=0.6.2,<0.7 
    109 
    1110[pudge] 
     
    1514 
    1615[full] 
    17 Pylons>=0.9 
    18 SQLAlchemy>=0.3.2 
    19 DBUtils>=0.9.2 
    20 Beaker 
     16Pylons>=0.9,<=1.0 
     17SQLAlchemy>=0.3.2,<=0.4 
     18DBUtils>=0.9.2,<=1.0 
    2119pudge==dev 
    2220buildutils==dev 
     
    2422 
    2523[pylons] 
    26 Pylons>=0.9 
     24Pylons>=0.9,<=1.0 
    2725 
    2826[mysql] 
    29 SQLAlchemy>=0.3.2 
    30 DBUtils>=0.9.2 
     27SQLAlchemy>=0.3.2,<=0.4 
     28DBUtils>=0.9.2,<=1.0 
  • AuthKit/branches/0.4/authkit/authenticate/__init__.py

    r60 r61  
    4444from pkg_resources import iter_entry_points, load_entry_point 
    4545from paste.deploy.converters import asbool 
     46from paste.httpexceptions import HTTPExceptionHandler 
    4647 
    4748# 
     
    535536 
    536537    # 
     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    # 
    537553    # Configure the config files 
    538554    # 
     
    721737        raise NotImplementedError('No %r method has been implemented'%method) 
    722738            
    723 from authkit.authorize import authorize 
    724  
    725 def test_app(environ, start_response): 
     739from authkit.authorize import authorize_request 
     740from authkit.permissions import RemoteUser 
     741 
     742def sample_app(environ, start_response): 
    726743    """ 
    727744    A sample WSGI application that returns a 401 status code when the path  
     
    739756    """ 
    740757    if environ['PATH_INFO']=='/private': 
    741         authorize(environ, RemoteUser()) 
     758        authorize_request(environ, RemoteUser()) 
    742759    if environ['PATH_INFO'] == '/signout': 
    743760        start_response('200 OK', [('Content-type', 'text/plain')]) 
     
    751768    else: 
    752769        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  
    294294            cookie_value = '' 
    295295        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')
    297297        log.debug("Remote addr %r, value %r, include_ip %r", remote_addr, cookie_value, self.include_ip) 
    298298 
  • AuthKit/branches/0.4/authkit/authenticate/form.py

    r59 r61  
    1414template = """\ 
    1515<html> 
    16   <head><title>Please Login!</title></head> 
     16  <head><title>Please Sign In</title></head> 
    1717  <body> 
    18     <h1>Please Login</h1> 
     18    <h1>Please Sign In</h1> 
    1919    <form action="%s" method="post"> 
    2020      <dl> 
     
    6262 
    6363        content = self.template % construct_url(environ) 
    64         start_response("200 OK",[('Content-Type', 'text/html'), 
     64        start_response("401 Unauthorized",[('Content-Type', 'text/html'), 
    6565                                 ('Content-Length', str(len(content)))]) 
    6666        return [content] 
     
    7676        app, 
    7777        '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    ) 
    7980 
    8081    template_conf = strip_base(auth_conf, 'template.') 
     
    9596    return app 
    9697 
    97 if __name__ == 'main': 
    98     from paste.httpserver import serve 
    99     from authkit.authenticate import middleware, test_app 
    100  
    101     app = middleware( 
    102         test_app, 
    103         method='new_form', 
    104         cookie_secret='secret encryption string', 
    105         users_setup = """ 
    106             Username1:password1 
    107             username2:password2 
    108         """, 
    109         cookie_signout = '/signout', 
    110         custom_methods = { 
    111             'new_form': make_new_form_middleware 
    112         }, 
    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_app 
     1from authkit.authenticate import middleware 
    22from authkit.authenticate.multi import MultiHandler, status_checker 
    33 
  • AuthKit/branches/0.4/authkit/authorize.py

    r60 r61  
    2525 
    2626from paste import httpexceptions 
    27 from authkit.permissions import PermissionSetupError 
    28 from authkit.authorize import NotAuthenticatedError, NotAuthorizedError 
     27#from authkit.permissions import NotAuthenticatedError, NotAuthorizedError 
     28 
     29class PermissionSetupError(Exception): 
     30    pass 
    2931 
    3032# 
     
    164166        'Try using the authkit.authorize.middleware or the authorize decorator.' 
    165167    ) 
    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: 
    167191        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                     _PermissionStartResponse 
    184                 ),  
    185                 _PermissionList 
    186             ): 
    187                 raise _FiddledWith('Fiddled with response') 
    188         except _FiddledWith: 
    189             raise error 
    190192 
    191193def authorized(environ, permission): 
  • AuthKit/branches/0.4/authkit/permissions.py

    r60 r61  
    3131# 
    3232 
    33 class PermissionSetupError(Exception): 
    34     pass 
    3533 
    3634class Permission: 
  • AuthKit/branches/0.4/examples/docs/basic.py

    r59 r61  
    1 from authkit.authenticate import middleware, test_app  
    2  
     1from authkit.authenticate import middleware, sample_app  
    32 
    43def valid(environ, username, password): 
     
    65 
    76app = middleware( 
    8     test_app,  
     7    sample_app,  
    98    setup_method='basic',  
    109    basic_realm='Test Realm',  
     
    1211) 
    1312 
    14 from paste.httpserver import serve 
    15 serve(app, host='0.0.0.0', port=8080) 
     13if __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_app  
     1from authkit.authenticate import middleware, sample_app  
    22from authkit.authenticate.digest import digest_password 
    33 
     
    77 
    88app = 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', 
    1212    digest_authenticate_function=digest 
    1313) 
    1414 
    15 from paste.httpserver import serve 
    16 serve(app, host='0.0.0.0', port=8080) 
     15if __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 
     1from authkit.authenticate import middleware, sample_app 
    32 
    43app = middleware( 
    5     test_app, 
     4    sample_app, 
    65    setup_method='form,cookie', 
    76    cookie_secret='secret encryption string', 
     
    1312    #cookie_params_name = 'test' 
    1413) 
    15 serve(app, host='0.0.0.0', port=8080) 
     14 
     15if __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): 
     1from authkit.authenticate import middleware 
     2 
     3def sample_app(environ, start_response): 
    24    """ 
    35    A sample WSGI application that returns a 401 status code when the path  
     
    3638            """ 
    3739        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>'] 
    4045        else: 
    4146            # Quick and dirty sign in check, do it properly in your code 
     
    5257     
    5358    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   
    5864 
    5965app = middleware( 
    60     test_app, 
     66    sample_app, 
    6167    setup_method='forward,cookie', 
    6268    forward_internalpath = '/signin', 
     
    6470    cookie_secret = 'somesecret', 
    6571) 
    66 serve(app, host='0.0.0.0', port=8080) 
     72 
     73if __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 
     1from authkit.authenticate import middleware, sample_app 
    32 
    43app = middleware( 
    5     test_app, 
     4    sample_app, 
    65    setup_method='passurl,cookie', 
    76    passurl_path_signedin='/private', 
     
    1211) 
    1312 
    14 serve(app, host='0.0.0.0', port=8080) 
     13if __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 
     1from authkit.authenticate import middleware, sample_app 
    32 
    43app = middleware( 
    5     test_app, 
     4    sample_app, 
    65    setup_method='redirect,cookie', 
    7     redirect_url='http://google.com', 
     6    redirect_url='http://3aims.com', 
    87    cookie_secret='asdasd' 
    98) 
    10  
    11 serve(app, host='0.0.0.0', port=8080) 
     9if __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  
    6565    include_package_data=True, 
    6666    zip_safe=False, 
     67    test_suite = 'nose.collector', 
    6768    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", 
    7072        "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", 
    7477    ], 
    7578    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"], 
    8082        'pudge': ["pudge==dev", "buildutils==dev", "pygments==0.6"], 
    8183    }, 
  • AuthKit/branches/0.4/test/test.py

    r60 r61  
    1 from authkit.authenticate import middleware, test_app 
     1""" 
     2Very basic tests which so no more than check each of the authentication 
     3methods to ensure that an unprotected page is accessible and that a  
     4protected page triggers the a sign in. 
     5 
     6Note: Should the Form and Forward methods return 401 or 200 when they 
     7generate an HTML page for the user to sign in? 
     8""" 
     9 
     10import sys 
     11import os 
     12 
     13from authkit.authenticate import middleware, sample_app 
    214from paste.fixture import * 
    315 
    4 def simple_app(environ, start_response): 
    5     return test_app(environ, start_response) 
     16sys.path.append(os.getcwd()+'/examples/docs') 
     17 
     18from form import app as form_app 
     19from basic import app as basic_app 
     20from digest import app as digest_app 
     21from forward import app as forward_app 
     22from passurl import app as passurl_app 
     23from redirect import app as redirect_app 
     24 
     25def assertEqual(a,b): 
     26    if a != b: 
     27        raise AssertionError('%s != %s'%(a,b)) 
     28 
     29apps = [ 
     30    form_app,  
     31    basic_app,  
     32    digest_app,  
     33    forward_app, 
     34    passurl_app,  
     35    redirect_app, 
     36
    637 
    738def 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 res 
     39    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 
    1344 
     45def 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 
     53def 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 
     59def 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 
     67def 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 
     73def 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