mirror of
https://github.com/TecharoHQ/anubis.git
synced 2025-08-04 02:08:59 -04:00

* chore(deps): update dependencies in go.mod and go.sum Signed-off-by: Jason Cameron <git@jasoncameron.dev> * refactor: rename variables for clarity in anubis.go and main.go Signed-off-by: Jason Cameron <git@jasoncameron.dev> * fix(checker): handle error when inserting IP range in ranger Signed-off-by: Jason Cameron <git@jasoncameron.dev> * fix(tests): simplify boolean checks in header and URL value tests Signed-off-by: Jason Cameron <git@jasoncameron.dev> * refactor(api): remove unused /test-error endpoint and restrict /make-challenge to development Signed-off-by: Jason Cameron <git@jasoncameron.dev> * build(deps): update golang-set to v2.8.0 in go.sum Signed-off-by: Jason Cameron <git@jasoncameron.dev> * Update metadata check-spelling run (pull_request) for json/stuff Signed-off-by: check-spelling-bot <check-spelling-bot@users.noreply.github.com> on-behalf-of: @check-spelling <check-spelling-bot@check-spelling.dev> --------- Signed-off-by: Jason Cameron <git@jasoncameron.dev> Signed-off-by: check-spelling-bot <check-spelling-bot@users.noreply.github.com>
51 lines
1017 B
Go
51 lines
1017 B
Go
package expressions
|
|
|
|
import (
|
|
"net/url"
|
|
"testing"
|
|
|
|
"github.com/google/cel-go/common/types"
|
|
)
|
|
|
|
func TestURLValues(t *testing.T) {
|
|
headers := URLValues{
|
|
Values: url.Values{
|
|
"format": {"json"},
|
|
},
|
|
}
|
|
|
|
t.Run("contains-existing-key", func(t *testing.T) {
|
|
resp := headers.Contains(types.String("format"))
|
|
if !resp.(types.Bool) {
|
|
t.Fatal("headers does not contain User-Agent")
|
|
}
|
|
})
|
|
|
|
t.Run("not-contains-missing-key", func(t *testing.T) {
|
|
resp := headers.Contains(types.String("not-there"))
|
|
if resp.(types.Bool) {
|
|
t.Fatal("headers does not contain User-Agent")
|
|
}
|
|
})
|
|
|
|
t.Run("get-existing-key", func(t *testing.T) {
|
|
val := headers.Get(types.String("format"))
|
|
switch val.(type) {
|
|
case types.String:
|
|
// ok
|
|
default:
|
|
t.Fatalf("result was wrong type %T", val)
|
|
}
|
|
})
|
|
|
|
t.Run("not-get-missing-key", func(t *testing.T) {
|
|
val := headers.Get(types.String("not-there"))
|
|
switch val.(type) {
|
|
case *types.Err:
|
|
// ok
|
|
default:
|
|
t.Fatalf("result was wrong type %T", val)
|
|
}
|
|
})
|
|
}
|