fluentd 0.14.13-x86-mingw32 → 0.14.17-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fluentd might be problematic. Click here for more details.

Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -5
  3. data/ChangeLog +106 -0
  4. data/MAINTAINERS.md +5 -0
  5. data/README.md +25 -0
  6. data/example/worker_section.conf +36 -0
  7. data/fluentd.gemspec +1 -1
  8. data/lib/fluent/agent.rb +5 -2
  9. data/lib/fluent/command/binlog_reader.rb +1 -0
  10. data/lib/fluent/command/fluentd.rb +28 -12
  11. data/lib/fluent/command/plugin_config_formatter.rb +0 -1
  12. data/lib/fluent/command/plugin_generator.rb +1 -1
  13. data/lib/fluent/compat/detach_process_mixin.rb +8 -0
  14. data/lib/fluent/compat/input.rb +0 -10
  15. data/lib/fluent/compat/output.rb +0 -10
  16. data/lib/fluent/config/element.rb +22 -0
  17. data/lib/fluent/config/literal_parser.rb +2 -0
  18. data/lib/fluent/config/types.rb +2 -2
  19. data/lib/fluent/engine.rb +27 -10
  20. data/lib/fluent/env.rb +3 -3
  21. data/lib/fluent/log.rb +4 -1
  22. data/lib/fluent/plugin/base.rb +3 -0
  23. data/lib/fluent/plugin/filter.rb +2 -2
  24. data/lib/fluent/plugin/filter_parser.rb +17 -6
  25. data/lib/fluent/plugin/in_forward.rb +1 -1
  26. data/lib/fluent/plugin/in_http.rb +4 -0
  27. data/lib/fluent/plugin/in_monitor_agent.rb +8 -3
  28. data/lib/fluent/plugin/in_syslog.rb +3 -2
  29. data/lib/fluent/plugin/in_tail.rb +14 -3
  30. data/lib/fluent/plugin/in_udp.rb +6 -2
  31. data/lib/fluent/plugin/out_file.rb +5 -0
  32. data/lib/fluent/plugin/out_forward.rb +5 -2
  33. data/lib/fluent/plugin/output.rb +13 -8
  34. data/lib/fluent/plugin/parser_apache2.rb +1 -1
  35. data/lib/fluent/plugin/parser_syslog.rb +40 -1
  36. data/lib/fluent/plugin_helper/cert_option.rb +2 -2
  37. data/lib/fluent/plugin_helper/compat_parameters.rb +1 -1
  38. data/lib/fluent/plugin_helper/storage.rb +1 -1
  39. data/lib/fluent/root_agent.rb +36 -4
  40. data/lib/fluent/supervisor.rb +37 -6
  41. data/lib/fluent/system_config.rb +7 -0
  42. data/lib/fluent/time.rb +1 -0
  43. data/lib/fluent/version.rb +1 -1
  44. data/lib/fluent/winsvc.rb +25 -11
  45. data/test/command/test_fluentd.rb +253 -4
  46. data/test/config/test_element.rb +63 -0
  47. data/test/config/test_literal_parser.rb +1 -1
  48. data/test/config/test_system_config.rb +36 -6
  49. data/test/config/test_types.rb +19 -0
  50. data/test/plugin/test_filter_parser.rb +35 -0
  51. data/test/plugin/test_in_http.rb +58 -4
  52. data/test/plugin/test_in_monitor_agent.rb +90 -9
  53. data/test/plugin/test_in_tail.rb +16 -0
  54. data/test/plugin/test_in_udp.rb +11 -1
  55. data/test/plugin/test_out_file.rb +9 -0
  56. data/test/plugin/test_out_forward.rb +45 -0
  57. data/test/plugin/test_output.rb +15 -15
  58. data/test/plugin/test_output_as_buffered.rb +30 -2
  59. data/test/plugin/test_parser_apache2.rb +8 -0
  60. data/test/plugin/test_parser_syslog.rb +176 -0
  61. data/test/plugin_helper/test_server.rb +37 -31
  62. data/test/plugin_helper/test_storage.rb +9 -0
  63. data/test/test_log.rb +6 -0
  64. data/test/test_plugin_classes.rb +50 -0
  65. data/test/test_root_agent.rb +245 -14
  66. data/test/test_time_parser.rb +12 -0
  67. metadata +13 -5
