github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/pkg/scanners/azure/functions/uri_test.go (about) 1 package functions 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/require" 7 ) 8 9 func Test_Uri(t *testing.T) { 10 tests := []struct { 11 name string 12 args []interface{} 13 expected string 14 }{ 15 { 16 name: "uri from a base and relative with no trailing slash", 17 args: []interface{}{ 18 "http://contoso.org/firstpath", 19 "myscript.sh", 20 }, 21 expected: "http://contoso.org/firstpath/myscript.sh", 22 }, 23 { 24 name: "uri from a base and relative with trailing slash", 25 args: []interface{}{ 26 "http://contoso.org/firstpath/", 27 "myscript.sh", 28 }, 29 expected: "http://contoso.org/firstpath/myscript.sh", 30 }, 31 { 32 name: "uri from a base with trailing slash and relative with ../", 33 args: []interface{}{ 34 "http://contoso.org/firstpath/", 35 "../myscript.sh", 36 }, 37 expected: "http://contoso.org/myscript.sh", 38 }, 39 } 40 41 for _, tt := range tests { 42 t.Run(tt.name, func(t *testing.T) { 43 actual := Uri(tt.args...) 44 require.Equal(t, tt.expected, actual) 45 }) 46 } 47 48 }