def setUpTestData(cls): TEST_URL = "http://localhost/" TEST_SECRET = "thisisaverystrongsecret" webhooks = Webhook.objects.bulk_create( [ Webhook( name="Create Webhook", type_create=True, url=TEST_URL, secret=TEST_SECRET, ), Webhook( name="Update Webhook", type_update=True, url=TEST_URL, secret=TEST_SECRET, ), Webhook( name="Delete Webhook", type_delete=True, url=TEST_URL, secret=TEST_SECRET, ), ] ) Tag.objects.bulk_create( ( Tag(name="Foo", slug="foo"), Tag(name="Bar", slug="bar"), Tag(name="Baz", slug="baz"), ) )
def setUpTestData(cls): webhooks = ( Webhook( name="Webhook 1", type_create=True, enabled=True, url="https://example.com/?1", http_method="GET", ssl_verification=True, ), Webhook( name="Webhook 2", type_update=True, enabled=True, url="https://example.com/?2", http_method="POST", ssl_verification=True, ), Webhook( name="Webhook 3", type_delete=True, enabled=False, http_method="PATCH", url="https://example.com/?3", ssl_verification=False, ), ) Webhook.objects.bulk_create(webhooks)
def setUpTestData(cls): TEST_URL = "http://localhost/" TEST_SECRET = "thisisaverystrongsecret" webhooks = Webhook.objects.bulk_create( [ Webhook( name="AS Create Webhook", type_create=True, url=TEST_URL, secret=TEST_SECRET, ), Webhook( name="AS Update Webhook", type_update=True, url=TEST_URL, secret=TEST_SECRET, ), Webhook( name="AS Delete Webhook", type_delete=True, url=TEST_URL, secret=TEST_SECRET, ), ] )
def setUpTestData(cls): webhooks = ( Webhook(name="Webhook 1", type_create=True, url="http://example.com/?1"), Webhook(name="Webhook 2", type_update=True, url="http://example.com/?2"), Webhook(name="Webhook 3", type_delete=True, url="http://example.com/?3"), ) Webhook.objects.bulk_create(webhooks)
def setUpTestData(cls): site_ct = ContentType.objects.get_for_model(Site) DUMMY_URL = "http://localhost/" DUMMY_SECRET = "LOOKATMEIMASECRETSTRING" webhooks = Webhook.objects.bulk_create(( Webhook(name='Site Create Webhook', type_create=True, payload_url=DUMMY_URL, secret=DUMMY_SECRET, additional_headers='X-Foo: Bar'), Webhook(name='Site Update Webhook', type_update=True, payload_url=DUMMY_URL, secret=DUMMY_SECRET), Webhook(name='Site Delete Webhook', type_delete=True, payload_url=DUMMY_URL, secret=DUMMY_SECRET), )) for webhook in webhooks: webhook.obj_type.set([site_ct])
def test_webhook_conditions(self): # Create a conditional Webhook webhook = Webhook( name='Conditional Webhook', type_create=True, type_update=True, payload_url='http://localhost/', conditions={ 'and': [ { 'attr': 'status.value', 'value': 'active', } ] } ) # Create a Site to evaluate site = Site.objects.create(name='Site 1', slug='site-1', status=SiteStatusChoices.STATUS_STAGING) data = serialize_for_webhook(site) # Evaluate the conditions (status='staging') self.assertFalse(eval_conditions(webhook, data)) # Change the site's status site.status = SiteStatusChoices.STATUS_ACTIVE data = serialize_for_webhook(site) # Evaluate the conditions (status='active') self.assertTrue(eval_conditions(webhook, data))
def setUpTestData(cls): site_ct = ContentType.objects.get_for_model(Site) PAYLOAD_URL = "http://localhost/" webhooks = Webhook.objects.bulk_create(( Webhook(name='Site Create Webhook', type_create=True, payload_url=PAYLOAD_URL), Webhook(name='Site Update Webhook', type_update=True, payload_url=PAYLOAD_URL), Webhook(name='Site Delete Webhook', type_delete=True, payload_url=PAYLOAD_URL), )) for webhook in webhooks: webhook.obj_type.set([site_ct])
def setUpTestData(cls): site_ct = ContentType.objects.get_for_model(Site) DUMMY_URL = "http://localhost/" DUMMY_SECRET = "LOOKATMEIMASECRETSTRING" webhooks = Webhook.objects.bulk_create(( Webhook(name='Webhook 1', type_create=True, payload_url=DUMMY_URL, secret=DUMMY_SECRET, additional_headers='X-Foo: Bar'), Webhook(name='Webhook 2', type_update=True, payload_url=DUMMY_URL, secret=DUMMY_SECRET), Webhook(name='Webhook 3', type_delete=True, payload_url=DUMMY_URL, secret=DUMMY_SECRET), )) for webhook in webhooks: webhook.content_types.set([site_ct]) Tag.objects.bulk_create(( Tag(name='Foo', slug='foo'), Tag(name='Bar', slug='bar'), Tag(name='Baz', slug='baz'), ))