@@ -75,6 +75,31 @@ module FluentPluginOutputAsBufferedTest
75
75
  end
76
76
  end
77
77
  class DummyCustomFormatBufferedOutput < DummyBareOutput
78
+ def initialize
79
+ super
80
+ @format_type_is_msgpack = nil
81
+ @prefer_delayed_commit = nil
82
+ @write = nil
83
+ @try_write = nil
84
+ end
85
+ def format(tag, time, record)
86
+ @format ? @format.call(tag, time, record) : [tag, time, record].to_json
87
+ end
88
+ def formatted_to_msgpack_binary?
89
+ @format_type_is_msgpack ? @format_type_is_msgpack.call : false
90
+ end
91
+ def prefer_delayed_commit
92
+ @prefer_delayed_commit ? @prefer_delayed_commit.call : false
93
+ end
94
+ def write(chunk)
95
+ @write ? @write.call(chunk) : nil
96
+ end
97
+ def try_write(chunk)
98
+ @try_write ? @try_write.call(chunk) : nil
99
+ end
100
+ end
101
+ # check for formatted_to_msgpack_binary compatibility
102
+ class DummyOldCustomFormatBufferedOutput < DummyBareOutput
78
103
  def initialize
79
104
  super
80
105
  @format_type_is_msgpack = nil
@@ -163,6 +188,7 @@ class BufferedOutputTest < Test::Unit::TestCase
163
188
  when :full then FluentPluginOutputAsBufferedTest::DummyFullFeatureOutput.new
164
189
  when :old_buf then FluentPluginOutputAsBufferedTest::DummyOldBufferedOutput.new
165
190
  when :old_obj then FluentPluginOutputAsBufferedTest::DummyOldObjectBufferedOutput.new
191
+ when :old_custom then FluentPluginOutputAsBufferedTest::DummyOldCustomFormatBufferedOutput.new
166
192
  else
167
193
  raise ArgumentError, "unknown type: #{type}"
168
194
  end
@@ -306,9 +332,11 @@ class BufferedOutputTest < Test::Unit::TestCase
306
332
  assert_equal 0, events_from_chunk.size
307
333
  end
308
334
 
309
- test 'plugin using custom format can iterate chunk in #write if #format returns msgpack' do
335
+ data('formatted_to_msgpack_binary?' => :custom,
336
+ 'formatted_to_msgpack_binary' => :old_custom)
337
+ test 'plugin using custom format can iterate chunk in #write if #format returns msgpack' do |out_type|
310
338
  events_from_chunk = []
311
- @i = create_output(:custom)
339
+ @i = create_output(out_type)
312
340
  @i.configure(config_element('ROOT','',{},[config_element('buffer','',@hash)]))
313
341
  @i.register(:prefer_delayed_commit){ false }
314
342
  @i.register(:format){ |tag, time, record| [tag,time,record].to_msgpack }
@@ -35,4 +35,12 @@ class Apache2ParserTest < ::Test::Unit::TestCase
35
35
  assert_equal(@expected, record)
36
36
  }
37
37
  end
38
+
39
+ def test_parse_with_escape_sequence
40
+ @parser.instance.parse('192.168.0.1 - - [28/Feb/2013:12:00:00 +0900] "GET /\" HTTP/1.1" 200 777 "referer \\\ \"" "user agent \\\ \""') { |_, record|
41
+ assert_equal('/\"', record['path'])
42
+ assert_equal('referer \\\ \"', record['referer'])
43
+ assert_equal('user agent \\\ \"', record['agent'])
44
+ }
45
+ end
38
46
  end
