nuclei/v2/pkg/protocols/network/network_test.go

36 lines
1.1 KiB
Go
Raw Normal View History

package network
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/projectdiscovery/nuclei/v2/pkg/model"
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
"github.com/projectdiscovery/nuclei/v2/pkg/testutils"
)
func TestNetworkCompileMake(t *testing.T) {
options := testutils.DefaultOptions
testutils.Init(options)
templateID := "testing-network"
request := &Request{
ID: templateID,
2021-11-30 06:34:47 +00:00
Address: []string{"tls://{{Host}}:443"},
ReadSize: 1024,
2021-02-03 12:19:10 +00:00
Inputs: []*Input{{Data: "test-data"}},
}
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
ID: templateID,
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
})
err := request.Compile(executerOpts)
require.Nil(t, err, "could not compile network request")
require.Equal(t, 1, len(request.addresses), "could not get correct number of input address")
2021-02-23 12:47:24 +00:00
t.Run("check-tls-with-port", func(t *testing.T) {
require.True(t, request.addresses[0].tls, "could not get correct port for host")
})
}