@@ -213,6 +213,16 @@ func TestParserHappyCases(t *testing.T) {
213
213
},
214
214
},
215
215
},
216
+ {
217
+ name : "no trailing semicolon" ,
218
+ config : fmt .Sprintf ("http::addr=%s" , addr ),
219
+ expected : qdb.ConfigData {
220
+ Schema : "http" ,
221
+ KeyValuePairs : map [string ]string {
222
+ "addr" : addr ,
223
+ },
224
+ },
225
+ },
216
226
}
217
227
218
228
for _ , tc := range testCases {
@@ -231,6 +241,11 @@ func TestParserPathologicalCases(t *testing.T) {
231
241
config : "" ,
232
242
expectedErrMsgContains : "no schema separator found" ,
233
243
},
244
+ {
245
+ name : "empty config with semicolon" ,
246
+ config : ";" ,
247
+ expectedErrMsgContains : "no schema separator found" ,
248
+ },
234
249
{
235
250
name : "no schema" ,
236
251
config : "addr=localhost:9000" ,
@@ -242,10 +257,15 @@ func TestParserPathologicalCases(t *testing.T) {
242
257
expectedErrMsgContains : "'addr' key not found" ,
243
258
},
244
259
{
245
- name : "unescaped semicolon in password leads to invalid key character " ,
260
+ name : "unescaped semicolon in password leads to unexpected end of string (with trailing semicolon) " ,
246
261
config : "http::addr=localhost:9000;username=test;password=pass;word;" ,
247
262
expectedErrMsgContains : "unexpected end of" ,
248
263
},
264
+ {
265
+ name : "unescaped semicolon in password leads to unexpected end of string (no trailing semicolon)" ,
266
+ config : "http::addr=localhost:9000;username=test;password=pass;word" ,
267
+ expectedErrMsgContains : "unexpected end of" ,
268
+ },
249
269
}
250
270
251
271
for _ , tc := range testCases {
@@ -344,7 +364,7 @@ func TestHappyCasesFromConf(t *testing.T) {
344
364
},
345
365
{
346
366
name : "password before username" ,
347
- config : fmt .Sprintf ("http::addr=%s;password=%s;username=%s; " ,
367
+ config : fmt .Sprintf ("http::addr=%s;password=%s;username=%s" ,
348
368
addr , pass , user ),
349
369
expectedOpts : []qdb.LineSenderOption {
350
370
qdb .WithHttp (),
@@ -364,7 +384,7 @@ func TestHappyCasesFromConf(t *testing.T) {
364
384
},
365
385
{
366
386
name : "bearer token" ,
367
- config : fmt .Sprintf ("http::addr=%s;token=%s; " ,
387
+ config : fmt .Sprintf ("http::addr=%s;token=%s" ,
368
388
addr , token ),
369
389
expectedOpts : []qdb.LineSenderOption {
370
390
qdb .WithHttp (),
@@ -453,9 +473,19 @@ func TestPathologicalCasesFromConf(t *testing.T) {
453
473
expectedErrMsgContains : "unsupported option" ,
454
474
},
455
475
{
456
- name : "trailing semicolon required" ,
457
- config : "http::addr=localhost:9000" ,
458
- expectedErrMsgContains : "trailing semicolon" ,
476
+ name : "partial key at end" ,
477
+ config : "http::addr=localhost:9000;test" ,
478
+ expectedErrMsgContains : "unexpected end of string" ,
479
+ },
480
+ {
481
+ name : "no value at end" ,
482
+ config : "http::addr=localhost:9000;username=" ,
483
+ expectedErrMsgContains : "empty value for key" ,
484
+ },
485
+ {
486
+ name : "no value at end with semicolon" ,
487
+ config : "http::addr=localhost:9000;username=;" ,
488
+ expectedErrMsgContains : "empty value for key" ,
459
489
},
460
490
}
461
491
0 commit comments