@@ -63,4 +63,180 @@ class SyslogParserTest < ::Test::Unit::TestCase
63
63
  assert_equal "Feb 28 00:00:12", record['time']
64
64
  end
65
65
  end
66
+
67
+ class TestRFC5424Regexp < self
68
+ def test_parse_with_rfc5424_message
69
+ @parser.configure(
70
+ 'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
71
+ 'message_format' => 'rfc5424',
72
+ )
73
+ text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
74
+ @parser.instance.parse(text) do |time, record|
75
+ assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
76
+ assert_equal "-", record["pid"]
77
+ assert_equal "-", record["msgid"]
78
+ assert_equal "-", record["extradata"]
79
+ assert_equal "Hi, from Fluentd!", record["message"]
80
+ end
81
+ end
82
+
83
+ def test_parse_with_rfc5424_message_without_time_format
84
+ @parser.configure(
85
+ 'message_format' => 'rfc5424',
86
+ )
87
+ text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
88
+ @parser.instance.parse(text) do |time, record|
89
+ assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
90
+ assert_equal "-", record["pid"]
91
+ assert_equal "-", record["msgid"]
92
+ assert_equal "-", record["extradata"]
93
+ assert_equal "Hi, from Fluentd!", record["message"]
94
+ end
95
+ end
96
+
97
+ def test_parse_with_rfc5424_structured_message
98
+ @parser.configure(
99
+ 'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
100
+ 'message_format' => 'rfc5424',
101
+ )
102
+ text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"] Hi, from Fluentd!'
103
+ @parser.instance.parse(text) do |time, record|
104
+ assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
105
+ assert_equal "11111", record["pid"]
106
+ assert_equal "ID24224", record["msgid"]
107
+ assert_equal "[exampleSDID@20224 iut=\"3\" eventSource=\"Application\" eventID=\"11211\"]",
108
+ record["extradata"]
109
+ assert_equal "Hi, from Fluentd!", record["message"]
110
+ end
111
+ end
112
+ end
113
+
114
+ class TestAutoRegexp < self
115
+ def test_auto_with_legacy_syslog_message
116
+ @parser.configure(
117
+ 'time_format' => '%b %d %M:%S:%H',
118
+ 'mseeage_format' => 'auto',
119
+ )
120
+ text = 'Feb 28 00:00:12 192.168.0.1 fluentd[11111]: [error] Syslog test'
121
+ @parser.instance.parse(text) do |time, record|
122
+ assert_equal(event_time("Feb 28 00:00:12", format: '%b %d %M:%S:%H'), time)
123
+ assert_equal(@expected, record)
124
+ end
125
+ end
126
+
127
+ def test_auto_with_legacy_syslog_priority_message
128
+ @parser.configure(
129
+ 'time_format' => '%b %d %M:%S:%H',
130
+ 'with_priority' => true,
131
+ 'mseeage_format' => 'auto',
132
+ )
133
+ text = '<6>Feb 28 12:00:00 192.168.0.1 fluentd[11111]: [error] Syslog test'
134
+ @parser.instance.parse(text) do |time, record|
135
+ assert_equal(event_time("Feb 28 12:00:00", format: '%b %d %M:%S:%H'), time)
136
+ assert_equal(@expected.merge('pri' => 6), record)
137
+ end
138
+ end
139
+
140
+ def test_parse_with_rfc5424_message
141
+ @parser.configure(
142
+ 'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
143
+ 'message_format' => 'auto',
144
+ )
145
+ text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
146
+ @parser.instance.parse(text) do |time, record|
147
+ assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
148
+ assert_equal "-", record["pid"]
149
+ assert_equal "-", record["msgid"]
150
+ assert_equal "-", record["extradata"]
151
+ assert_equal "Hi, from Fluentd!", record["message"]
152
+ end
153
+ end
154
+
155
+ def test_parse_with_rfc5424_structured_message
156
+ @parser.configure(
157
+ 'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
158
+ 'message_format' => 'auto',
159
+ )
160
+ text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"] Hi, from Fluentd!'
161
+ @parser.instance.parse(text) do |time, record|
162
+ assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
163
+ assert_equal "11111", record["pid"]
164
+ assert_equal "ID24224", record["msgid"]
165
+ assert_equal "[exampleSDID@20224 iut=\"3\" eventSource=\"Application\" eventID=\"11211\"]",
166
+ record["extradata"]
167
+ assert_equal "Hi, from Fluentd!", record["message"]
168
+ end
169
+ end
170
+
171
+ def test_parse_with_both_message_type
172
+ @parser.configure(
173
+ 'time_format' => '%b %d %M:%S:%H',
174
+ 'rfc5424_time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
175
+ 'message_format' => 'auto',
176
+ )
177
+ text = 'Feb 28 12:00:00 192.168.0.1 fluentd[11111]: [error] Syslog test'
178
+ @parser.instance.parse(text) do |time, record|
179
+ assert_equal(event_time("Feb 28 12:00:00", format: '%b %d %M:%S:%H'), time)
180
+ assert_equal(@expected, record)
181
+ end
182
+ text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"] Hi, from Fluentd!'
183
+ @parser.instance.parse(text) do |time, record|
184
+ assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
185
+ assert_equal "11111", record["pid"]
186
+ assert_equal "ID24224", record["msgid"]
187
+ assert_equal "[exampleSDID@20224 iut=\"3\" eventSource=\"Application\" eventID=\"11211\"]",
188
+ record["extradata"]
189
+ assert_equal "Hi, from Fluentd!", record["message"]
190
+ end
191
+ text = 'Feb 28 12:00:02 192.168.0.1 fluentd[11111]: [error] Syslog test'
192
+ @parser.instance.parse(text) do |time, record|
193
+ assert_equal(event_time("Feb 28 12:00:02", format: '%b %d %M:%S:%H'), time)
194
+ assert_equal(@expected, record)
195
+ end
196
+ text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
197
+ @parser.instance.parse(text) do |time, record|
198
+ assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
199
+ assert_equal "-", record["pid"]
200
+ assert_equal "-", record["msgid"]
201
+ assert_equal "-", record["extradata"]
202
+ assert_equal "Hi, from Fluentd!", record["message"]
203
+ end
204
+ end
205
+
206
+ def test_parse_with_both_message_type_and_priority
207
+ @parser.configure(
208
+ 'time_format' => '%b %d %M:%S:%H',
209
+ 'rfc5424_time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
210
+ 'with_priority' => true,
211
+ 'message_format' => 'auto',
212
+ )
213
+ text = '<6>Feb 28 12:00:00 192.168.0.1 fluentd[11111]: [error] Syslog test'
214
+ @parser.instance.parse(text) do |time, record|
215
+ assert_equal(event_time("Feb 28 12:00:00", format: '%b %d %M:%S:%H'), time)
216
+ assert_equal(@expected.merge('pri' => 6), record)
217
+ end
218
+ text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"] Hi, from Fluentd!'
219
+ @parser.instance.parse(text) do |time, record|
220
+ assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
221
+ assert_equal "11111", record["pid"]
222
+ assert_equal "ID24224", record["msgid"]
223
+ assert_equal "[exampleSDID@20224 iut=\"3\" eventSource=\"Application\" eventID=\"11211\"]",
224
+ record["extradata"]
225
+ assert_equal "Hi, from Fluentd!", record["message"]
226
+ end
227
+ text = '<16>Feb 28 12:00:02 192.168.0.1 fluentd[11111]: [error] Syslog test'
228
+ @parser.instance.parse(text) do |time, record|
229
+ assert_equal(event_time("Feb 28 12:00:02", format: '%b %d %M:%S:%H'), time)
230
+ assert_equal(@expected.merge('pri' => 16), record)
231
+ end
232
+ text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
233
+ @parser.instance.parse(text) do |time, record|
234
+ assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
235
+ assert_equal "-", record["pid"]
236
+ assert_equal "-", record["msgid"]
237
+ assert_equal "-", record["extradata"]
238
+ assert_equal "Hi, from Fluentd!", record["message"]
239
+ end
240
+ end
241
+ end
66
242
  end
