Пример #1
0
 def test_ipv6(self):
     try:
         logger.info('Test http server in ipv6')
         PHTTPServer._instance = None
         httpd = PHTTPServer(bind_ip='::', bind_port=6666, requestHandler=BaseRequestHandler)
         httpd.start()
         url = '{}://{}:{}/'.format('http', '[{}]'.format(get_host_ipv6()), 6666)
         resp = requests.get(url)
         self.assertEqual(resp.status_code, 200)
     except Exception:
         pass
     finally:
         httpd.stop()
Пример #2
0
 def test_ipv4_https(self):
     try:
         logger.info('Test https server in ipv4')
         PHTTPServer._instance = None
         httpd = PHTTPServer(bind_ip='0.0.0.0', bind_port=6666, use_https=True,
                             requestHandler=BaseRequestHandler)
         httpd.start()
         url = '{}://{}:{}/'.format('https', get_host_ip(), 6666)
         requests.get(url)
     except requests.exceptions.SSLError:
         url = '{}://{}:{}/'.format('https', get_host_ip(), 6666)
         resp = requests.get(url, verify=False)
         self.assertEqual(resp.status_code, 200)
     except Exception:
         assert False
     finally:
         httpd.stop()
Пример #3
0
 def test_singleton(self):
     logger.info("Test http server is singleton")
     PHTTPServer._instance = None
     httpd1 = PHTTPServer()
     httpd2 = PHTTPServer()
     self.assertEqual(id(httpd1), id(httpd2))
Пример #4
0
 def test_only_start_server_once(self):
     logger.info("Test http server is only start once")
     PHTTPServer._instance = None
     httpd1 = PHTTPServer()
     httpd2 = PHTTPServer()
     httpd1.start()
     httpd2.start()
     httpd1.stop()
     httpd2.stop()