foreman_webhooks 3.2.1 → 3.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aaeb5b54bb4d6679430fefcb7d569bf57d19d5df1aacc73b34dae585766878b1
4
- data.tar.gz: df3d0865057e2bd34877d7a1cad67303e63c369d691efeda0e149f3ca7a27581
3
+ metadata.gz: 457b89d953e3410524cd3ad5aee4d63ca47192037523ee2c606e69d291e0e8e2
4
+ data.tar.gz: 9e43a93a35c44a7e8d0d3fdcecef2f4196120645ffe9b0517fba5a3ded221620
5
5
  SHA512:
6
- metadata.gz: a6eba6fd3256c144a37615dea8d61519d3878c9ea8a3b0ef8c36f3e45d61b5d1b911ece90e5027d5af6aadda94c79ce272f6051eeb7ce626e647aca520b49326
7
- data.tar.gz: b19adb7f561f38537f5826ceca7d0e53ca1617e049071912e0504c62f8a31550f6e117f46cfa47901d2b05fb159ad589baaf0c2b469b91a0962a515451fd8c12
6
+ metadata.gz: 7dca14e67eb8d98c5677ecdbb0e11a1a580fa9d6499f4c164aa263668a7709cee10441cd552fb4f0d2b9a74965520d0e4f29f7c311020817e70d4de3af96ca71
7
+ data.tar.gz: 939a492793d040c4555e73eedf6dc8a66cc4c72121addfdc3ac659ba5642599ad6960c1a3182299e0e98321d7dec52e524b52450d11d0eb5766e546e612a387c
@@ -6,13 +6,25 @@ module ForemanWebhooks
6
6
 
7
7
  def perform(options)
8
8
  webhook = Webhook.unscoped.find_by(id: options[:webhook_id])
9
- WebhookService.new(
9
+ result = WebhookService.new(
10
10
  webhook: webhook,
11
11
  headers: options[:headers],
12
12
  url: options[:url],
13
13
  event_name: options[:event_name],
14
14
  payload: options[:payload]
15
15
  ).execute
16
+
17
+ return unless result[:status] == :error
18
+
19
+ raise [result[:http_status], result[:message]].compact.join(': ')
20
+ end
21
+
22
+ rescue_from(StandardError) do |error|
23
+ Foreman::Logging.logger('background').error(
24
+ 'DeliverWebhook: '\
25
+ "Error while delivering - #{error.message}"
26
+ )
27
+ raise error # propagate the error to the tasking system to properly report it there
16
28
  end
17
29
 
18
30
  def webhook_id
@@ -82,8 +82,8 @@ class Webhook < ApplicationRecord
82
82
  def test(payload: nil)
83
83
  ForemanWebhooks::WebhookService.new(
84
84
  webhook: self,
85
- headers: rendered_headers(event, {}),
86
- url: rendered_targed_url(event, {}),
85
+ headers: http_headers,
86
+ url: target_url,
87
87
  event_name: event,
88
88
  payload: test_payload(payload || '')
89
89
  ).execute
@@ -1,6 +1,6 @@
1
1
  <%#
2
2
  name: Katello Content View
3
- description: Example payload for content_view_*.event.foreman
3
+ description: Example payload for actions.katello.content_view_*.event.foreman
4
4
  snippet: false
5
5
  model: WebhookTemplate
6
6
  -%>
@@ -1,6 +1,6 @@
1
1
  <%#
2
2
  name: Katello Promote
3
- description: Example payload for actions.katello.content_view.promote_suceeded
3
+ description: Example payload for actions.katello.content_view.promote_suceeded.event.foreman
4
4
  snippet: false
5
5
  model: WebhookTemplate
6
6
  -%>
@@ -1,6 +1,6 @@
1
1
  <%#
2
2
  name: Katello Publish
3
- description: Example payload for actions.katello.content_view.publish_suceeded
3
+ description: Example payload for actions.katello.content_view.publish_suceeded.event.foreman
4
4
  snippet: false
5
5
  model: WebhookTemplate
6
6
  -%>
@@ -1,6 +1,6 @@
1
1
  <%#
2
2
  name: Katello Sync
3
- description: Example payload for actions.katello.repository.sync_succeeded
3
+ description: Example payload for actions.katello.repository.sync_succeeded.event.foreman
4
4
  snippet: false
5
5
  model: WebhookTemplate
6
6
  -%>
@@ -1,6 +1,6 @@
1
1
  <%#
2
2
  name: Remote Execution Host Job
3
- description: Example payload for actions.remote_execution.run_host_job_succeeded
3
+ description: Example payload for actions.remote_execution.run_host_job_succeeded.event.foreman
4
4
  snippet: false
5
5
  model: WebhookTemplate
6
6
  -%>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForemanWebhooks
4
- VERSION = "3.2.1"
4
+ VERSION = "3.2.2"
5
5
  end
@@ -10,7 +10,8 @@ module ForemanWebhooks
10
10
  end
11
11
 
12
12
  it 'executes the webhook service' do
13
- ::ForemanWebhooks::WebhookService.any_instance.expects(:execute).once
13
+ result = { status: :success }
14
+ ::ForemanWebhooks::WebhookService.any_instance.expects(:execute).once.returns(result)
14
15
  job.perform_now
15
16
  end
16
17
  end
@@ -58,18 +58,16 @@ const WebhookTestModal = ({ toTest }) => {
58
58
  enforceFocus
59
59
  className="webhooks-modal"
60
60
  >
61
- <p>
62
- {sprintf(
63
- __(
64
- 'You are about to test %s webhook.' +
65
- '\n' +
66
- 'Please, note that this will not contain actual information or render the attached template.' +
67
- '\n' +
68
- 'You can specify below a custom payload to test the webhook with.'
69
- ),
70
- name
71
- )}
72
- </p>
61
+ {`${sprintf(__('You are about to test %s webhook.'), name)} `}
62
+ {`${__(
63
+ 'Please, note that this will not contain actual information or render the attached template.'
64
+ )} `}
65
+ {`${__(
66
+ 'In case you are using dynamic URL (ERB template), this will not be rendered correctly due to the absence of a real object.'
67
+ )} `}
68
+ {__('You can specify below a custom payload to test the webhook with.')}
69
+ <br />
70
+ <br />
73
71
  <ForemanForm
74
72
  onSubmit={handleSubmit}
75
73
  initialValues={initialTestValues}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_webhooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timo Goebel
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-09 00:00:00.000000000 Z
11
+ date: 2023-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -245,7 +245,7 @@ licenses:
245
245
  - GPL-3.0
246
246
  metadata:
247
247
  is_foreman_plugin: 'true'
248
- post_install_message:
248
+ post_install_message:
249
249
  rdoc_options: []
250
250
  require_paths:
251
251
  - lib
@@ -260,8 +260,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
260
260
  - !ruby/object:Gem::Version
261
261
  version: '0'
262
262
  requirements: []
263
- rubygems_version: 3.1.6
264
- signing_key:
263
+ rubygems_version: 3.4.10
264
+ signing_key:
265
265
  specification_version: 4
266
266
  summary: Configure webhooks for Foreman.
267
267
  test_files: