示例#1
0
class TestHTTPProbe(unittest.TestCase):
    """Basic tests of HTTP probe functionalities."""
    def setUp(self):
        self.http = ProbeHTTP("monitoring-dc.app.corp")

    def test_instance_init(self):
        """Test instance initialization."""
        self.assertEqual(self.http.baseurl, "http://monitoring-dc.app.corp:80")

    def test_probe_auth(self):
        """Test HTTP probe auth."""
        http = ProbeHTTP("wwgrpapp0061.ww.corp",
                         auth=('9nagios', 'PassNAD9@!@'))
        http_get_response = http.get("/")
        self.assertTrue(http_get_response.status_code == 200)

    def test_http_get(self):
        """Test HTTP GET request."""
        http_get_response = self.http.get("/")
        self.assertTrue(http_get_response.status_code == 200)

    def test_http_post(self):
        """Test HTTP POST request."""
        http = ProbeHTTP("httpbin.org")
        http_get_response = http.post("/post", data={"hello": "world"})
        self.assertTrue(http_get_response.status_code == 200)

    def test_bad_status_exception(self):
        """Test that HTTP request returns bad code."""
        with self.assertRaises(SystemExit):
            self.http.get("/rueyuzeytzeytiuytuez")

    def test_xml_parser_init(self):
        """Test fetching a XML file and parsing it."""
        http = ProbeHTTP("wweasapp0611.eas.ww.corp")
        response = http.get("/wweasapp0611.xml")
        self.assertIsInstance(response.xml(), BeautifulSoup)

    def test_xml_find_tag(self):
        """Test fetching a XML file and find a tag in it."""
        http = ProbeHTTP("wweasapp0611.eas.ww.corp")
        response = http.get("/wweasapp0611.xml")
        xml = response.xml()
        self.assertTrue(xml.alert.last_update)
class TestHTTPProbe(unittest.TestCase):
    """Basic tests of HTTP probe functionalities."""
    def setUp(self):
        self.http = ProbeHTTP("monitoring-dc.app.corp")

    def test_instance_init(self):
        """Test instance initialization."""
        self.assertEqual(self.http.baseurl, "http://monitoring-dc.app.corp:80")

    def test_probe_auth(self):
        """Test HTTP probe auth."""
        http = ProbeHTTP("wwgrpapp0061.ww.corp", auth=('9nagios',
                                                       'PassNAD9@!@'))
        http_get_response = http.get("/")
        self.assertTrue(http_get_response.status_code == 200)

    def test_http_get(self):
        """Test HTTP GET request."""
        http_get_response = self.http.get("/")
        self.assertTrue(http_get_response.status_code == 200)

    def test_http_post(self):
        """Test HTTP POST request."""
        http = ProbeHTTP("httpbin.org")
        http_get_response = http.post("/post", data={"hello": "world"})
        self.assertTrue(http_get_response.status_code == 200)

    def test_bad_status_exception(self):
        """Test that HTTP request returns bad code."""
        with self.assertRaises(SystemExit):
            self.http.get("/rueyuzeytzeytiuytuez")

    def test_xml_parser_init(self):
        """Test fetching a XML file and parsing it."""
        http = ProbeHTTP("wweasapp0611.eas.ww.corp")
        response = http.get("/wweasapp0611.xml")
        self.assertIsInstance(response.xml(), BeautifulSoup)

    def test_xml_find_tag(self):
        """Test fetching a XML file and find a tag in it."""
        http = ProbeHTTP("wweasapp0611.eas.ww.corp")
        response = http.get("/wweasapp0611.xml")
        xml = response.xml()
        self.assertTrue(xml.alert.last_update)
示例#3
0
    def __init__(self, *args, **kwargs):
        super(NagiosPluginHTTP, self).__init__(*args, **kwargs)

        self.http = ProbeHTTP(hostaddress=self.options.hostname,
                              port=self.options.port,
                              ssl=self.options.ssl,
                              auth=self.options.auth)

        if 'NagiosPluginHTTP' == self.__class__.__name__:
            logger.debug('=== END PLUGIN INIT ===')
示例#4
0
 def test_xml_find_tag(self):
     """Test fetching a XML file and find a tag in it."""
     http = ProbeHTTP("wweasapp0611.eas.ww.corp")
     response = http.get("/wweasapp0611.xml")
     xml = response.xml()
     self.assertTrue(xml.alert.last_update)
示例#5
0
 def test_xml_parser_init(self):
     """Test fetching a XML file and parsing it."""
     http = ProbeHTTP("wweasapp0611.eas.ww.corp")
     response = http.get("/wweasapp0611.xml")
     self.assertIsInstance(response.xml(), BeautifulSoup)
示例#6
0
 def test_http_post(self):
     """Test HTTP POST request."""
     http = ProbeHTTP("httpbin.org")
     http_get_response = http.post("/post", data={"hello": "world"})
     self.assertTrue(http_get_response.status_code == 200)
示例#7
0
 def test_probe_auth(self):
     """Test HTTP probe auth."""
     http = ProbeHTTP("wwgrpapp0061.ww.corp",
                      auth=('9nagios', 'PassNAD9@!@'))
     http_get_response = http.get("/")
     self.assertTrue(http_get_response.status_code == 200)
示例#8
0
 def setUp(self):
     self.http = ProbeHTTP("monitoring-dc.app.corp")
 def test_xml_find_tag(self):
     """Test fetching a XML file and find a tag in it."""
     http = ProbeHTTP("wweasapp0611.eas.ww.corp")
     response = http.get("/wweasapp0611.xml")
     xml = response.xml()
     self.assertTrue(xml.alert.last_update)
 def test_xml_parser_init(self):
     """Test fetching a XML file and parsing it."""
     http = ProbeHTTP("wweasapp0611.eas.ww.corp")
     response = http.get("/wweasapp0611.xml")
     self.assertIsInstance(response.xml(), BeautifulSoup)
 def test_http_post(self):
     """Test HTTP POST request."""
     http = ProbeHTTP("httpbin.org")
     http_get_response = http.post("/post", data={"hello": "world"})
     self.assertTrue(http_get_response.status_code == 200)
 def test_probe_auth(self):
     """Test HTTP probe auth."""
     http = ProbeHTTP("wwgrpapp0061.ww.corp", auth=('9nagios',
                                                    'PassNAD9@!@'))
     http_get_response = http.get("/")
     self.assertTrue(http_get_response.status_code == 200)
 def setUp(self):
     self.http = ProbeHTTP("monitoring-dc.app.corp")