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)
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)
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)
def test_str(self): notification = VerificationNotification('https://thebluealliance.com/', 'password') self.assertTrue("{'verification_key': " in str(notification))
def test_data_payload(self): notification = VerificationNotification('https://thebluealliance.com/', 'password') self.assertIsNone(notification.data_payload)
def test_type(self): self.assertEqual(VerificationNotification._type(), NotificationType.VERIFICATION)
def test_secret_empty(self): # TODO: Migrate existing users, make this throw again VerificationNotification('https://thebluealliance.com/', '')
def test_secret_type(self): with self.assertRaises(TypeError): VerificationNotification('https://thebluealliance.com/', 200)
def test_url_empty(self): with self.assertRaises(ValueError): VerificationNotification('', 'password')
def test_url_type(self): with self.assertRaises(TypeError): VerificationNotification(200, 'password')
def test_url(self): with self.assertRaises(TypeError): VerificationNotification(None, 'password')
def test_secret_empty(self): with self.assertRaises(ValueError): VerificationNotification('https://thebluealliance.com/', '')