@@ -10,7 +10,6 @@ import (
10
10
"path/filepath"
11
11
"testing"
12
12
13
- "github.com/go-kit/log"
14
13
"github.com/grafana/alloy/internal/component/faro/receiver/internal/payload"
15
14
alloyutil "github.com/grafana/alloy/internal/util"
16
15
"github.com/prometheus/client_golang/prometheus"
@@ -601,71 +600,10 @@ func Test_sourceMapsStoreImpl_RealWorldPathValidation(t *testing.T) {
601
600
602
601
actual := transformException (logger , store , input , "123" )
603
602
require .Equal (t , input , actual )
604
- require .Equal (t , []string {"/foo/bar/baz/qux/folder/file.js.map" }, fileService .stats )
603
+ require .Equal (t , []string {filepath . FromSlash ( "/foo/bar/baz/qux/folder/file.js.map" ) }, fileService .stats )
605
604
require .Empty (t , fileService .reads , "should not read file when stat fails" )
606
605
}
607
606
608
- func Test_sourceMapsStoreImpl_InvalidPathMetrics (t * testing.T ) {
609
- var (
610
- logBuf bytes.Buffer
611
- logger = log .NewLogfmtLogger (log .NewSyncWriter (& logBuf ))
612
- reg = prometheus .NewRegistry ()
613
- store = newSourceMapsStore (
614
- logger ,
615
- SourceMapsArguments {
616
- Download : false ,
617
- Locations : []LocationArguments {
618
- {
619
- MinifiedPathPrefix : "http://foo.com/" ,
620
- Path : "/var/build/latest/" ,
621
- },
622
- },
623
- },
624
- newSourceMapMetrics (reg ),
625
- nil ,
626
- newTestFileService (),
627
- )
628
- )
629
-
630
- input := & payload.Exception {
631
- Stacktrace : & payload.Stacktrace {
632
- Frames : []payload.Frame {
633
- {
634
- Colno : 6 ,
635
- Filename : "http://foo.com/..\\ etc\\ passwd" ,
636
- Function : "eval" ,
637
- Lineno : 5 ,
638
- },
639
- },
640
- },
641
- }
642
-
643
- transformException (logger , store , input , "123" )
644
-
645
- logOutput := logBuf .String ()
646
- require .Contains (t , logOutput , "msg=\" source map path contains invalid characters\" " )
647
- require .Contains (t , logOutput , "url=http://foo.com/..\\ etc\\ passwd" )
648
- require .Contains (t , logOutput , "file_path=/var/build/latest/..\\ etc\\ passwd.map" )
649
-
650
- metrics , err := reg .Gather ()
651
- require .NoError (t , err )
652
-
653
- var found bool
654
- for _ , metric := range metrics {
655
- if metric .GetName () == "faro_receiver_sourcemap_file_reads_total" {
656
- for _ , m := range metric .GetMetric () {
657
- for _ , label := range m .GetLabel () {
658
- if label .GetName () == "status" && label .GetValue () == "invalid_path" {
659
- found = true
660
- require .Equal (t , float64 (1 ), m .GetCounter ().GetValue ())
661
- }
662
- }
663
- }
664
- }
665
- }
666
- require .True (t , found , "Expected to find metric with invalid_path status" )
667
- }
668
-
669
607
type mockHTTPClient struct {
670
608
responses []struct {
671
609
* http.Response
0 commit comments