nuclei/v2/pkg/protocols/common/generators/generators_test.go

82 lines
2.3 KiB
Go
Raw Normal View History

2020-12-22 01:02:38 +05:30
package generators
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestSniperGenerator(t *testing.T) {
2020-12-22 01:21:05 +05:30
usernames := []string{"admin", "password", "login", "test"}
2020-12-29 12:08:46 +05:30
generator, err := New(map[string]interface{}{"username": usernames}, Sniper, "")
2020-12-22 01:21:05 +05:30
require.Nil(t, err, "could not create generator")
iterator := generator.NewIterator()
count := 0
2020-12-26 22:52:33 +05:30
for {
value, ok := iterator.Value()
if !ok {
break
}
2020-12-22 01:21:05 +05:30
count++
2020-12-22 03:54:55 +05:30
require.Contains(t, usernames, value["username"], "Could not get correct sniper")
2020-12-22 01:21:05 +05:30
}
require.Equal(t, len(usernames), count, "could not get correct sniper counts")
}
func TestPitchforkGenerator(t *testing.T) {
usernames := []string{"admin", "token"}
passwords := []string{"admin", "password"}
2020-12-29 12:08:46 +05:30
generator, err := New(map[string]interface{}{"username": usernames, "password": passwords}, PitchFork, "")
2020-12-22 01:21:05 +05:30
require.Nil(t, err, "could not create generator")
iterator := generator.NewIterator()
count := 0
2020-12-26 22:52:33 +05:30
for {
value, ok := iterator.Value()
if !ok {
break
}
2020-12-22 01:21:05 +05:30
count++
require.Contains(t, usernames, value["username"], "Could not get correct pitchfork username")
require.Contains(t, passwords, value["password"], "Could not get correct pitchfork password")
}
require.Equal(t, len(passwords), count, "could not get correct pitchfork counts")
}
func TestClusterbombGenerator(t *testing.T) {
usernames := []string{"admin"}
passwords := []string{"admin", "password", "token"}
2020-12-29 12:08:46 +05:30
generator, err := New(map[string]interface{}{"username": usernames, "password": passwords}, ClusterBomb, "")
2020-12-22 01:02:38 +05:30
require.Nil(t, err, "could not create generator")
iterator := generator.NewIterator()
2020-12-22 01:21:05 +05:30
count := 0
2020-12-26 22:52:33 +05:30
for {
value, ok := iterator.Value()
if !ok {
break
}
count++
require.Contains(t, usernames, value["username"], "Could not get correct clusterbomb username")
require.Contains(t, passwords, value["password"], "Could not get correct clusterbomb password")
}
require.Equal(t, 3, count, "could not get correct clusterbomb counts")
iterator.Reset()
count = 0
for {
value, ok := iterator.Value()
if !ok {
break
}
2020-12-22 01:21:05 +05:30
count++
require.Contains(t, usernames, value["username"], "Could not get correct clusterbomb username")
require.Contains(t, passwords, value["password"], "Could not get correct clusterbomb password")
2020-12-22 01:02:38 +05:30
}
2020-12-22 01:21:05 +05:30
require.Equal(t, 3, count, "could not get correct clusterbomb counts")
2020-12-22 01:02:38 +05:30
}