-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0828339
commit b301b1b
Showing
6 changed files
with
95 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package runner | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/projectdiscovery/goflags" | ||
"github.com/projectdiscovery/nuclei/v2/pkg/types" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestParseHeadlessOptionalArguments(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
input string | ||
want map[string]string | ||
}{ | ||
{ | ||
name: "single value", | ||
input: "a=b", | ||
want: map[string]string{"a": "b"}, | ||
}, | ||
{ | ||
name: "empty string", | ||
input: "", | ||
want: map[string]string{}, | ||
}, | ||
{ | ||
name: "empty key", | ||
input: "=b", | ||
want: map[string]string{}, | ||
}, | ||
{ | ||
name: "empty value", | ||
input: "a=", | ||
want: map[string]string{}, | ||
}, | ||
{ | ||
name: "double input", | ||
input: "a=b,c=d", | ||
want: map[string]string{"a": "b", "c": "d"}, | ||
}, | ||
{ | ||
name: "duplicated input", | ||
input: "a=b,a=b", | ||
want: map[string]string{"a": "b"}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
strsl := goflags.StringSlice{} | ||
for _, v := range strings.Split(tt.input, ",") { | ||
//nolint | ||
strsl.Set(v) | ||
} | ||
opt := types.Options{HeadlessOptionalArguments: strsl} | ||
got := opt.ParseHeadlessOptionalArguments() | ||
require.Equal(t, tt.want, got) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters