2021-02-03 07:37:24 +00:00
|
|
|
package network
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
2021-07-19 18:04:08 +00:00
|
|
|
|
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
2021-09-03 13:48:39 +00:00
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
2021-11-04 21:31:41 +00:00
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/testutils"
|
2021-02-03 07:37:24 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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"},
|
2021-02-03 07:37:24 +00:00
|
|
|
ReadSize: 1024,
|
2021-02-03 12:19:10 +00:00
|
|
|
Inputs: []*Input{{Data: "test-data"}},
|
2021-02-03 07:37:24 +00:00
|
|
|
}
|
|
|
|
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
|
|
|
ID: templateID,
|
2021-09-03 13:48:39 +00:00
|
|
|
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
2021-02-03 07:37:24 +00:00
|
|
|
})
|
|
|
|
err := request.Compile(executerOpts)
|
|
|
|
require.Nil(t, err, "could not compile network request")
|
|
|
|
|
2021-11-23 05:14:31 +00:00
|
|
|
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) {
|
2021-11-23 05:14:31 +00:00
|
|
|
require.True(t, request.addresses[0].tls, "could not get correct port for host")
|
2021-02-03 07:37:24 +00:00
|
|
|
})
|
|
|
|
}
|