-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1288 from projectdiscovery/dynamic-value-reuse-http
Reusing dynamically extracted values as iterators in http request
- Loading branch information
Showing
10 changed files
with
392 additions
and
79 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package operators | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestMakeDynamicValuesCallback(t *testing.T) { | ||
input := map[string][]string{ | ||
"a": []string{"1", "2"}, | ||
"b": []string{"3"}, | ||
"c": []string{}, | ||
"d": []string{"A", "B", "C"}, | ||
} | ||
|
||
count := 0 | ||
MakeDynamicValuesCallback(input, true, func(data map[string]interface{}) bool { | ||
count++ | ||
require.Len(t, data, 3, "could not get correct output length") | ||
return false | ||
}) | ||
require.Equal(t, 3, count, "could not get correct result count") | ||
|
||
t.Run("all", func(t *testing.T) { | ||
input := map[string][]string{ | ||
"a": []string{"1"}, | ||
"b": []string{"2"}, | ||
"c": []string{"3"}, | ||
} | ||
|
||
count := 0 | ||
MakeDynamicValuesCallback(input, true, func(data map[string]interface{}) bool { | ||
count++ | ||
require.Len(t, data, 3, "could not get correct output length") | ||
return false | ||
}) | ||
require.Equal(t, 1, count, "could not get correct result count") | ||
}) | ||
|
||
t.Run("first", func(t *testing.T) { | ||
input := map[string][]string{ | ||
"a": []string{"1", "2"}, | ||
"b": []string{"3"}, | ||
"c": []string{}, | ||
"d": []string{"A", "B", "C"}, | ||
} | ||
|
||
count := 0 | ||
MakeDynamicValuesCallback(input, false, func(data map[string]interface{}) bool { | ||
count++ | ||
require.Len(t, data, 3, "could not get correct output length") | ||
return false | ||
}) | ||
require.Equal(t, 1, count, "could not get correct result count") | ||
}) | ||
} |
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,16 @@ | ||
package generators | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestMergeMapsMany(t *testing.T) { | ||
got := MergeMapsMany(map[string]interface{}{"a": []string{"1", "2"}, "c": "5"}, map[string][]string{"b": []string{"3", "4"}}) | ||
require.Equal(t, map[string][]string{ | ||
"a": []string{"1", "2"}, | ||
"b": []string{"3", "4"}, | ||
"c": []string{"5"}, | ||
}, got, "could not get correct merged map") | ||
} |
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
Oops, something went wrong.