Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
projectdiscovery
GitHub Repository: projectdiscovery/nuclei
Path: blob/dev/pkg/input/formats/yaml/multidoc_test.go
2070 views
1
package yaml
2
3
import (
4
"os"
5
"testing"
6
7
"github.com/projectdiscovery/nuclei/v3/pkg/input/types"
8
"github.com/stretchr/testify/require"
9
)
10
11
func TestYamlFormatterParse(t *testing.T) {
12
format := New()
13
14
proxifyInputFile := "../testdata/ginandjuice.proxify.yaml"
15
16
expectedUrls := []string{
17
"https://ginandjuice.shop/blog/post?postId=3&source=proxify",
18
"https://ginandjuice.shop/users/3",
19
}
20
21
file, err := os.Open(proxifyInputFile)
22
require.Nilf(t, err, "error opening proxify input file: %v", err)
23
defer func() {
24
_ = file.Close()
25
}()
26
27
var urls []string
28
err = format.Parse(file, func(request *types.RequestResponse) bool {
29
urls = append(urls, request.URL.String())
30
return false
31
}, proxifyInputFile)
32
require.Nilf(t, err, "error parsing yaml file: %v", err)
33
require.Len(t, urls, len(expectedUrls), "invalid number of urls")
34
require.ElementsMatch(t, urls, expectedUrls, "invalid urls")
35
}
36
37