Exemplo n.º 1
0
 def test_webhook_payload(self):
     notification = VerificationNotification('https://thebluealliance.com/',
                                             'password')
     self.assertIsNotNone(notification.webhook_payload)
     verification_key = notification.webhook_payload.get(
         'verification_key', None)
     self.assertIsNotNone(verification_key)
Exemplo n.º 2
0
    def verification(self, request):
        """ Immediately dispatch a Verification to a webhook """
        self._validate_authentication()

        from tbans.models.notifications.verification import VerificationNotification
        notification = VerificationNotification(request.webhook.url, request.webhook.secret)

        from tbans.models.messages.webhook_message import WebhookMessage
        message = WebhookMessage(notification, request.webhook.url, request.webhook.secret)
        logging.info('Verification - {}'.format(str(message)))

        response = message.send()
        logging.info('Verification Response - {}'.format(str(response)))
        return VerificationResponse(code=response.status_code, message=response.content, verification_key=notification.verification_key)
Exemplo n.º 3
0
    def verification(self, request):
        """ Immediately dispatch a Verification to a webhook """
        self._validate_authentication()

        from tbans.models.notifications.verification import VerificationNotification
        notification = VerificationNotification(request.webhook.url, request.webhook.secret)

        from tbans.requests.webhook_request import WebhookRequest
        webhook_request = WebhookRequest(notification, request.webhook.url, request.webhook.secret)
        logging.info('Verification - {}'.format(str(webhook_request)))

        webhook_request.send()
        logging.info('Verification Key - {}'.format(notification.verification_key))

        return VerificationResponse(code=200, verification_key=notification.verification_key)
 def test_type(self):
     self.assertEqual(VerificationNotification._type(), NotificationType.VERIFICATION)
Exemplo n.º 5
0
 def test_str(self):
     notification = VerificationNotification('https://thebluealliance.com/',
                                             'password')
     self.assertTrue("{'verification_key': " in str(notification))
Exemplo n.º 6
0
 def test_data_payload(self):
     notification = VerificationNotification('https://thebluealliance.com/',
                                             'password')
     self.assertIsNone(notification.data_payload)
Exemplo n.º 7
0
 def test_type(self):
     self.assertEqual(VerificationNotification._type(),
                      NotificationType.VERIFICATION)
Exemplo n.º 8
0
 def test_secret_empty(self):
     # TODO: Migrate existing users, make this throw again
     VerificationNotification('https://thebluealliance.com/', '')
Exemplo n.º 9
0
 def test_secret_type(self):
     with self.assertRaises(TypeError):
         VerificationNotification('https://thebluealliance.com/', 200)
Exemplo n.º 10
0
 def test_url_empty(self):
     with self.assertRaises(ValueError):
         VerificationNotification('', 'password')
Exemplo n.º 11
0
 def test_url_type(self):
     with self.assertRaises(TypeError):
         VerificationNotification(200, 'password')
Exemplo n.º 12
0
 def test_url(self):
     with self.assertRaises(TypeError):
         VerificationNotification(None, 'password')
Exemplo n.º 13
0
 def test_secret_empty(self):
     with self.assertRaises(ValueError):
         VerificationNotification('https://thebluealliance.com/', '')