From 08d60d0b78e3054f2bc2c4880e80bb33af67ac67 Mon Sep 17 00:00:00 2001 From: zicklam Date: Mon, 6 May 2019 19:20:00 +0200 Subject: [PATCH] Update test_notification Template for webhooks - rename webhook_no_verify_ssl to disable_ssl_verification --- awx/main/notifications/webhook_backend.py | 8 ++++---- awx/main/tests/functional/test_notifications.py | 6 +++--- .../src/notifications/notificationTemplates.form.js | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/awx/main/notifications/webhook_backend.py b/awx/main/notifications/webhook_backend.py index 7c17c21723..e4fdc7de4a 100644 --- a/awx/main/notifications/webhook_backend.py +++ b/awx/main/notifications/webhook_backend.py @@ -15,13 +15,13 @@ logger = logging.getLogger('awx.main.notifications.webhook_backend') class WebhookBackend(AWXBaseEmailBackend): init_parameters = {"url": {"label": "Target URL", "type": "string"}, - "webhook_no_verify_ssl": {"label": "Verify SSL", "type": "bool"}, + "disable_ssl_verification": {"label": "Verify SSL", "type": "bool"}, "headers": {"label": "HTTP Headers", "type": "object"}} recipient_parameter = "url" sender_parameter = None - def __init__(self, headers, webhook_no_verify_ssl=False, fail_silently=False, **kwargs): - self.webhook_no_verify_ssl = webhook_no_verify_ssl + def __init__(self, headers, disable_ssl_verification=False, fail_silently=False, **kwargs): + self.disable_ssl_verification = disable_ssl_verification self.headers = headers super(WebhookBackend, self).__init__(fail_silently=fail_silently) @@ -36,7 +36,7 @@ class WebhookBackend(AWXBaseEmailBackend): r = requests.post("{}".format(m.recipients()[0]), json=m.body, headers=self.headers, - verify=(not self.webhook_no_verify_ssl)) + verify=(not self.disable_ssl_verification)) if r.status_code >= 400: logger.error(smart_text(_("Error sending notification webhook: {}").format(r.text))) if not self.fail_silently: diff --git a/awx/main/tests/functional/test_notifications.py b/awx/main/tests/functional/test_notifications.py index b9fc394d12..5c2bf74d5a 100644 --- a/awx/main/tests/functional/test_notifications.py +++ b/awx/main/tests/functional/test_notifications.py @@ -28,7 +28,7 @@ def test_basic_parameterization(get, post, user, organization): description="test webhook", organization=organization.id, notification_type="webhook", - notification_configuration=dict(url="http://localhost", + notification_configuration=dict(url="http://localhost", disable_ssl_verification=False, headers={"Test": "Header"})), u) assert response.status_code == 201 @@ -81,7 +81,7 @@ def test_inherited_notification_templates(get, post, user, organization, project description="test webhook {}".format(nfiers), organization=organization.id, notification_type="webhook", - notification_configuration=dict(url="http://localhost", + notification_configuration=dict(url="http://localhost", disable_ssl_verification=False, headers={"Test": "Header"})), u) assert response.status_code == 201 @@ -143,7 +143,7 @@ def test_custom_environment_injection(post, user, organization): description="test webhook", organization=organization.id, notification_type="webhook", - notification_configuration=dict(url="https://example.org", + notification_configuration=dict(url="https://example.org", disable_ssl_verification=False, headers={"Test": "Header"})), u) assert response.status_code == 201 diff --git a/awx/ui/client/src/notifications/notificationTemplates.form.js b/awx/ui/client/src/notifications/notificationTemplates.form.js index 51876a3cf6..fa291d7654 100644 --- a/awx/ui/client/src/notifications/notificationTemplates.form.js +++ b/awx/ui/client/src/notifications/notificationTemplates.form.js @@ -399,7 +399,7 @@ export default ['i18n', function(i18n) { subForm: 'typeSubForm', ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)' }, - webhook_no_verify_ssl: { + disable_ssl_verification: { label: i18n._('Disable SSL Verification'), type: 'checkbox', ngShow: "notification_type.value == 'webhook' ",