-
Notifications
You must be signed in to change notification settings - Fork 639
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Headless issue with root user (#132)
* Headless issue with root user. #131 * Linting * Linting * Add input check * misc option update * linting * Fix flag names in check * readme update Co-authored-by: sandeep <[email protected]>
- Loading branch information
1 parent
bedf7cc
commit bc05957
Showing
6 changed files
with
138 additions
and
3 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
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,101 @@ | ||
package types | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/projectdiscovery/goflags" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestParseCustomHeaders(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 value", | ||
input: "a:", | ||
want: map[string]string{"a": ""}, | ||
}, | ||
{ | ||
name: "double input", | ||
input: "a:b,c:d", | ||
want: map[string]string{"a": "b", "c": "d"}, | ||
}, | ||
} | ||
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 := Options{CustomHeaders: strsl} | ||
got := opt.ParseCustomHeaders() | ||
require.Equal(t, tt.want, got) | ||
}) | ||
} | ||
} | ||
|
||
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 := Options{HeadlessOptionalArguments: strsl} | ||
got := opt.ParseHeadlessOptionalArguments() | ||
require.Equal(t, tt.want, got) | ||
}) | ||
} | ||
} |