mirror of
https://github.com/ansible/awx.git
synced 2024-10-27 17:55:10 +03:00
Merge pull request #3839 from zicklam/webhook_disable_ssl_verify
Add "Disable SSL Verification" checkbox to webhook notification Reviewed-by: https://github.com/softwarefactory-project-zuul[bot]
This commit is contained in:
commit
186ec88581
@ -15,11 +15,13 @@ logger = logging.getLogger('awx.main.notifications.webhook_backend')
|
|||||||
class WebhookBackend(AWXBaseEmailBackend):
|
class WebhookBackend(AWXBaseEmailBackend):
|
||||||
|
|
||||||
init_parameters = {"url": {"label": "Target URL", "type": "string"},
|
init_parameters = {"url": {"label": "Target URL", "type": "string"},
|
||||||
|
"disable_ssl_verification": {"label": "Verify SSL", "type": "bool", "default": False},
|
||||||
"headers": {"label": "HTTP Headers", "type": "object"}}
|
"headers": {"label": "HTTP Headers", "type": "object"}}
|
||||||
recipient_parameter = "url"
|
recipient_parameter = "url"
|
||||||
sender_parameter = None
|
sender_parameter = None
|
||||||
|
|
||||||
def __init__(self, headers, fail_silently=False, **kwargs):
|
def __init__(self, headers, disable_ssl_verification=False, fail_silently=False, **kwargs):
|
||||||
|
self.disable_ssl_verification = disable_ssl_verification
|
||||||
self.headers = headers
|
self.headers = headers
|
||||||
super(WebhookBackend, self).__init__(fail_silently=fail_silently)
|
super(WebhookBackend, self).__init__(fail_silently=fail_silently)
|
||||||
|
|
||||||
@ -33,7 +35,8 @@ class WebhookBackend(AWXBaseEmailBackend):
|
|||||||
for m in messages:
|
for m in messages:
|
||||||
r = requests.post("{}".format(m.recipients()[0]),
|
r = requests.post("{}".format(m.recipients()[0]),
|
||||||
json=m.body,
|
json=m.body,
|
||||||
headers=self.headers)
|
headers=self.headers,
|
||||||
|
verify=(not self.disable_ssl_verification))
|
||||||
if r.status_code >= 400:
|
if r.status_code >= 400:
|
||||||
logger.error(smart_text(_("Error sending notification webhook: {}").format(r.text)))
|
logger.error(smart_text(_("Error sending notification webhook: {}").format(r.text)))
|
||||||
if not self.fail_silently:
|
if not self.fail_silently:
|
||||||
|
@ -28,7 +28,7 @@ def test_basic_parameterization(get, post, user, organization):
|
|||||||
description="test webhook",
|
description="test webhook",
|
||||||
organization=organization.id,
|
organization=organization.id,
|
||||||
notification_type="webhook",
|
notification_type="webhook",
|
||||||
notification_configuration=dict(url="http://localhost",
|
notification_configuration=dict(url="http://localhost", disable_ssl_verification=False,
|
||||||
headers={"Test": "Header"})),
|
headers={"Test": "Header"})),
|
||||||
u)
|
u)
|
||||||
assert response.status_code == 201
|
assert response.status_code == 201
|
||||||
@ -81,7 +81,7 @@ def test_inherited_notification_templates(get, post, user, organization, project
|
|||||||
description="test webhook {}".format(nfiers),
|
description="test webhook {}".format(nfiers),
|
||||||
organization=organization.id,
|
organization=organization.id,
|
||||||
notification_type="webhook",
|
notification_type="webhook",
|
||||||
notification_configuration=dict(url="http://localhost",
|
notification_configuration=dict(url="http://localhost", disable_ssl_verification=False,
|
||||||
headers={"Test": "Header"})),
|
headers={"Test": "Header"})),
|
||||||
u)
|
u)
|
||||||
assert response.status_code == 201
|
assert response.status_code == 201
|
||||||
@ -143,7 +143,7 @@ def test_custom_environment_injection(post, user, organization):
|
|||||||
description="test webhook",
|
description="test webhook",
|
||||||
organization=organization.id,
|
organization=organization.id,
|
||||||
notification_type="webhook",
|
notification_type="webhook",
|
||||||
notification_configuration=dict(url="https://example.org",
|
notification_configuration=dict(url="https://example.org", disable_ssl_verification=False,
|
||||||
headers={"Test": "Header"})),
|
headers={"Test": "Header"})),
|
||||||
u)
|
u)
|
||||||
assert response.status_code == 201
|
assert response.status_code == 201
|
||||||
|
@ -399,6 +399,13 @@ export default ['i18n', function(i18n) {
|
|||||||
subForm: 'typeSubForm',
|
subForm: 'typeSubForm',
|
||||||
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)'
|
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)'
|
||||||
},
|
},
|
||||||
|
disable_ssl_verification: {
|
||||||
|
label: i18n._('Disable SSL Verification'),
|
||||||
|
type: 'checkbox',
|
||||||
|
ngShow: "notification_type.value == 'webhook' ",
|
||||||
|
subForm: 'typeSubForm',
|
||||||
|
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)'
|
||||||
|
},
|
||||||
headers: {
|
headers: {
|
||||||
label: i18n._('HTTP Headers'),
|
label: i18n._('HTTP Headers'),
|
||||||
dataTitle: i18n._('HTTP Headers'),
|
dataTitle: i18n._('HTTP Headers'),
|
||||||
|
Loading…
Reference in New Issue
Block a user