Back to index

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

List of all members.

Classes

class  Config

Public Member Functions

def testMoinAuthSession
def setup_class
def teardown_class
def run_request

Static Public Attributes

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

Detailed Description

Definition at line 198 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 MoinAuth, check whether session works 

Definition at line 203 of file test_auth.py.

00203 
00204     def testMoinAuthSession(self):
00205         """ run some requests with MoinAuth, check whether session works """
00206         from MoinMoin.user import User
00207         username = u'MoinAuthTestUser'
00208         password = u'ßecretß'
00209         User(self.request, name=username, password=password).save() # create user
00210         trail_expected = []
00211         first = True
00212         for pagename in self.PAGES:
00213             if first:
00214                 formdata = {
00215                     'name': username,
00216                     'password': password,
00217                     'login': 'login',
00218                 }
00219                 request = self.run_request(path='/%s' % pagename,
00220                                            query_string='login=login',
00221                                            method='POST', form_data=formdata)
00222             else: # not first page, use session cookie
00223                 environ_overrides = {'HTTP_COOKIE': cookie}
00224                 request = self.run_request(path='/%s' % pagename,
00225                                            environ_overrides=environ_overrides)
00226 
00227             # Login worked?
00228             assert request.user.valid
00229             assert request.user.name == username
00230 
00231             # Do we have a session?
00232             assert request.session is not None
00233 
00234             appiter, status, headers = evaluate_request(request.request)
00235             # check if the request resulted in normal status, result headers and content
00236             assert status[:3] == '200'
00237             has_ct = has_v = has_cc = False
00238             for k, v in request.headers:
00239                 if k == 'Content-Type':
00240                     assert v.startswith('text/html')
00241                     has_ct = True
00242                 elif k == 'Vary':
00243                     assert 'Cookie' in v
00244                     assert 'Accept-Language' in v
00245                     has_v = True
00246                 elif k == 'Cache-Control':
00247                     assert 'private' in v
00248                     assert 'must-revalidate' in v
00249                     has_cc = True
00250                 elif k == 'Set-Cookie':
00251                     cookie = v
00252             assert has_ct
00253             assert has_v
00254             assert has_cc # do not cache logged-in user's content
00255             assert '</html>' in ''.join(appiter)
00256 
00257             # The trail is only ever saved on the second page display
00258             # because otherwise anonymous sessions would be created
00259             # for every request, even if it never sent a cookie!
00260             # Hence, skip over the first request and only verify
00261             # the trail for the second and following.
00262             if first:
00263                 first = False
00264                 continue
00265 
00266             trail_expected.append(unicode(pagename))
00267 
00268             # Requested pagenames get into trail?
00269             assert 'trail' in request.session
00270             trail = request.session['trail']
00271             assert trail == trail_expected
00272 

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: