@@ -213,6 +213,16 @@ func TestParserHappyCases(t *testing.T) {
213213 },
214214 },
215215 },
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+ },
216226 }
217227
218228 for _ , tc := range testCases {
@@ -231,6 +241,11 @@ func TestParserPathologicalCases(t *testing.T) {
231241 config : "" ,
232242 expectedErrMsgContains : "no schema separator found" ,
233243 },
244+ {
245+ name : "empty config with semicolon" ,
246+ config : ";" ,
247+ expectedErrMsgContains : "no schema separator found" ,
248+ },
234249 {
235250 name : "no schema" ,
236251 config : "addr=localhost:9000" ,
@@ -242,10 +257,15 @@ func TestParserPathologicalCases(t *testing.T) {
242257 expectedErrMsgContains : "'addr' key not found" ,
243258 },
244259 {
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) " ,
246261 config : "http::addr=localhost:9000;username=test;password=pass;word;" ,
247262 expectedErrMsgContains : "unexpected end of" ,
248263 },
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+ },
249269 }
250270
251271 for _ , tc := range testCases {
@@ -344,7 +364,7 @@ func TestHappyCasesFromConf(t *testing.T) {
344364 },
345365 {
346366 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" ,
348368 addr , pass , user ),
349369 expectedOpts : []qdb.LineSenderOption {
350370 qdb .WithHttp (),
@@ -364,7 +384,7 @@ func TestHappyCasesFromConf(t *testing.T) {
364384 },
365385 {
366386 name : "bearer token" ,
367- config : fmt .Sprintf ("http::addr=%s;token=%s; " ,
387+ config : fmt .Sprintf ("http::addr=%s;token=%s" ,
368388 addr , token ),
369389 expectedOpts : []qdb.LineSenderOption {
370390 qdb .WithHttp (),
@@ -453,9 +473,19 @@ func TestPathologicalCasesFromConf(t *testing.T) {
453473 expectedErrMsgContains : "unsupported option" ,
454474 },
455475 {
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" ,
459489 },
460490 }
461491
0 commit comments