@@ -767,8 +767,9 @@ class ServerPluginHelperTest < Test::Unit::TestCase
767
767
 
768
768
  def write_cert_and_key(cert_path, cert, key_path, key, passphrase)
769
769
  File.open(cert_path, "w"){|f| f.write(cert.to_pem) }
770
- # Encrypt secret key by AES256, and write it in PEM format
771
- File.open(key_path, "w"){|f| f.write(key.export(OpenSSL::Cipher.new("AES-256-CBC"), passphrase)) }
770
+ # Write the secret key (raw or ecnrypted by AES256) in PEM format
771
+ key_str = passphrase ? key.export(OpenSSL::Cipher.new("AES-256-CBC"), passphrase) : key.export
772
+ File.open(key_path, "w"){|f| f.write(key_str) }
772
773
  File.chmod(0600, cert_path, key_path)
773
774
  end
774
775
 
@@ -807,7 +808,8 @@ class ServerPluginHelperTest < Test::Unit::TestCase
807
808
  f.write server_cert.to_pem
808
809
  f.write chain_cert.to_pem
809
810
  end
810
- File.open(private_key_path, "w"){|f| f.write(server_key.export(OpenSSL::Cipher.new("AES-256-CBC"), passphrase)) }
811
+ key_str = passphrase ? server_key.export(OpenSSL::Cipher.new("AES-256-CBC"), passphrase) : server_key.export
812
+ File.open(private_key_path, "w"){|f| f.write(key_str) }
811
813
  File.chmod(0600, cert_path, private_key_path)
