fluent-plugin-http-pull 0.7.0 → 0.8.1

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.
@@ -1,79 +1,79 @@
1
- require "helper"
2
- require "fluent/plugin/in_http_pull.rb"
3
-
4
- require 'ostruct'
5
-
6
- class HttpPullInputTestRequestMethod < Test::Unit::TestCase
7
- @stub_server = nil
8
-
9
- setup do
10
- @stub_server = StubServer.new
11
- @stub_server.start
12
- end
13
-
14
- teardown do
15
- @stub_server.shutdown
16
- end
17
-
18
- sub_test_case "request method" do
19
- TEST_INTERVAL_3_POST = %[
20
- tag test
21
- url http://127.0.0.1:3939/method_post
22
-
23
- interval 3s
24
- format json
25
- http_method post
26
- ]
27
-
28
- TEST_INTERVAL_3_DELETE = %[
29
- tag test
30
- url http://127.0.0.1:3939/method_delete
31
-
32
- interval 3s
33
- format json
34
- http_method delete
35
- ]
36
-
37
- test 'interval 3 with :post' do
38
- d = create_driver TEST_INTERVAL_3_POST
39
- assert_equal("test", d.instance.tag)
40
- assert_equal(3, d.instance.interval)
41
-
42
- d.run(timeout: 8) do
43
- sleep 7
44
- end
45
- assert_equal(2, d.events.size)
46
-
47
- d.events.each do |tag, time, record|
48
- assert_equal("test", tag)
49
-
50
- assert_equal({"url"=>"http://127.0.0.1:3939/method_post","status"=>200, "message"=>{"status"=>"OK"}}, record)
51
- assert(time.is_a?(Fluent::EventTime))
52
- end
53
- end
54
-
55
- test 'interval 3 with :delete' do
56
- d = create_driver TEST_INTERVAL_3_DELETE
57
- assert_equal("test", d.instance.tag)
58
- assert_equal(3, d.instance.interval)
59
-
60
- d.run(timeout: 8) do
61
- sleep 7
62
- end
63
- assert_equal(2, d.events.size)
64
-
65
- d.events.each do |tag, time, record|
66
- assert_equal("test", tag)
67
-
68
- assert_equal({"url"=>"http://127.0.0.1:3939/method_delete","status"=>200, "message"=>{"status"=>"OK"}}, record)
69
- assert(time.is_a?(Fluent::EventTime))
70
- end
71
- end
72
- end
73
-
74
- private
75
-
76
- def create_driver(conf)
77
- Fluent::Test::Driver::Input.new(Fluent::Plugin::HttpPullInput).configure(conf)
78
- end
79
- end
1
+ require "helper"
2
+ require "fluent/plugin/in_http_pull.rb"
3
+
4
+ require 'ostruct'
5
+
6
+ class HttpPullInputTestRequestMethod < Test::Unit::TestCase
7
+ @stub_server = nil
8
+
9
+ setup do
10
+ @stub_server = StubServer.new
11
+ @stub_server.start
12
+ end
13
+
14
+ teardown do
15
+ @stub_server.shutdown
16
+ end
17
+
18
+ sub_test_case "request method" do
19
+ TEST_INTERVAL_3_POST = %[
20
+ tag test
21
+ url http://localhost:3939/method_post
22
+
23
+ interval 3s
24
+ format json
25
+ http_method post
26
+ ]
27
+
28
+ TEST_INTERVAL_3_DELETE = %[
29
+ tag test
30
+ url http://localhost:3939/method_delete
31
+
32
+ interval 3s
33
+ format json
34
+ http_method delete
35
+ ]
36
+
37
+ test 'interval 3 with :post' do
38
+ d = create_driver TEST_INTERVAL_3_POST
39
+ assert_equal("test", d.instance.tag)
40
+ assert_equal(3, d.instance.interval)
41
+
42
+ d.run(timeout: 8) do
43
+ sleep 7
44
+ end
45
+ assert_equal(2, d.events.size)
46
+
47
+ d.events.each do |tag, time, record|
48
+ assert_equal("test", tag)
49
+
50
+ assert_equal({"url"=>"http://localhost:3939/method_post","status"=>200, "message"=>{"status"=>"OK"}}, record)
51
+ assert(time.is_a?(Fluent::EventTime))
52
+ end
53
+ end
54
+
55
+ test 'interval 3 with :delete' do
56
+ d = create_driver TEST_INTERVAL_3_DELETE
57
+ assert_equal("test", d.instance.tag)
58
+ assert_equal(3, d.instance.interval)
59
+
60
+ d.run(timeout: 8) do
61
+ sleep 7
62
+ end
63
+ assert_equal(2, d.events.size)
64
+
65
+ d.events.each do |tag, time, record|
66
+ assert_equal("test", tag)
67
+
68
+ assert_equal({"url"=>"http://localhost:3939/method_delete","status"=>200, "message"=>{"status"=>"OK"}}, record)
69
+ assert(time.is_a?(Fluent::EventTime))
70
+ end
71
+ end
72
+ end
73
+
74
+ private
75
+
76
+ def create_driver(conf)
77
+ Fluent::Test::Driver::Input.new(Fluent::Plugin::HttpPullInput).configure(conf)
78
+ end
79
+ end
@@ -0,0 +1,173 @@
1
+ require "helper"
2
+ require "fluent/plugin/in_http_pull.rb"
3
+
4
+ require 'ostruct'
5
+
6
+ class HttpPullInputTestSSLBasic < Test::Unit::TestCase
7
+ @stub_server = nil
8
+
9
+ setup do
10
+ @stub_server = StubServer.new(4040, true)
11
+ @stub_server.start
12
+ end
13
+
14
+ teardown do
15
+ @stub_server.shutdown
16
+ end
17
+
18
+ sub_test_case "remote has valid ssl cert" do
19
+ TEST_INTERVAL_3_VALID_SSL_CONFIG = %[
20
+ tag test
21
+ url https://www.google.com
22
+
23
+ interval 3s
24
+ format none
25
+ status_only true
26
+ ]
27
+
28
+ # test 'interval 3' do
29
+ # d = create_driver TEST_INTERVAL_3_VALID_SSL_CONFIG
30
+ # assert_equal("test", d.instance.tag)
31
+ # assert_equal(3, d.instance.interval)
32
+
33
+ # d.run(timeout: 8) do
34
+ # sleep 7
35
+ # end
36
+ # assert_equal(2, d.events.size)
37
+
38
+ # d.events.each do |tag, time, record|
39
+ # assert_equal("test", tag)
40
+
41
+ # assert_equal({"url"=>"https://www.google.com","status"=>200}, record)
42
+ # assert(time.is_a?(Fluent::EventTime))
43
+ # end
44
+ # end
45
+ end
46
+
47
+ sub_test_case "remote has self-signed ssl cert" do
48
+ TEST_INTERVAL_3_CONFIG = %[
49
+ tag test
50
+ url https://localhost:4040
51
+
52
+ interval 3s
53
+ format none
54
+ status_only true
55
+ ]
56
+
57
+ TEST_INTERVAL_3_VERIFY_FALSE_CONFIG = %[
58
+ tag test
59
+ url https://localhost:4040
60
+
61
+ interval 3s
62
+ format none
63
+ status_only true
64
+ verify_ssl false
65
+ ]
66
+
67
+ TEST_INTERVAL_3_CA_CONFIG = %[
68
+ tag test
69
+ url https://localhost:4040
70
+
71
+ interval 3s
72
+ format none
73
+ status_only true
74
+ ca_path #{Dir.pwd}/test/helper/.ssl
75
+ ca_file #{Dir.pwd}/test/helper/.ssl/server.crt
76
+ ]
77
+
78
+ TEST_INTERVAL_3_INVALID_CA_CONFIG = %[
79
+ tag test
80
+ url https://localhost:4040
81
+
82
+ interval 3s
83
+ format none
84
+ status_only true
85
+ ca_path #{Dir.pwd}/test/helper/.ssl_not_exist
86
+ ca_file #{Dir.pwd}/test/helper/.ssl_not_exist/server.crt
87
+ ]
88
+
89
+ test 'should be fail with no ssl options' do
90
+ d = create_driver TEST_INTERVAL_3_CONFIG
91
+ assert_equal("test", d.instance.tag)
92
+ assert_equal(3, d.instance.interval)
93
+
94
+ d.run(timeout: 8) do
95
+ sleep 7
96
+ end
97
+ assert_equal(2, d.events.size)
98
+
99
+ d.events.each do |tag, time, record|
100
+ assert_equal("test", tag)
101
+
102
+ assert_equal("https://localhost:4040", record["url"])
103
+ assert(time.is_a?(Fluent::EventTime))
104
+
105
+ assert_equal(0, record["status"])
106
+ assert_not_nil(record["error"])
107
+ end
108
+ end
109
+
110
+ test 'should be success with verify_ssl false' do
111
+ d = create_driver TEST_INTERVAL_3_VERIFY_FALSE_CONFIG
112
+ assert_equal("test", d.instance.tag)
113
+ assert_equal(3, d.instance.interval)
114
+
115
+ d.run(timeout: 8) do
116
+ sleep 7
117
+ end
118
+ assert_equal(2, d.events.size)
119
+
120
+ d.events.each do |tag, time, record|
121
+ assert_equal("test", tag)
122
+
123
+ assert_equal({"url"=>"https://localhost:4040","status"=>200}, record)
124
+ assert(time.is_a?(Fluent::EventTime))
125
+ end
126
+ end
127
+
128
+ test 'should be success with valid ca options' do
129
+ d = create_driver TEST_INTERVAL_3_CA_CONFIG
130
+ assert_equal("test", d.instance.tag)
131
+ assert_equal(3, d.instance.interval)
132
+
133
+ d.run(timeout: 8) do
134
+ sleep 7
135
+ end
136
+ assert_equal(2, d.events.size)
137
+
138
+ d.events.each do |tag, time, record|
139
+ assert_equal("test", tag)
140
+
141
+ assert_equal({"url"=>"https://localhost:4040","status"=>200}, record)
142
+ assert(time.is_a?(Fluent::EventTime))
143
+ end
144
+ end
145
+
146
+ test 'should be fail with invalid ca options' do
147
+ d = create_driver TEST_INTERVAL_3_INVALID_CA_CONFIG
148
+ assert_equal("test", d.instance.tag)
149
+ assert_equal(3, d.instance.interval)
150
+
151
+ d.run(timeout: 8) do
152
+ sleep 7
153
+ end
154
+ assert_equal(2, d.events.size)
155
+
156
+ d.events.each do |tag, time, record|
157
+ assert_equal("test", tag)
158
+
159
+ assert_equal("https://localhost:4040", record["url"])
160
+ assert(time.is_a?(Fluent::EventTime))
161
+
162
+ assert_equal(0, record["status"])
163
+ assert_not_nil(record["error"])
164
+ end
165
+ end
166
+ end
167
+
168
+ private
169
+
170
+ def create_driver(conf)
171
+ Fluent::Test::Driver::Input.new(Fluent::Plugin::HttpPullInput).configure(conf)
172
+ end
173
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-http-pull
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - filepang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-20 00:00:00.000000000 Z
11
+ date: 2018-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -144,6 +144,11 @@ files:
144
144
  - fluent-plugin-http-pull.gemspec
