Back to index

moin  1.9.0~rc2
Classes | Public Member Functions | Static Public Attributes
test_auth.TestHttpAuthSession Class Reference
Inheritance diagram for test_auth.TestHttpAuthSession:
Inheritance graph
[legend]
Collaboration diagram for test_auth.TestHttpAuthSession:
Collaboration graph
[legend]

List of all members.

Classes

class  Config

Public Member Functions

def testHttpAuthSession
def setup_class
def teardown_class
def run_request

Static Public Attributes

list PAGES = ['FrontPage', 'MoinMoin', 'HelpContents', 'WikiSandBox', ]

Detailed Description

Definition at line 132 of file test_auth.py.


Member Function Documentation

def test_auth.AuthTest.run_request (   self,
  params 
) [inherited]

Definition at line 30 of file test_auth.py.

00030 
00031     def run_request(self, **params):
00032         request = TestRequest(**params)
00033         #XXX: config passing hack
00034         request.given_config = getattr(self, 'Config', wikiconfig.Config)
00035         context = wsgiapp.init(request)
00036         wsgiapp.run(context)
00037         return context
00038 

Here is the caller graph for this function:

def test_auth.AuthTest.setup_class (   cls) [inherited]
Stuff that should be run to init the state of this test class

Some test needs specific config values, or they will fail.

Definition at line 19 of file test_auth.py.

00019 
00020     def setup_class(cls):
00021         """ Stuff that should be run to init the state of this test class
00022 
00023         Some test needs specific config values, or they will fail.
00024         """

def test_auth.AuthTest.teardown_class (   cls) [inherited]
Stuff that should run to clean up the state of this test class

Definition at line 25 of file test_auth.py.

00025 
00026     def teardown_class(cls):
00027         """ Stuff that should run to clean up the state of this test class
00028 
00029         """

run some requests with http auth, check whether session works 

Definition at line 138 of file test_auth.py.

00138 
00139     def testHttpAuthSession(self):
00140         """ run some requests with http auth, check whether session works """
00141         username = u'HttpAuthTestUser'
00142         auth_info = u'%s:%s' % (username, u'testpass')
00143         auth_header = 'Basic %s' % auth_info.encode('base64')
00144         cookie = ''
00145         trail_expected = []
00146         first = True
00147         for pagename in self.PAGES:
00148             environ_overrides = {'HTTP_COOKIE': cookie,
00149                                  'HTTP_AUTHORIZATION': auth_header}
00150             request = self.run_request(path='/%s' % pagename,
00151                                        environ_overrides=environ_overrides)
00152 
00153             # Login worked?
00154             assert request.user.valid
00155             assert request.user.name == username
00156 
00157             # Do we have a session?
00158             assert request.session is not None
00159 
00160             appiter, status, headers = evaluate_request(request.request)
00161             # check if the request resulted in normal status, result headers and content
00162             assert status[:3] == '200'
00163             has_ct = has_v = has_cc = False
00164             for k, v in request.headers:
00165                 if k == 'Content-Type':
00166                     assert v.startswith('text/html')
00167                     has_ct = True
00168                 elif k == 'Vary':
00169                     assert 'Cookie' in v
00170                     assert 'Accept-Language' in v
00171                     has_v = True
00172                 elif k == 'Cache-Control':
00173                     assert 'private' in v
00174                     assert 'must-revalidate' in v
00175                     has_cc = True
00176                 elif k == 'Set-Cookie':
00177                     cookie = v
00178             assert has_ct
00179             assert has_v
00180             assert has_cc # do not cache logged-in user's content
00181             assert '</html>' in ''.join(appiter)
00182 
00183             # The trail is only ever saved on the second page display
00184             # because otherwise anonymous sessions would be created
00185             # for every request, even if it never sent a cookie!
00186             # Hence, skip over the first request and only verify
00187             # the trail for the second and following.
00188             if first:
00189                 first = False
00190                 continue
00191 
00192             trail_expected.append(unicode(pagename))
00193 
00194             # Requested pagenames get into trail?
00195             assert 'trail' in request.session
00196             trail = request.session['trail']
00197             assert trail == trail_expected

Here is the call graph for this function:


Member Data Documentation

list test_auth.AuthTest.PAGES = ['FrontPage', 'MoinMoin', 'HelpContents', 'WikiSandBox', ] [static, inherited]

Definition at line 17 of file test_auth.py.


The documentation for this class was generated from the following file: