Esempio n. 1
0
 def test_validation_for_pagerduty(self):
     notification = {"name": "MyPagerduty", "type": "PAGERDUTY",
                     "address": "nzH2LVRdMzun11HNC2oD"}
     try:
         schemas_notifications.validate(notification)
     except schemas_exceptions.ValidationException:
         self.fail("shouldn't happen")
Esempio n. 2
0
 def test_validation_for_max_name_address(self):
     name = "A" * 250
     self.assertEqual(250, len(name))
     address = "http://" + "A" * 502 + ".io"
     self.assertEqual(512, len(address))
     notification = {"name": name, "type": "WEBHOOK", "address": address}
     try:
         schemas_notifications.validate(notification)
     except schemas_exceptions.ValidationException:
         self.fail("shouldn't happen")
Esempio n. 3
0
 def test_validation_for_pagerduty(self):
     notification = {
         "name": "MyPagerduty",
         "type": "PAGERDUTY",
         "address": "nzH2LVRdMzun11HNC2oD"
     }
     try:
         schemas_notifications.validate(notification)
     except schemas_exceptions.ValidationException:
         self.fail("shouldn't happen")
Esempio n. 4
0
 def test_validation_for_webhook(self):
     notification = {
         "name": "MyWebhook",
         "type": "WEBHOOK",
         "address": "http://somedomain.com"
     }
     try:
         schemas_notifications.validate(notification)
     except schemas_exceptions.ValidationException:
         self.fail("shouldn't happen")
Esempio n. 5
0
 def test_validation_for_email(self):
     notification = {
         "name": "MyEmail",
         "type": "EMAIL",
         "address": "*****@*****.**"
     }
     try:
         schemas_notifications.validate(notification)
     except schemas_exceptions.ValidationException:
         self.fail("shouldn't happen")
Esempio n. 6
0
 def test_validation_for_max_name_address(self):
     name = "A" * 250
     self.assertEqual(250, len(name))
     address = "http://" + "A" * 502 + ".io"
     self.assertEqual(512, len(address))
     notification = {"name": name, "type": "WEBHOOK", "address": address}
     try:
         schemas_notifications.validate(notification)
     except schemas_exceptions.ValidationException:
         self.fail("shouldn't happen")
Esempio n. 7
0
 def test_validation_exception_for_webhook_no_netloc(self):
     notification = {
         "name": "MyWebhook",
         "type": "WEBHOOK",
         "address": "http://"
     }
     with self.assertRaises(schemas_exceptions.ValidationException) as ve:
         schemas_notifications.validate(notification)
     ex = ve.exception
     self.assertEqual("Address http:// does not have network location",
                      ex.message)
Esempio n. 8
0
 def test_validation_exception_for_webhook_no_scheme(self):
     notification = {
         "name": "MyWebhook",
         "type": "WEBHOOK",
         "address": "//somedomain.com"
     }
     with self.assertRaises(schemas_exceptions.ValidationException) as ve:
         schemas_notifications.validate(notification)
     ex = ve.exception
     self.assertEqual("Address //somedomain.com does not have URL scheme",
                      ex.message)
Esempio n. 9
0
 def test_validation_exception_for_email(self):
     notification = {
         "name": "MyEmail",
         "type": "EMAIL",
         "address": "name@domain."
     }
     with self.assertRaises(schemas_exceptions.ValidationException) as ve:
         schemas_notifications.validate(notification)
     ex = ve.exception
     self.assertEqual("Address name@domain. is not of correct format",
                      ex.message)
Esempio n. 10
0
    def _validate_notification(self, notification):
        """Validates the notification

        :param notification: An event object.
        :raises falcon.HTTPBadRequest
        """
        try:
            schemas_notifications.validate(notification)
        except schemas_exceptions.ValidationException as ex:
            LOG.debug(ex)
            raise falcon.HTTPBadRequest('Bad request', ex.message)
Esempio n. 11
0
    def _validate_notification(self, notification):
        """Validates the notification

        :param notification: An event object.
        :raises falcon.HTTPBadRequest
        """
        try:
            schemas_notifications.validate(notification)
        except schemas_exceptions.ValidationException as ex:
            LOG.debug(ex)
            raise falcon.HTTPBadRequest('Bad Request', ex.message)
Esempio n. 12
0
 def test_validation_exception_for_webhook_invalid_scheme(self):
     notification = {
         "name": "MyWebhook",
         "type": "WEBHOOK",
         "address": "ftp://somedomain.com"
     }
     with self.assertRaises(schemas_exceptions.ValidationException) as ve:
         schemas_notifications.validate(notification)
     ex = ve.exception
     self.assertEqual(
         "Address ftp://somedomain.com scheme is not in ['http', 'https']",
         ex.message)
Esempio n. 13
0
 def test_validation_exception_for_webhook_invalid_scheme(self):
     notification = {"name": "MyWebhook", "type": "WEBHOOK", "address": "ftp://somedomain.com"}
     with self.assertRaises(schemas_exceptions.ValidationException) as ve:
         schemas_notifications.validate(notification)
     ex = ve.exception
     self.assertEqual("Address ftp://somedomain.com scheme is not in ['http', 'https']", ex.message)
Esempio n. 14
0
 def test_validation_exception_for_webhook_no_netloc(self):
     notification = {"name": "MyWebhook", "type": "WEBHOOK", "address": "http://"}
     with self.assertRaises(schemas_exceptions.ValidationException) as ve:
         schemas_notifications.validate(notification)
     ex = ve.exception
     self.assertEqual("Address http:// does not have network location", ex.message)
Esempio n. 15
0
 def test_validation_exception_for_webhook_no_scheme(self):
     notification = {"name": "MyWebhook", "type": "WEBHOOK", "address": "//somedomain.com"}
     with self.assertRaises(schemas_exceptions.ValidationException) as ve:
         schemas_notifications.validate(notification)
     ex = ve.exception
     self.assertEqual("Address //somedomain.com does not have URL scheme", ex.message)
Esempio n. 16
0
 def test_validation_for_webhook(self):
     notification = {"name": "MyWebhook", "type": "WEBHOOK", "address": "http://somedomain.com"}
     try:
         schemas_notifications.validate(notification)
     except schemas_exceptions.ValidationException:
         self.fail("shouldn't happen")
Esempio n. 17
0
 def test_validation_exception_for_email(self):
     notification = {"name": "MyEmail", "type": "EMAIL", "address": "name@domain."}
     with self.assertRaises(schemas_exceptions.ValidationException) as ve:
         schemas_notifications.validate(notification)
     ex = ve.exception
     self.assertEqual("Address name@domain. is not of correct format", ex.message)
Esempio n. 18
0
 def test_validation_for_email(self):
     notification = {"name": "MyEmail", "type": "EMAIL", "address": "*****@*****.**"}
     try:
         schemas_notifications.validate(notification)
     except schemas_exceptions.ValidationException:
         self.fail("shouldn't happen")