812
814
  end
813
815
 
@@ -889,10 +891,11 @@ class ServerPluginHelperTest < Test::Unit::TestCase
889
891
  assert_equal "yay\nfoo\n", received
890
892
  end
891
893
 
892
- test 'load self-signed cert/key pair (files), verified from clients using cert files' do
894
+ data('with passphrase' => 'yaaaaaaaaaaaaaaaaaaay',
895
+ 'without passphrase' => nil)
896
+ test 'load self-signed cert/key pair (files), verified from clients using cert files' do |private_key_passphrase|
893
897
  cert_path = File.join(@server_cert_dir, "cert.pem")
894
898
  private_key_path = File.join(@certs_dir, "server.key.pem")
895
- private_key_passphrase = "yaaaaaaaaaaaaaaaaaaay"
896
899
  create_server_pair_signed_by_self(cert_path, private_key_path, private_key_passphrase)
897
900
 
898
901
  tls_options = {
@@ -902,8 +905,8 @@ class ServerPluginHelperTest < Test::Unit::TestCase
902
905
  insecure: false,
903
906
  cert_path: cert_path,
904
907
  private_key_path: private_key_path,
905
- private_key_passphrase: private_key_passphrase,
906
908
  }
909
+ tls_options[:private_key_passphrase] = private_key_passphrase if private_key_passphrase
907
910
  received = ""
908
911
  @d.server_create_tls(:s, PORT, tls_options: tls_options) do |data, conn|
909
912
  received << data
@@ -922,10 +925,11 @@ class ServerPluginHelperTest < Test::Unit::TestCase
922
925
  assert_equal "yay\nfoo\n", received
923
926
  end
924
927
 
925
- test 'create dynamic server cert by private CA cert file, verified from clients using CA cert file' do
928
+ data('with passphrase' => "fooooooooooooooooooooooooo",
929
+ 'without passphrase' => nil)
930
+ test 'create dynamic server cert by private CA cert file, verified from clients using CA cert file' do |ca_key_passphrase|
926
931
  ca_cert_path = File.join(@certs_dir, "ca_cert.pem")
