369 clear_cache(req, 'get_authorization') |
369 clear_cache(req, 'get_authorization') |
370 |
370 |
371 def _test_auth_anon(self, req): |
371 def _test_auth_anon(self, req): |
372 asession = self.app.get_session(req) |
372 asession = self.app.get_session(req) |
373 # important otherwise _reset_cookie will not use the right session |
373 # important otherwise _reset_cookie will not use the right session |
374 req.set_cnx(repoapi.ClientConnection(asession)) |
374 req.set_cnx(repoapi.Connection(asession)) |
375 self.assertEqual(len(self.open_sessions), 1) |
375 self.assertEqual(len(self.open_sessions), 1) |
376 self.assertEqual(asession.login, 'anon') |
376 self.assertEqual(asession.login, 'anon') |
377 self.assertTrue(asession.anonymous_session) |
377 self.assertTrue(asession.anonymous_session) |
378 self._reset_cookie(req) |
378 self._reset_cookie(req) |
379 |
379 |
380 def _test_anon_auth_fail(self, req): |
380 def _test_anon_auth_fail(self, req): |
381 self.assertEqual(1, len(self.open_sessions)) |
381 self.assertEqual(1, len(self.open_sessions)) |
382 session = self.app.get_session(req) |
382 session = self.app.get_session(req) |
383 # important otherwise _reset_cookie will not use the right session |
383 # important otherwise _reset_cookie will not use the right session |
384 req.set_cnx(repoapi.ClientConnection(session)) |
384 req.set_cnx(repoapi.Connection(session)) |
385 self.assertEqual(req.message, 'authentication failure') |
385 self.assertEqual(req.message, 'authentication failure') |
386 self.assertEqual(req.session.anonymous_session, True) |
386 self.assertEqual(req.session.anonymous_session, True) |
387 self.assertEqual(1, len(self.open_sessions)) |
387 self.assertEqual(1, len(self.open_sessions)) |
388 self._reset_cookie(req) |
388 self._reset_cookie(req) |
389 |
389 |