Exemple #1
0
 def test_logged_user_allowed(self):
     with self.settings(
             MIDDLEWARE_CLASSES=TestMiddleware.MIDDLEWARE_CLASSES,
             INSTALLED_APPS=TestMiddleware.INSTALLED_APPS):
         api.stop()  # just to be sure
         assert api.is_online()
         self.client.login(**{'username': '******', 'password': '******'})
         response = self.client.get('/admin/')
         self.assertEqual(response.status_code, 200)
         self._activate()
         response = self.client.get('/admin/')
         self.assertEqual(response.status_code, 200)
 def test_logged_user_allowed(self):
     with self.settings(
         MIDDLEWARE_CLASSES=TestMiddleware.MIDDLEWARE_CLASSES, INSTALLED_APPS=TestMiddleware.INSTALLED_APPS
     ):
         api.stop()  # just to be sure
         assert api.is_online()
         self.client.login(**{"username": "******", "password": "******"})
         response = self.client.get("/admin/")
         self.assertEqual(response.status_code, 200)
         self._activate()
         response = self.client.get("/admin/")
         self.assertEqual(response.status_code, 200)
Exemple #3
0
 def test_logged_user_forced(self):
     # not sure this is required
     # web server should itercept request first
     # in any case double check
     with self.settings(
             MIDDLEWARE_CLASSES=TestMiddleware.MIDDLEWARE_CLASSES,
             INSTALLED_APPS=TestMiddleware.INSTALLED_APPS):
         api.stop()  # just to be sure
         assert api.is_online()
         self.client.login(**{'username': '******', 'password': '******'})
         response = self.client.get('/admin/')
         self.assertEqual(response.status_code, 200)
         self._activate(ignore_session=True)
         response = self.client.get('/admin/')
         self.assertEqual(response.status_code, 302)
 def test_logged_user_forced(self):
     # not sure this is required
     # web server should itercept request first
     # in any case double check
     with self.settings(
         MIDDLEWARE_CLASSES=TestMiddleware.MIDDLEWARE_CLASSES, INSTALLED_APPS=TestMiddleware.INSTALLED_APPS
     ):
         api.stop()  # just to be sure
         assert api.is_online()
         self.client.login(**{"username": "******", "password": "******"})
         response = self.client.get("/admin/")
         self.assertEqual(response.status_code, 200)
         self._activate(ignore_session=True)
         response = self.client.get("/admin/")
         self.assertEqual(response.status_code, 302)
Exemple #5
0
 def test_is_online(self):
     ret, msg = api.start()
     self.assertEqual(ret, SUCCESS)
     self.assertFalse(api.is_online())
     api.stop()
     self.assertTrue(api.is_online())
 def test_is_online(self):
     ret, msg = api.start()
     self.assertEqual(ret, SUCCESS)
     self.assertFalse(api.is_online())
     api.stop()
     self.assertTrue(api.is_online())