mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-17 20:15:27 +00:00
* chore: fix non-constant fmt string in call Signed-off-by: Dwi Siswanto <git@dw1.io> * build: bump all direct modules Signed-off-by: Dwi Siswanto <git@dw1.io> * chore(hosterrorscache): update import path Signed-off-by: Dwi Siswanto <git@dw1.io> * fix(charts): break changes Signed-off-by: Dwi Siswanto <git@dw1.io> * build: pinned `github.com/zmap/zcrypto` to v0.0.0-20240512203510-0fef58d9a9db Signed-off-by: Dwi Siswanto <git@dw1.io> * chore: golangci-lint auto fixes Signed-off-by: Dwi Siswanto <git@dw1.io> * chore: satisfy lints Signed-off-by: Dwi Siswanto <git@dw1.io> * build: migrate `github.com/xanzy/go-gitlab` => `gitlab.com/gitlab-org/api/client-go` Signed-off-by: Dwi Siswanto <git@dw1.io> * feat(json): update build constraints Signed-off-by: Dwi Siswanto <git@dw1.io> * chore: dont panicking on close err Signed-off-by: Dwi Siswanto <git@dw1.io> --------- Signed-off-by: Dwi Siswanto <git@dw1.io>
47 lines
1009 B
Go
47 lines
1009 B
Go
package component
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/projectdiscovery/retryablehttp-go"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestQueryComponent(t *testing.T) {
|
|
req, err := retryablehttp.NewRequest(http.MethodGet, "https://example.com?foo=bar", nil)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
query := NewQuery()
|
|
_, err = query.Parse(req)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
var keys []string
|
|
var values []string
|
|
_ = query.Iterate(func(key string, value interface{}) error {
|
|
keys = append(keys, key)
|
|
values = append(values, value.(string))
|
|
return nil
|
|
})
|
|
|
|
require.Equal(t, []string{"foo"}, keys, "unexpected keys")
|
|
require.Equal(t, []string{"bar"}, values, "unexpected values")
|
|
|
|
err = query.SetValue("foo", "baz")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
rebuilt, err := query.Rebuild()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
require.Equal(t, "foo=baz", rebuilt.RawQuery, "unexpected query string")
|
|
require.Equal(t, "https://example.com?foo=baz", rebuilt.String(), "unexpected url")
|
|
}
|