Back to index

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

List of all members.

Classes

class  Config

Public Member Functions

def testAnonSession
def setup_class
def teardown_class
def run_request

Static Public Attributes

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

Detailed Description

Definition at line 70 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, no auth, check if anon sessions work 

Definition at line 74 of file test_auth.py.

00074 
00075     def testAnonSession(self):
00076         """ run some requests, no auth, check if anon sessions work """
00077         cookie = ''
00078         trail_expected = []
00079         first = True
00080         for pagename in self.PAGES:
00081             environ_overrides = {'HTTP_COOKIE': cookie}
00082             request = self.run_request(path='/%s' % pagename,
00083                                        environ_overrides=environ_overrides)
00084 
00085             # anon user?
00086             assert not request.user.valid
00087 
00088             # Do we have a session?
00089             assert request.session is not None
00090 
00091             appiter, status, headers = evaluate_request(request.request)
00092             # check if the request resulted in normal status, result headers and content
00093             assert status[:3] == '200'
00094             has_ct = has_v = has_cc = False
00095             for k, v in headers:
00096                 if k == 'Content-Type':
00097                     assert v.startswith('text/html')
00098                     has_ct = True
00099                 elif k == 'Vary':
00100                     assert 'Cookie' in v
00101                     assert 'Accept-Language' in v
00102                     has_v = True
00103                 elif k == 'Cache-Control':
00104                     assert 'private' in v
00105                     assert 'must-revalidate' in v
00106                     has_cc = True
00107                 elif k == 'Set-Cookie':
00108                     cookie = v
00109             assert has_ct
00110             assert has_v
00111             # XX BROKEN
00112             #assert not has_cc # do not cache anon user's (with session!) content
00113             assert '</html>' in ''.join(appiter)
00114 
00115             # The trail is only ever saved on the second page display
00116             # because otherwise anonymous sessions would be created
00117             # for every request, even if it never sent a cookie!
00118             # Hence, skip over the first request and only verify
00119             # the trail for the second and following.
00120             if first:
00121                 first = False
00122                 continue
00123 
00124             assert not request.session.is_new
00125 
00126             trail_expected.append(unicode(pagename))
00127 
00128             # Requested pagenames get into trail?
00129             assert 'trail' in request.session
00130             trail = request.session['trail']
00131             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: