nuclei/pkg/protocols/utils/utils_test.go
Tarun Koyalwar dc44105baf
nuclei v3 : misc updates (#4247)
* use parsed options while signing

* update project layout to v3

* fix .gitignore

* remove example template

* misc updates

* bump tlsx version

* hide template sig warning with env

* js: retain value while using log

* fix nil pointer derefernce

* misc doc update

---------

Co-authored-by: sandeep <8293321+ehsandeep@users.noreply.github.com>
2023-10-17 17:44:13 +05:30

28 lines
690 B
Go

package utils
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestCalculateContentLength(t *testing.T) {
tests := []struct {
name string
expected int64
contentLengthHeader int64
bodyLength int64
}{
{"content-length-header", 10, 10, 10},
{"content-length-header-with-body-length", 10, 10, 1000},
{"no-content-length-header-with-body-length", 1000, -1, 1000},
{"content-length-header-without-body-length", 10, 10, -1},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
got := CalculateContentLength(test.contentLengthHeader, test.bodyLength)
require.Equal(t, test.expected, got)
})
}
}