nuclei/pkg/protocols/http/cluster_test.go
Kristinn Vikar Jónsson 381ebba6a2
Clustering performance improvements (#5319)
* Clustering performance improvements

* IsClusterable filters out beforehand, update test to mirror that

* inverse IsClusterable
This makes much more sense

* HashMap based clustering

* furthur improvements to clustering

---------

Co-authored-by: Tarun Koyalwar <tarun@projectdiscovery.io>
2024-06-27 13:14:43 +05:30

19 lines
657 B
Go

package http
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestCanCluster(t *testing.T) {
req := &Request{Unsafe: true}
require.False(t, req.IsClusterable(), "could cluster unsafe request")
req = &Request{Path: []string{"{{BaseURL}}"}, Method: HTTPMethodTypeHolder{MethodType: HTTPGet}}
newReq := &Request{Path: []string{"{{BaseURL}}"}, Method: HTTPMethodTypeHolder{MethodType: HTTPGet}}
require.True(t, req.IsClusterable(), "could not cluster GET request")
require.True(t, req.IsClusterable(), "could not cluster GET request")
require.Equal(t, req.TmplClusterKey(), newReq.TmplClusterKey(), "cluster keys should be equal")
}