Esempio n. 1
0
 def test_Handler_unauthorized(self):
     Handler = server.handler_factory(
         base_dir=self._get_base_dir(),
         username="******",
         password="******",
         oneshot=False,
         jinja_template_rendered=self._render_template(
             events=["event1", "event2"],
             qrcode_button=True,
             shutdown_button=True),
     )
     Handler = make_testable(Handler)
     self.assertTrue(
         self._test(Handler, b"/").startswith(b"HTTP/1.0 401 Unauthorized"))
Esempio n. 2
0
    def test_handler_factory(self):
        Handler = server.handler_factory(
            base_dir=self._get_base_dir(),
            username="******",
            password="******",
            oneshot=False,
            jinja_template_rendered=self._render_template(
                events=["event1", "event2"],
                qrcode_button=True,
                shutdown_button=True),
        )

        Handler = make_testable(Handler)
        handler = Handler(MockRequest(b"/"), (0, 0), None)
        self.assertEqual(handler.require_login, True)
Esempio n. 3
0
 def test_Handler_authorized(self):
     Handler = server.handler_factory(
         base_dir=self._get_base_dir(),
         username="******",
         password=None,
         oneshot=False,
         jinja_template_rendered=self._render_template(
             events=["event1", "event2"],
             qrcode_button=True,
             shutdown_button=True),
     )
     Handler = make_testable(Handler)
     response = self._test(Handler, b"/")
     response = response.decode("utf8")
     self.assertTrue("HTTP/1.0 200 OK" in response)
     self.assertTrue("qrcode-btn" in response)
     self.assertTrue("shutdown-btn" in response)
     for event in ["event1", "event2"]:
         self.assertTrue(event in response)