Ignore:
Timestamp:
14/05/09 16:42:36 (10 years ago)
Author:
pjkersha
Message:

Reworking unit tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/python/ndg.security.test/ndg/security/test/unit/wsgi/authn/test_authn.py

    r5037 r5290  
    22"""Unit tests for WSGI Authentication redirect handler 
    33 
    4 NERC Data Grid Project 
     4NERC DataGrid Project 
    55""" 
    66__author__ = "P J Kershaw" 
     
    4343        elif environ['PATH_INFO'] == '/test_401WithLoggedIn': 
    4444            status = "401 Unauthorized" 
    45             environ['REMOTE_USER'] = 'testuser'             
    4645             
    4746        elif environ['PATH_INFO'] == '/test_200WithNotLoggedIn': 
     
    7372    def test01Catch401WithNotLoggedIn(self): 
    7473        response = self.app.get('/test_401WithNotLoggedIn') 
     74        self.assert_(response.status == 302) 
     75         
    7576        try: 
    7677            redirectResponse = response.follow() 
     
    8081 
    8182    def test02Skip200WithLoggedIn(self): 
    82         response = self.app.get('/test_200WithLoggedIn') 
    83         self.assert_(TestAuthNMiddleware.response in response) 
     83        response = self.app.get('/test_200WithLoggedIn', 
     84                                extra_environ={'REMOTE_USER': 'testuser'}, 
     85                                status=403) 
     86        self.assert_(response.status == 403) 
    8487 
    8588    def test03Catch401WithLoggedIn(self): 
     
    9396    def test04Catch200WithNotLoggedIn(self): 
    9497        response = self.app.get('/test_200WithNotLoggedIn') 
    95         self.assert_(TestAuthNMiddleware.response in response) 
     98        self.assert_(response.status == 302) 
     99         
     100        try: 
     101            redirectResponse = response.follow() 
     102        except paste.fixture.AppError, e: 
     103            self.failIf('404 Not found' not in str(e),  
     104                        "Expecting 404 Not found") 
    96105     
    97106 
Note: See TracChangeset for help on using the changeset viewer.