|
@ -18,7 +18,7 @@ class AddWebhookTestCase(BaseTestCase): |
|
|
self.assertRedirects(r, "/integrations/") |
|
|
self.assertRedirects(r, "/integrations/") |
|
|
|
|
|
|
|
|
c = Channel.objects.get() |
|
|
c = Channel.objects.get() |
|
|
self.assertEqual(c.value, '{"headers": "", "post_data": "", "url_down": "http://foo.com", "url_up": "https://bar.com"}') |
|
|
|
|
|
|
|
|
self.assertEqual(c.value, '{"headers": {}, "post_data": "", "url_down": "http://foo.com", "url_up": "https://bar.com"}') |
|
|
|
|
|
|
|
|
def test_it_adds_webhook_using_team_access(self): |
|
|
def test_it_adds_webhook_using_team_access(self): |
|
|
form = {"url_down": "http://foo.com", "url_up": "https://bar.com"} |
|
|
form = {"url_down": "http://foo.com", "url_up": "https://bar.com"} |
|
@ -30,7 +30,7 @@ class AddWebhookTestCase(BaseTestCase): |
|
|
|
|
|
|
|
|
c = Channel.objects.get() |
|
|
c = Channel.objects.get() |
|
|
self.assertEqual(c.user, self.alice) |
|
|
self.assertEqual(c.user, self.alice) |
|
|
self.assertEqual(c.value, '{"headers": "", "post_data": "", "url_down": "http://foo.com", "url_up": "https://bar.com"}') |
|
|
|
|
|
|
|
|
self.assertEqual(c.value, '{"headers": {}, "post_data": "", "url_down": "http://foo.com", "url_up": "https://bar.com"}') |
|
|
|
|
|
|
|
|
def test_it_rejects_bad_urls(self): |
|
|
def test_it_rejects_bad_urls(self): |
|
|
urls = [ |
|
|
urls = [ |
|
@ -59,7 +59,7 @@ class AddWebhookTestCase(BaseTestCase): |
|
|
self.client.post(self.url, form) |
|
|
self.client.post(self.url, form) |
|
|
|
|
|
|
|
|
c = Channel.objects.get() |
|
|
c = Channel.objects.get() |
|
|
self.assertEqual(c.value, '{"headers": "", "post_data": "", "url_down": "", "url_up": "http://foo.com"}') |
|
|
|
|
|
|
|
|
self.assertEqual(c.value, '{"headers": {}, "post_data": "", "url_down": "", "url_up": "http://foo.com"}') |
|
|
|
|
|
|
|
|
def test_it_adds_post_data(self): |
|
|
def test_it_adds_post_data(self): |
|
|
form = {"url_down": "http://foo.com", "post_data": "hello"} |
|
|
form = {"url_down": "http://foo.com", "post_data": "hello"} |
|
@ -69,15 +69,15 @@ class AddWebhookTestCase(BaseTestCase): |
|
|
self.assertRedirects(r, "/integrations/") |
|
|
self.assertRedirects(r, "/integrations/") |
|
|
|
|
|
|
|
|
c = Channel.objects.get() |
|
|
c = Channel.objects.get() |
|
|
self.assertEqual(c.value, '{"headers": "", "post_data": "hello", "url_down": "http://foo.com", "url_up": ""}') |
|
|
|
|
|
|
|
|
self.assertEqual(c.value, '{"headers": {}, "post_data": "hello", "url_down": "http://foo.com", "url_up": ""}') |
|
|
|
|
|
|
|
|
def test_it_adds_headers(self): |
|
|
def test_it_adds_headers(self): |
|
|
form = {"url_down": "http://foo.com", "headers": '{"test": "123"}'} |
|
|
|
|
|
|
|
|
form = {"url_down": "http://foo.com", "header_key[]": ["test", "test2"], "header_value[]": ["123", "abc"]} |
|
|
|
|
|
|
|
|
self.client.login(username="[email protected]", password="password") |
|
|
self.client.login(username="[email protected]", password="password") |
|
|
r = self.client.post(self.url, form) |
|
|
r = self.client.post(self.url, form) |
|
|
self.assertRedirects(r, "/integrations/") |
|
|
self.assertRedirects(r, "/integrations/") |
|
|
|
|
|
|
|
|
c = Channel.objects.get() |
|
|
c = Channel.objects.get() |
|
|
self.assertEqual(c.value, '{"headers": "{\\\"test\\\": \\\"123\\\"}", "post_data": "", "url_down": "http://foo.com", "url_up": ""}') |
|
|
|
|
|
|
|
|
self.assertEqual(c.value, '{"headers": {"test": "123", "test2": "abc"}, "post_data": "", "url_down": "http://foo.com", "url_up": ""}') |
|
|
|
|
|
|