927
932
  ca_key_path = File.join(@certs_dir, "ca.key.pem")
928
- ca_key_passphrase = "fooooooooooooooooooooooooo"
929
933
  create_ca_pair_signed_by_self(ca_cert_path, ca_key_path, ca_key_passphrase)
930
934
 
931
935
  tls_options = {
@@ -935,9 +939,9 @@ class ServerPluginHelperTest < Test::Unit::TestCase
935
939
  insecure: false,
936
940
  ca_cert_path: ca_cert_path,
937
941
  ca_private_key_path: ca_key_path,
938
- ca_private_key_passphrase: ca_key_passphrase,
939
942
  generate_private_key_length: 2048,
940
943
  }
944
+ tls_options[:ca_private_key_passphrase] = ca_key_passphrase if ca_key_passphrase
941
945
  received = ""
942
946
  @d.server_create_tls(:s, PORT, tls_options: tls_options) do |data, conn|
943
947
  received << data
@@ -950,15 +954,15 @@ class ServerPluginHelperTest < Test::Unit::TestCase
950
954
  assert_equal "yay\nfoo\n", received
951
955
  end
952
956
 
953
- test 'load static server cert by private CA cert file, verified from clients using CA cert file' do
957
+ data('with passphrase' => ["foooooooo", "yaaaaaaaaaaaaaaaaaaay"],
958
+ 'without passphrase' => [nil, nil])
959
+ test 'load static server cert by private CA cert file, verified from clients using CA cert file' do |(ca_key_passphrase, private_key_passphrase)|
954
960
  ca_cert_path = File.join(@certs_dir, "ca_cert.pem")
955
961
  ca_key_path = File.join(@certs_dir, "ca.key.pem")
956
- ca_key_passphrase = "foooooooo"
957
962
  create_ca_pair_signed_by_self(ca_cert_path, ca_key_path, ca_key_passphrase)
958
963
 
959
964
  cert_path = File.join(@server_cert_dir, "cert.pem")
960
965
  private_key_path = File.join(@certs_dir, "server.key.pem")
961
- private_key_passphrase = "yaaaaaaaaaaaaaaaaaaay"
962
966
  create_server_pair_signed_by_ca(ca_cert_path, ca_key_path, ca_key_passphrase, cert_path, private_key_path, private_key_passphrase)
963
967
 
964
968
  tls_options = {
@@ -968,8 +972,8 @@ class ServerPluginHelperTest < Test::Unit::TestCase
968
972
  insecure: false,
969
973
  cert_path: cert_path,
970
974
  private_key_path: private_key_path,
971
- private_key_passphrase: private_key_passphrase,
972
975
  }
976
+ tls_options[:private_key_passphrase] = private_key_passphrase if private_key_passphrase
973
977
  received = ""
974
978
  @d.server_create_tls(:s, PORT, tls_options: tls_options) do |data, conn|
975
979
  received << data
@@ -982,13 +986,13 @@ class ServerPluginHelperTest < Test::Unit::TestCase
982
986
  assert_equal "yay\nfoo\n", received
983
987
  end
984
988
 
985
- test 'load chained server cert by private CA cert file, verified from clients using CA cert file as root' do
989
+ data('with passphrase' => ["foooooooo", "yaaaaaaaaaaaaaaaaaaay"],
990
+ 'without passphrase' => [nil, nil])
991
+ test 'load chained server cert by private CA cert file, verified from clients using CA cert file as root' do |(ca_key_passphrase, private_key_passphrase)|
986
992
  ca_cert_path = File.join(@certs_dir, "ca_cert.pem")
987
993
  ca_key_path = File.join(@certs_dir, "ca.key.pem")
