Files
zitadel/internal/denylist/denylist_test.go
T
8e82ec1cb9 Merge commit from fork
* Add DenyLists parsing

* Remove unneeded returned error

* Plug global denylist into Command

* app creation: apply denylist to backchannel logout URI

* Inject denylist to backchannel logout worker

* webhook config: validate against blocked URLs

* Add notificationsWebhook denylist target

* command: Add SMTP endpoint validation against blocklist

* command: Add SMS endpoint validation against blocklist

* Validate webhook endpoint against denylist on channel notification

* Remove unused tests

* handle deprecated denylists

* remove unintended denylist entry in deprecated list

* use single http client

* fix tests

* update comments

* fixes

* cleanup

* address comments

* fix merge

---------

Co-authored-by: Livio Spring <[email protected]>
2026-06-15 15:36:14 +02:00

46 lines
1.1 KiB
Go

package denylist
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseDenyList(t *testing.T) {
t.Parallel()
tt := []struct {
testName string
inputIPList []string
expectedAddressCheckers int
expectedError error
}{
{
testName: "when empty list should return no error and no checker list",
},
{
testName: "list with a non-ip should return no error and no checker list",
inputIPList: []string{"127.0.0.1", "localhost", "not an ip"},
expectedAddressCheckers: 3,
},
{
testName: "parseable IP list should return no error, non-zero hash and non-empty checker list",
inputIPList: []string{"127.0.0.1", "localhost", "1.1.1.1"},
expectedAddressCheckers: 3,
},
}
for _, tc := range tt {
t.Run(tc.testName, func(t *testing.T) {
t.Parallel()
// Test
checkers, err := ParseDenyList(tc.inputIPList)
// Verify
assert.Len(t, checkers, tc.expectedAddressCheckers)
assert.ErrorIs(t, err, tc.expectedError)
})
}
}