Exemplo n.º 1
0
 def test_set_current_user_known(self):
     site = zoom.sites.Site()
     request = zoom.utils.Bunch(
         site=site,
         session=zoom.utils.Bunch(),
         remote_user='******',
         profiler=set(),
     )
     set_current_user(request)
     self.assertEqual(request.user.username, 'user')
Exemplo n.º 2
0
 def test_set_current_user_unknown(self):
     zoom.system.site = site = zoom.sites.Site()
     request = zoom.utils.Bunch(
         site=site,
         session=zoom.utils.Bunch(),
         remote_user='******',
         profiler=set(),
     )
     # If the user is authenticated but not known to the system
     # the user should be added to the users table.
     self.assertFalse(site.users.first(username='******'))
     set_current_user(request)
     self.assertEqual(request.user.username, 'newuser')
     self.assertTrue(site.users.first(username='******'))
     site.users.delete(username='******')
     self.assertFalse(site.users.first(username='******'))