예제 #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")
예제 #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")
예제 #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")
예제 #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")
예제 #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")
예제 #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")
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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")
예제 #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)
예제 #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")