988
- ca_key_passphrase = "foooooooo"
989
994
  cert_path = File.join(@server_cert_dir, "cert.pem")
990
995
  private_key_path = File.join(@certs_dir, "server.key.pem")
991
- private_key_passphrase = "yaaaaaaaaaaaaaaaaaaay"
992
996
  create_server_pair_chained_with_root_ca(ca_cert_path, ca_key_path, ca_key_passphrase, cert_path, private_key_path, private_key_passphrase)
993
997
 
994
998
  tls_options = {
@@ -998,8 +1002,8 @@ class ServerPluginHelperTest < Test::Unit::TestCase
998
1002
  insecure: false,
999
1003
  cert_path: cert_path,
1000
1004
  private_key_path: private_key_path,
1001
- private_key_passphrase: private_key_passphrase,
1002
1005
  }
1006
+ tls_options[:private_key_passphrase] = private_key_passphrase if private_key_passphrase
1003
1007
  received = ""
1004
1008
  @d.server_create_tls(:s, PORT, tls_options: tls_options) do |data, conn|
1005
1009
  received << data
@@ -1042,17 +1046,18 @@ class ServerPluginHelperTest < Test::Unit::TestCase
1042
1046
  assert_equal "yay\nfoo\n", received
1043
1047
  end
1044
1048
 
1045
- test 'load self-signed cert/key pair (files), verified from clients using cert files' do
1049
+ data('with passphrase' => "yaaaaaaaaaaaaaaaaaaay",
1050
+ 'without passphrase' => nil)
1051
+ test 'load self-signed cert/key pair (files), verified from clients using cert files' do |private_key_passphrase|
1046
1052
  cert_path = File.join(@server_cert_dir, "cert.pem")
1047
1053
  private_key_path = File.join(@certs_dir, "server.key.pem")
1048
- private_key_passphrase = "yaaaaaaaaaaaaaaaaaaay"
1049
1054
  create_server_pair_signed_by_self(cert_path, private_key_path, private_key_passphrase)
1050
1055
 
1051
1056
  transport_opts = {
1052
1057
  'cert_path' => cert_path,
1053
1058
  'private_key_path' => private_key_path,
1054
- 'private_key_passphrase' => private_key_passphrase,
1055
1059
  }
1060
+ transport_opts['private_key_passphrase'] = private_key_passphrase if private_key_passphrase
1056
1061
  transport_conf = config_element('transport', 'tls', transport_opts)
1057
1062
  conf = config_element('match', 'tag.*', {}, [transport_conf])
1058
1063
 
@@ -1076,17 +1081,18 @@ class ServerPluginHelperTest < Test::Unit::TestCase
1076
1081
  assert_equal "yay\nfoo\n", received
1077
1082
  end
1078
1083
 
1079
- test 'create dynamic server cert by private CA cert file, verified from clients using CA cert file' do
1084
+ data('with passphrase' => "fooooooooooooooooooooooooo",
1085
+ 'without passphrase' => nil)
1086
+ test 'create dynamic server cert by private CA cert file, verified from clients using CA cert file' do |ca_key_passphrase|
1080
1087
  ca_cert_path = File.join(@certs_dir, "ca_cert.pem")
1081
1088
  ca_key_path = File.join(@certs_dir, "ca.key.pem")
1082
- ca_key_passphrase = "fooooooooooooooooooooooooo"
1083
1089
  create_ca_pair_signed_by_self(ca_cert_path, ca_key_path, ca_key_passphrase)
1084
1090
 
1085
1091
  transport_opts = {
1086
1092
  'ca_cert_path' => ca_cert_path,
1087
1093
  'ca_private_key_path' => ca_key_path,
1088
- 'ca_private_key_passphrase' => ca_key_passphrase,
1089
1094
  }
1095
+ transport_opts['ca_private_key_passphrase'] = ca_key_passphrase if ca_key_passphrase
1090
1096
  transport_conf = config_element('transport', 'tls', transport_opts)
