Skip to content

Commit f97c742

Browse files
committed
test: Apply coderabbitai PR test feedback
1 parent 7fc0b1f commit f97c742

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

pkg/server/server_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package server
22

33
import (
4+
"strings"
45
"testing"
56

67
"github.com/projectdiscovery/interactsh/pkg/settings"
@@ -19,7 +20,7 @@ func TestIsCorrelationID(t *testing.T) {
1920
options := Options{CorrelationIdLength: settings.CorrelationIdLengthDefault, CorrelationIdNonceLength: settings.CorrelationIdNonceLengthDefault}
2021

2122
t.Run("exact length match", func(t *testing.T) {
22-
id := xid.New().String() + "aaabbbbcccccc"
23+
id := strings.Repeat("a", options.CorrelationIdLength) + strings.Repeat("b", options.CorrelationIdNonceLength)
2324
require.True(t, options.isCorrelationID(id))
2425
})
2526

@@ -30,7 +31,7 @@ func TestIsCorrelationID(t *testing.T) {
3031
t.Run("sliding window finds embedded ID", func(t *testing.T) {
3132
shortNonce := Options{CorrelationIdLength: settings.CorrelationIdLengthDefault, CorrelationIdNonceLength: 4}
3233
validID := xid.New().String() + "abcd"
33-
longer := validID + "extrapaddi" // simulates client with longer nonce
34+
longer := ".." + validID + ".." // non-alphanumeric padding prevents spurious matches
3435
found := false
3536
for chunk := range stringsutil.SlideWithLength(longer, shortNonce.GetIdLength()) {
3637
if shortNonce.isCorrelationID(chunk) {

0 commit comments

Comments
 (0)