145
145
  - lib/fluent/plugin/in_http_pull.rb
146
146
  - test/helper.rb
147
+ - test/helper/.ssl/README
148
+ - test/helper/.ssl/server.crt
149
+ - test/helper/.ssl/server.csr
150
+ - test/helper/.ssl/server.key
151
+ - test/helper/.ssl/server.key.org
147
152
  - test/helper/stub_proxy.rb
148
153
  - test/helper/stub_server.rb
149
154
  - test/plugin/test_in_http_pull.rb
@@ -152,6 +157,7 @@ files:
152
157
  - test/plugin/test_in_http_pull_http_header.rb
153
158
  - test/plugin/test_in_http_pull_proxy.rb
154
159
  - test/plugin/test_in_http_pull_request_method.rb
160
+ - test/plugin/test_in_http_pull_ssl.rb
155
161
  homepage: https://github.com/HatsuneMiku3939/fluent-plugin-http-pull
156
162
  licenses:
157
163
  - Apache-2.0
@@ -178,6 +184,11 @@ specification_version: 4
178
184
  summary: fluent-plugin-http-pull
179
185
  test_files:
180
186
  - test/helper.rb
187
+ - test/helper/.ssl/README
188
+ - test/helper/.ssl/server.crt
189
+ - test/helper/.ssl/server.csr
190
+ - test/helper/.ssl/server.key
191
+ - test/helper/.ssl/server.key.org
181
192
  - test/helper/stub_proxy.rb
182
193
  - test/helper/stub_server.rb
183
194
  - test/plugin/test_in_http_pull.rb
@@ -186,3 +197,4 @@ test_files:
186
197
  - test/plugin/test_in_http_pull_http_header.rb
187
198
  - test/plugin/test_in_http_pull_proxy.rb
188
199
  - test/plugin/test_in_http_pull_request_method.rb
200
+ - test/plugin/test_in_http_pull_ssl.rb