@@ -54,7 +54,7 @@ func TestParserHappyCases(t *testing.T) {
54
54
testCases := []parseConfigTestCase {
55
55
{
56
56
name : "http and ipv4 address" ,
57
- config : fmt .Sprintf ("http::addr=%s" , addr ),
57
+ config : fmt .Sprintf ("http::addr=%s; " , addr ),
58
58
expected : qdb.ConfigData {
59
59
Schema : "http" ,
60
60
KeyValuePairs : map [string ]string {
@@ -74,7 +74,7 @@ func TestParserHappyCases(t *testing.T) {
74
74
},
75
75
{
76
76
name : "tcp and address" ,
77
- config : fmt .Sprintf ("tcp::addr=%s" , addr ),
77
+ config : fmt .Sprintf ("tcp::addr=%s; " , addr ),
78
78
expected : qdb.ConfigData {
79
79
Schema : "tcp" ,
80
80
KeyValuePairs : map [string ]string {
@@ -84,7 +84,7 @@ func TestParserHappyCases(t *testing.T) {
84
84
},
85
85
{
86
86
name : "http and username/password" ,
87
- config : fmt .Sprintf ("http::addr=%s;username=%s;password=%s" , addr , user , pass ),
87
+ config : fmt .Sprintf ("http::addr=%s;username=%s;password=%s; " , addr , user , pass ),
88
88
expected : qdb.ConfigData {
89
89
Schema : "http" ,
90
90
KeyValuePairs : map [string ]string {
@@ -107,7 +107,7 @@ func TestParserHappyCases(t *testing.T) {
107
107
},
108
108
{
109
109
name : "tcp with key and user" ,
110
- config : fmt .Sprintf ("tcp::addr=%s;token=%s;username=%s" , addr , token , user ),
110
+ config : fmt .Sprintf ("tcp::addr=%s;token=%s;username=%s; " , addr , token , user ),
111
111
expected : qdb.ConfigData {
112
112
Schema : "tcp" ,
113
113
KeyValuePairs : map [string ]string {
@@ -119,7 +119,7 @@ func TestParserHappyCases(t *testing.T) {
119
119
},
120
120
{
121
121
name : "https with min_throughput" ,
122
- config : fmt .Sprintf ("https::addr=%s;min_throughput=%d" , addr , min_throughput ),
122
+ config : fmt .Sprintf ("https::addr=%s;min_throughput=%d; " , addr , min_throughput ),
123
123
expected : qdb.ConfigData {
124
124
Schema : "https" ,
125
125
KeyValuePairs : map [string ]string {
@@ -130,7 +130,7 @@ func TestParserHappyCases(t *testing.T) {
130
130
},
131
131
{
132
132
name : "https with min_throughput, init_buf_size and tls_verify=unsafe_off" ,
133
- config : fmt .Sprintf ("https::addr=%s;min_throughput=%d;init_buf_size=%d;tls_verify=unsafe_off" , addr , min_throughput , 1024 ),
133
+ config : fmt .Sprintf ("https::addr=%s;min_throughput=%d;init_buf_size=%d;tls_verify=unsafe_off; " , addr , min_throughput , 1024 ),
134
134
expected : qdb.ConfigData {
135
135
Schema : "https" ,
136
136
KeyValuePairs : map [string ]string {
@@ -143,7 +143,7 @@ func TestParserHappyCases(t *testing.T) {
143
143
},
144
144
{
145
145
name : "tcps with tls_verify=unsafe_off" ,
146
- config : fmt .Sprintf ("tcps::addr=%s;tls_verify=unsafe_off" , addr ),
146
+ config : fmt .Sprintf ("tcps::addr=%s;tls_verify=unsafe_off; " , addr ),
147
147
expected : qdb.ConfigData {
148
148
Schema : "tcps" ,
149
149
KeyValuePairs : map [string ]string {
@@ -154,7 +154,7 @@ func TestParserHappyCases(t *testing.T) {
154
154
},
155
155
{
156
156
name : "http with min_throughput, request_timeout, and retry_timeout" ,
157
- config : fmt .Sprintf ("http::addr=%s;min_throughput=%d;request_timeout=%d;retry_timeout=%d" ,
157
+ config : fmt .Sprintf ("http::addr=%s;min_throughput=%d;request_timeout=%d;retry_timeout=%d; " ,
158
158
addr , min_throughput , request_timeout .Milliseconds (), retry_timeout .Milliseconds ()),
159
159
expected : qdb.ConfigData {
160
160
Schema : "http" ,
@@ -168,7 +168,7 @@ func TestParserHappyCases(t *testing.T) {
168
168
},
169
169
{
170
170
name : "tcp with tls_verify=on" ,
171
- config : fmt .Sprintf ("tcp::addr=%s;tls_verify=on" , addr ),
171
+ config : fmt .Sprintf ("tcp::addr=%s;tls_verify=on; " , addr ),
172
172
expected : qdb.ConfigData {
173
173
Schema : "tcp" ,
174
174
KeyValuePairs : map [string ]string {
@@ -177,18 +177,6 @@ func TestParserHappyCases(t *testing.T) {
177
177
},
178
178
},
179
179
},
180
- {
181
- name : "password with an escaped semicolon" ,
182
- config : fmt .Sprintf ("http::addr=%s;username=%s;password=pass;;word" , addr , user ),
183
- expected : qdb.ConfigData {
184
- Schema : "http" ,
185
- KeyValuePairs : map [string ]string {
186
- "addr" : addr ,
187
- "username" : user ,
188
- "password" : "pass;word" ,
189
- },
190
- },
191
- },
192
180
{
193
181
name : "password with an escaped semicolon (ending with a ';')" ,
194
182
config : fmt .Sprintf ("http::addr=%s;username=%s;password=pass;;word;" , addr , user ),
@@ -215,7 +203,7 @@ func TestParserHappyCases(t *testing.T) {
215
203
},
216
204
{
217
205
name : "equal sign in password" ,
218
- config : fmt .Sprintf ("http::addr=%s;username=%s;password=pass=word" , addr , user ),
206
+ config : fmt .Sprintf ("http::addr=%s;username=%s;password=pass=word; " , addr , user ),
219
207
expected : qdb.ConfigData {
220
208
Schema : "http" ,
221
209
KeyValuePairs : map [string ]string {
@@ -253,15 +241,10 @@ func TestParserPathologicalCases(t *testing.T) {
253
241
config : "http::" ,
254
242
expectedErrMsgContains : "'addr' key not found" ,
255
243
},
256
- {
257
- name : "unescaped semicolon in password leads to unexpected end of string" ,
258
- config : "http::addr=localhost:9000;username=test;password=pass;word" ,
259
- expectedErrMsgContains : "unexpected end of string" ,
260
- },
261
244
{
262
245
name : "unescaped semicolon in password leads to invalid key character" ,
263
246
config : "http::addr=localhost:9000;username=test;password=pass;word;" ,
264
- expectedErrMsgContains : "invalid key character ';' " ,
247
+ expectedErrMsgContains : "unexpected end of " ,
265
248
},
266
249
}
267
250
@@ -299,7 +282,17 @@ func TestHappyCasesFromConf(t *testing.T) {
299
282
testCases := []configTestCase {
300
283
{
301
284
name : "user and token" ,
302
- config : fmt .Sprintf ("tcp::addr=%s;username=%s;token=%s" ,
285
+ config : fmt .Sprintf ("tcp::addr=%s;username=%s;token=%s;" ,
286
+ addr , user , token ),
287
+ expectedOpts : []qdb.LineSenderOption {
288
+ qdb .WithTcp (),
289
+ qdb .WithAddress (addr ),
290
+ qdb .WithAuth (user , token ),
291
+ },
292
+ },
293
+ {
294
+ name : "token_x and token_y (ignored)" ,
295
+ config : fmt .Sprintf ("tcp::addr=%s;username=%s;token=%s;token_x=xyz;token_y=xyz;" ,
303
296
addr , user , token ),
304
297
expectedOpts : []qdb.LineSenderOption {
305
298
qdb .WithTcp (),
@@ -309,7 +302,7 @@ func TestHappyCasesFromConf(t *testing.T) {
309
302
},
310
303
{
311
304
name : "init_buf_size and max_buf_size" ,
312
- config : fmt .Sprintf ("tcp::addr=%s;init_buf_size=%d;max_buf_size=%d" ,
305
+ config : fmt .Sprintf ("tcp::addr=%s;init_buf_size=%d;max_buf_size=%d; " ,
313
306
addr , initBufSize , maxBufSize ),
314
307
expectedOpts : []qdb.LineSenderOption {
315
308
qdb .WithTcp (),
@@ -320,7 +313,7 @@ func TestHappyCasesFromConf(t *testing.T) {
320
313
},
321
314
{
322
315
name : "with tls" ,
323
- config : fmt .Sprintf ("tcp::addr=%s;tls_verify=on" ,
316
+ config : fmt .Sprintf ("tcp::addr=%s;tls_verify=on; " ,
324
317
addr ),
325
318
expectedOpts : []qdb.LineSenderOption {
326
319
qdb .WithTcp (),
@@ -330,7 +323,7 @@ func TestHappyCasesFromConf(t *testing.T) {
330
323
},
331
324
{
332
325
name : "with tls and unsafe_off" ,
333
- config : fmt .Sprintf ("tcp::addr=%s;tls_verify=unsafe_off" ,
326
+ config : fmt .Sprintf ("tcp::addr=%s;tls_verify=unsafe_off; " ,
334
327
addr ),
335
328
expectedOpts : []qdb.LineSenderOption {
336
329
qdb .WithTcp (),
@@ -340,7 +333,7 @@ func TestHappyCasesFromConf(t *testing.T) {
340
333
},
341
334
{
342
335
name : "request_timeout and retry_timeout milli conversion" ,
343
- config : fmt .Sprintf ("http::addr=%s;request_timeout=%d;retry_timeout=%d" ,
336
+ config : fmt .Sprintf ("http::addr=%s;request_timeout=%d;retry_timeout=%d; " ,
344
337
addr , requestTimeout .Milliseconds (), retryTimeout .Milliseconds ()),
345
338
expectedOpts : []qdb.LineSenderOption {
346
339
qdb .WithHttp (),
@@ -351,7 +344,7 @@ func TestHappyCasesFromConf(t *testing.T) {
351
344
},
352
345
{
353
346
name : "password before username" ,
354
- config : fmt .Sprintf ("http::addr=%s;password=%s;username=%s" ,
347
+ config : fmt .Sprintf ("http::addr=%s;password=%s;username=%s; " ,
355
348
addr , pass , user ),
356
349
expectedOpts : []qdb.LineSenderOption {
357
350
qdb .WithHttp (),
@@ -361,7 +354,7 @@ func TestHappyCasesFromConf(t *testing.T) {
361
354
},
362
355
{
363
356
name : "min_throughput" ,
364
- config : fmt .Sprintf ("http::addr=%s;min_throughput=%d" ,
357
+ config : fmt .Sprintf ("http::addr=%s;min_throughput=%d; " ,
365
358
addr , minThroughput ),
366
359
expectedOpts : []qdb.LineSenderOption {
367
360
qdb .WithHttp (),
@@ -371,7 +364,7 @@ func TestHappyCasesFromConf(t *testing.T) {
371
364
},
372
365
{
373
366
name : "bearer token" ,
374
- config : fmt .Sprintf ("http::addr=%s;token=%s" ,
367
+ config : fmt .Sprintf ("http::addr=%s;token=%s; " ,
375
368
addr , token ),
376
369
expectedOpts : []qdb.LineSenderOption {
377
370
qdb .WithHttp (),
@@ -381,7 +374,7 @@ func TestHappyCasesFromConf(t *testing.T) {
381
374
},
382
375
{
383
376
name : "auto flush" ,
384
- config : fmt .Sprintf ("http::addr=%s;auto_flush_rows=100;auto_flush_interval=1000" ,
377
+ config : fmt .Sprintf ("http::addr=%s;auto_flush_rows=100;auto_flush_interval=1000; " ,
385
378
addr ),
386
379
expectedOpts : []qdb.LineSenderOption {
387
380
qdb .WithHttp (),
@@ -416,44 +409,54 @@ func TestPathologicalCasesFromConf(t *testing.T) {
416
409
},
417
410
{
418
411
name : "invalid schema" ,
419
- config : "foobar::addr=localhost:1111" ,
412
+ config : "foobar::addr=localhost:1111; " ,
420
413
expectedErrMsgContains : "invalid schema" ,
421
414
},
422
415
{
423
416
name : "invalid tls_verify 1" ,
424
- config : "tcp::addr=localhost:1111;tls_verify=invalid" ,
417
+ config : "tcp::addr=localhost:1111;tls_verify=invalid; " ,
425
418
expectedErrMsgContains : "invalid tls_verify" ,
426
419
},
427
420
{
428
421
name : "invalid tls_verify 2" ,
429
- config : "http::addr=localhost:1111;tls_verify=invalid" ,
422
+ config : "http::addr=localhost:1111;tls_verify=invalid; " ,
430
423
expectedErrMsgContains : "invalid tls_verify" ,
431
424
},
432
425
{
433
426
name : "unsupported option" ,
434
- config : "tcp::addr=localhost:1111;unsupported_option=invalid" ,
427
+ config : "tcp::addr=localhost:1111;unsupported_option=invalid; " ,
435
428
expectedErrMsgContains : "unsupported option" ,
436
429
},
437
430
{
438
431
name : "invalid auto_flush" ,
439
- config : "http::addr=localhost:1111;auto_flush=invalid" ,
432
+ config : "http::addr=localhost:1111;auto_flush=invalid; " ,
440
433
expectedErrMsgContains : "invalid auto_flush" ,
441
434
},
442
435
{
443
436
name : "invalid auto_flush_rows" ,
444
- config : "http::addr=localhost:1111;auto_flush_rows=invalid" ,
437
+ config : "http::addr=localhost:1111;auto_flush_rows=invalid; " ,
445
438
expectedErrMsgContains : "invalid auto_flush_rows" ,
446
439
},
447
440
{
448
441
name : "invalid auto_flush_interval" ,
449
- config : "http::addr=localhost:1111;auto_flush_interval=invalid" ,
442
+ config : "http::addr=localhost:1111;auto_flush_interval=invalid; " ,
450
443
expectedErrMsgContains : "invalid auto_flush_interval" ,
451
444
},
452
445
{
453
446
name : "unsupported option" ,
454
- config : "http::addr=localhost:1111;unsupported_option=invalid" ,
447
+ config : "http::addr=localhost:1111;unsupported_option=invalid;" ,
448
+ expectedErrMsgContains : "unsupported option" ,
449
+ },
450
+ {
451
+ name : "case-sensitive values" ,
452
+ config : "http::aDdr=localhost:9000;" ,
455
453
expectedErrMsgContains : "unsupported option" ,
456
454
},
455
+ {
456
+ name : "trailing semicolon required" ,
457
+ config : "http::addr=localhost:9000" ,
458
+ expectedErrMsgContains : "trailing semicolon" ,
459
+ },
457
460
}
458
461
459
462
for _ , tc := range testCases {
0 commit comments