1091
1097
  conf = config_element('match', 'tag.*', {}, [transport_conf])
1092
1098
 
@@ -1104,22 +1110,22 @@ class ServerPluginHelperTest < Test::Unit::TestCase
1104
1110
  assert_equal "yay\nfoo\n", received
1105
1111
  end
1106
1112
 
1107
- test 'load static server cert by private CA cert file, verified from clients using CA cert file' do
1113
+ data('with passphrase' => ["foooooooo", "yaaaaaaaaaaaaaaaaaaay"],
1114
+ 'without passphrase' => [nil, nil])
1115
+ test 'load static server cert by private CA cert file, verified from clients using CA cert file' do |(ca_key_passphrase, private_key_passphrase)|
1108
1116
  ca_cert_path = File.join(@certs_dir, "ca_cert.pem")
1109
1117
  ca_key_path = File.join(@certs_dir, "ca.key.pem")
1110
- ca_key_passphrase = "foooooooo"
1111
1118
  create_ca_pair_signed_by_self(ca_cert_path, ca_key_path, ca_key_passphrase)
1112
1119
 
1113
1120
  cert_path = File.join(@server_cert_dir, "cert.pem")
1114
1121
  private_key_path = File.join(@certs_dir, "server.key.pem")
1115
- private_key_passphrase = "yaaaaaaaaaaaaaaaaaaay"
1116
1122
  create_server_pair_signed_by_ca(ca_cert_path, ca_key_path, ca_key_passphrase, cert_path, private_key_path, private_key_passphrase)
1117
1123
 
1118
1124
  transport_opts = {
1119
1125
  'cert_path' => cert_path,
1120
1126
  'private_key_path' => private_key_path,
1121
- 'private_key_passphrase' => private_key_passphrase,
1122
1127
  }
1128
+ transport_opts['private_key_passphrase'] = private_key_passphrase if private_key_passphrase
1123
1129
  transport_conf = config_element('transport', 'tls', transport_opts)
1124
1130
  conf = config_element('match', 'tag.*', {}, [transport_conf])
1125
1131
 
@@ -1137,20 +1143,20 @@ class ServerPluginHelperTest < Test::Unit::TestCase
1137
1143
  assert_equal "yay\nfoo\n", received
1138
1144
  end
1139
1145
 
1140
- test 'load chained server cert by private CA cert file, verified from clients using CA cert file as root' do
1146
+ data('with passphrase' => ["foooooooo", "yaaaaaaaaaaaaaaaaaaay"],
1147
+ 'without passphrase' => [nil, nil])
1148
+ test 'load chained server cert by private CA cert file, verified from clients using CA cert file as root' do |(ca_key_passphrase, private_key_passphrase)|
1141
1149
  ca_cert_path = File.join(@certs_dir, "ca_cert.pem")
1142
1150
  ca_key_path = File.join(@certs_dir, "ca.key.pem")
1143
- ca_key_passphrase = "foooooooo"
1144
1151
  cert_path = File.join(@server_cert_dir, "cert.pem")
1145
1152
  private_key_path = File.join(@certs_dir, "server.key.pem")
1146
- private_key_passphrase = "yaaaaaaaaaaaaaaaaaaay"
1147
1153
  create_server_pair_chained_with_root_ca(ca_cert_path, ca_key_path, ca_key_passphrase, cert_path, private_key_path, private_key_passphrase)
1148
1154
 
1149
1155
  transport_opts = {
1150
1156
  'cert_path' => cert_path,
1151
1157
  'private_key_path' => private_key_path,
1152
- 'private_key_passphrase' => private_key_passphrase,
1153
1158
  }
1159
+ transport_opts['private_key_passphrase'] = private_key_passphrase if private_key_passphrase
1154
1160
  transport_conf = config_element('transport', 'tls', transport_opts)
1155
1161
  conf = config_element('match', 'tag.*', {}, [transport_conf])
1156
1162