hammer_cli_foreman_webhooks 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3349e5ec869114bfd9b702fa6f1e43204ec39b63d47dd0a2557fdc071fab3e1
|
4
|
+
data.tar.gz: 00424fc9386abcd61e9aee533b73b2dbce63dfafaf46cc5f59303e826b75455a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81d6d4db570f2e88a9706cf79a579488b86d690848dacc52101ec3c45fd487b2643879bc2bb9e558f63764ecf7b31f9810111912668ec14f37b1bf6267c5bdda
|
7
|
+
data.tar.gz: cdc9dcf879643d4d4aefbd7673393f8e9bda5d0e2035be834604bb6e408715f34772b90f2fea5b914b4d5a94a0f48e2e9b5edb6da2621e14bc67f5861a12c672
|
@@ -21,11 +21,11 @@ module HammerCLIForemanWebhooks
|
|
21
21
|
field :http_method, _('HTTP Method')
|
22
22
|
field :http_content_type, _('HTTP Content Type')
|
23
23
|
custom_field Fields::Reference, label: _('Webhook Template'), path: [:webhook_template]
|
24
|
-
field :user, _('User'), Fields::Field
|
25
|
-
field :
|
26
|
-
field :proxy_authorization, _('Proxy Authorization'), Fields::Boolean
|
24
|
+
field :user, _('User'), Fields::Field
|
25
|
+
field :verify_ssl, _('Verify SSL'), Fields::Boolean
|
26
|
+
field :proxy_authorization, _('Proxy Authorization'), Fields::Boolean
|
27
27
|
field :ssl_ca_certs, _('X509 Certification Authorities'), Fields::Text, sets: %w[ADDITIONAL ALL]
|
28
|
-
collection :http_headers, _('HTTP Headers')
|
28
|
+
collection :http_headers, _('HTTP Headers') do
|
29
29
|
custom_field Fields::KeyValue
|
30
30
|
end
|
31
31
|
HammerCLIForeman::References.timestamps(self)
|
@@ -42,7 +42,7 @@ module HammerCLIForemanWebhooks
|
|
42
42
|
|
43
43
|
build_options without: %i[ssl_ca_certs http_headers]
|
44
44
|
|
45
|
-
extend_with(HammerCLIForemanWebhooks::CommandExtensions::Webhook.new(only:
|
45
|
+
extend_with(HammerCLIForemanWebhooks::CommandExtensions::Webhook.new(only: %i[option request_params]))
|
46
46
|
end
|
47
47
|
|
48
48
|
class UpdateCommand < HammerCLIForeman::UpdateCommand
|
@@ -51,7 +51,7 @@ module HammerCLIForemanWebhooks
|
|
51
51
|
|
52
52
|
build_options without: %i[ssl_ca_certs http_headers]
|
53
53
|
|
54
|
-
extend_with(HammerCLIForemanWebhooks::CommandExtensions::Webhook.new(only:
|
54
|
+
extend_with(HammerCLIForemanWebhooks::CommandExtensions::Webhook.new(only: %i[option request_params]))
|
55
55
|
end
|
56
56
|
|
57
57
|
class DeleteCommand < HammerCLIForeman::DeleteCommand
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
describe 'webhook' do
|
4
|
+
let(:base_cmd) { %w[webhook] }
|
5
|
+
let(:webhook) do
|
6
|
+
{
|
7
|
+
id: 1,
|
8
|
+
name: 'test',
|
9
|
+
target_url: 'https://app.example.com',
|
10
|
+
enabled: true,
|
11
|
+
event: 'user_created.event.foreman',
|
12
|
+
http_method: 'POST',
|
13
|
+
http_content_type: 'application/json',
|
14
|
+
webhook_template: { id: 1, name: 'test' },
|
15
|
+
user: 'admin',
|
16
|
+
verify_ssl: true,
|
17
|
+
proxy_authorization: true,
|
18
|
+
ssl_ca_certs: 'certs',
|
19
|
+
'http_headers' => '{"X-Shellhook-Arg-0":"test","X-Shellhook-Arg-1":"2"}',
|
20
|
+
created_at: '01/10/2022',
|
21
|
+
updated_at: '01/10/2022'
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'list' do
|
26
|
+
let(:cmd) { base_cmd << 'list' }
|
27
|
+
|
28
|
+
it 'should list all webhooks' do
|
29
|
+
api_expects(:webhooks, :index, 'List').with_params(
|
30
|
+
'page' => 1, 'per_page' => 1000
|
31
|
+
).returns(index_response([webhook]))
|
32
|
+
|
33
|
+
output = IndexMatcher.new(
|
34
|
+
[
|
35
|
+
['ID', 'NAME', 'TARGET URL', 'ENABLED'],
|
36
|
+
['1', 'test', 'https://app.example.com', 'yes']
|
37
|
+
]
|
38
|
+
)
|
39
|
+
expected_result = success_result(output)
|
40
|
+
|
41
|
+
result = run_cmd(cmd)
|
42
|
+
assert_cmd(expected_result, result)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe 'create' do
|
47
|
+
let(:cmd) { base_cmd << 'create' }
|
48
|
+
let(:params) do
|
49
|
+
%w[
|
50
|
+
--name=test --target-url=https://app.example.com --enabled=true
|
51
|
+
--event=user_created.event.foreman
|
52
|
+
--http-headers=X-Shellhook-Arg-0=test,X-Shellhook-Arg-1=2
|
53
|
+
]
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should create a webhook' do
|
57
|
+
api_expects(:webhooks, :create).with_params(
|
58
|
+
'webhook' => {
|
59
|
+
'target_url' => 'https://app.example.com', 'name' => 'test',
|
60
|
+
'enabled' => true, 'event' => 'user_created.event.foreman',
|
61
|
+
'http_headers' => '{"X-Shellhook-Arg-0":"test","X-Shellhook-Arg-1":"2"}'
|
62
|
+
}
|
63
|
+
).returns(webhook)
|
64
|
+
|
65
|
+
expected_result = success_result("Webhook [test] created.\n")
|
66
|
+
|
67
|
+
result = run_cmd(cmd + params)
|
68
|
+
assert_cmd(expected_result, result)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe 'update' do
|
73
|
+
let(:cmd) { base_cmd << 'update' }
|
74
|
+
let(:params) do
|
75
|
+
%w[
|
76
|
+
--id=1 --target-url=https://app.example.com --enabled=true
|
77
|
+
--event=user_created.event.foreman
|
78
|
+
--http-headers=X-Shellhook-Arg-0=test,X-Shellhook-Arg-1=2
|
79
|
+
]
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should update a webhook' do
|
83
|
+
api_expects(:webhooks, :update).with_params(
|
84
|
+
'id' => '1',
|
85
|
+
'webhook' => {
|
86
|
+
'target_url' => 'https://app.example.com',
|
87
|
+
'enabled' => true, 'event' => 'user_created.event.foreman',
|
88
|
+
'http_headers' => '{"X-Shellhook-Arg-0":"test","X-Shellhook-Arg-1":"2"}'
|
89
|
+
}
|
90
|
+
).returns(webhook)
|
91
|
+
|
92
|
+
expected_result = success_result("Webhook [test] updated.\n")
|
93
|
+
|
94
|
+
result = run_cmd(cmd + params)
|
95
|
+
assert_cmd(expected_result, result)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe 'info' do
|
100
|
+
let(:cmd) { base_cmd << 'info' }
|
101
|
+
let(:params) { %w[--id=1] }
|
102
|
+
|
103
|
+
it 'should show a webhook' do
|
104
|
+
api_expects(:webhooks, :show, 'Show').with_params('id' => '1').returns(webhook)
|
105
|
+
|
106
|
+
expected_result = success_result(/X-Shellhook-Arg-0/)
|
107
|
+
|
108
|
+
result = run_cmd(cmd + params)
|
109
|
+
assert_cmd(expected_result, result)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe 'delete' do
|
114
|
+
let(:cmd) { base_cmd << 'delete' }
|
115
|
+
let(:params) { %w[--id=1] }
|
116
|
+
|
117
|
+
it 'should delete a webhook' do
|
118
|
+
api_expects(:webhooks, :destroy, 'Delete').with_params('id' => '1').returns(webhook)
|
119
|
+
|
120
|
+
expected_result = success_result("Webhook [test] deleted.\n")
|
121
|
+
|
122
|
+
result = run_cmd(cmd + params)
|
123
|
+
assert_cmd(expected_result, result)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hammer_cli_foreman_webhooks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oleh Fedorenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hammer_cli_foreman
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- test/data/3.3/foreman_api.json
|
50
50
|
- test/functional/test_helper.rb
|
51
51
|
- test/functional/webhook_template_test.rb
|
52
|
+
- test/functional/webhook_test.rb
|
52
53
|
- test/test_helper.rb
|
53
54
|
homepage: https://github.com/theforeman/hammer-cli-foreman-webhooks
|
54
55
|
licenses:
|
@@ -77,4 +78,5 @@ test_files:
|
|
77
78
|
- test/data/3.3/foreman_api.json
|
78
79
|
- test/functional/test_helper.rb
|
79
80
|
- test/functional/webhook_template_test.rb
|
81
|
+
- test/functional/webhook_test.rb
|
80
82
|
- test/test_helper.rb
|