@@ -648,3 +648,51 @@ func TestGetSignalURL(t *testing.T) {
648
648
})
649
649
}
650
650
}
651
+
652
+ func TestNChars (t * testing.T ) {
653
+ s := nchars ('*' , 10 )
654
+ require .Equal (t , "**********" , s )
655
+ s = nchars (' ' , 2 )
656
+ require .Equal (t , " " , s )
657
+ }
658
+
659
+ func TestSanitizeURL (t * testing.T ) {
660
+ testCases := []struct {
661
+ description string
662
+ urlString string
663
+ expected string
664
+ }{
665
+ {
666
+ description : "sanitized logs url" ,
667
+ urlString : "https://collectors.au.sumologic.com/receiver/v1/otlp/xxxxx/v1/logs" ,
668
+ expected : "https://collectors.au.sumologic.com/receiver/v1/otlp/*****/v1/logs" ,
669
+ },
670
+ {
671
+ description : "sanitized metrics url" ,
672
+ urlString : "https://collectors.au.sumologic.com/receiver/v1/otlp/xxxx==/v1/metrics" ,
673
+ expected : "https://collectors.au.sumologic.com/receiver/v1/otlp/******/v1/metrics" ,
674
+ },
675
+ {
676
+ description : "sanitized traces url" ,
677
+ urlString : "https://collectors.au.sumologic.com/receiver/v1/otlp/xxxx==/v1/traces" ,
678
+ expected : "https://collectors.au.sumologic.com/receiver/v1/otlp/******/v1/traces" ,
679
+ },
680
+ {
681
+ description : "no sanitization required" ,
682
+ urlString : "https://collectors.au.sumologic.com/receiver/v1/xxxx==/v1/traces" ,
683
+ expected : "https://collectors.au.sumologic.com/receiver/v1/xxxx==/v1/traces" ,
684
+ },
685
+ {
686
+ description : "no sanitization required with otlp/ appearing after v1/" ,
687
+ urlString : "https://collectors.au.sumologic.com/receiver/v1/v1/xxxx==/otlp/traces" ,
688
+ expected : "https://collectors.au.sumologic.com/receiver/v1/v1/xxxx==/otlp/traces" ,
689
+ },
690
+ }
691
+ for _ , tC := range testCases {
692
+ testCase := tC
693
+ t .Run (tC .description , func (t * testing.T ) {
694
+ actual := sanitizeURL (testCase .urlString )
695
+ require .Equal (t , testCase .expected , actual )
696
+ })
697
+ }
698
+ }
0 commit comments