MM-11931 Add support for AllowedUntrustedInternalConnections to be comma-separated (#11614)
* Add support for AllowedUntrustedInternalConnections to be comma-separated * Add comprehensive test cases for fields splitting function
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
cb534c704e
Коммит
dac7014b48
@@ -11,7 +11,10 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestHTTPClient(t *testing.T) {
|
||||
@@ -186,3 +189,44 @@ func TestIsOwnIP(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSplitHostnames(t *testing.T) {
|
||||
var config string
|
||||
var hostnames []string
|
||||
|
||||
config = ""
|
||||
hostnames = strings.FieldsFunc(config, splitFields)
|
||||
require.Equal(t, []string{}, hostnames)
|
||||
|
||||
config = "127.0.0.1 localhost"
|
||||
hostnames = strings.FieldsFunc(config, splitFields)
|
||||
require.Equal(t, []string{"127.0.0.1", "localhost"}, hostnames)
|
||||
|
||||
config = "127.0.0.1,localhost"
|
||||
hostnames = strings.FieldsFunc(config, splitFields)
|
||||
require.Equal(t, []string{"127.0.0.1", "localhost"}, hostnames)
|
||||
|
||||
config = "127.0.0.1,,localhost"
|
||||
hostnames = strings.FieldsFunc(config, splitFields)
|
||||
require.Equal(t, []string{"127.0.0.1", "localhost"}, hostnames)
|
||||
|
||||
config = "127.0.0.1 localhost"
|
||||
hostnames = strings.FieldsFunc(config, splitFields)
|
||||
require.Equal(t, []string{"127.0.0.1", "localhost"}, hostnames)
|
||||
|
||||
config = "127.0.0.1 , localhost"
|
||||
hostnames = strings.FieldsFunc(config, splitFields)
|
||||
require.Equal(t, []string{"127.0.0.1", "localhost"}, hostnames)
|
||||
|
||||
config = "127.0.0.1 localhost "
|
||||
hostnames = strings.FieldsFunc(config, splitFields)
|
||||
require.Equal(t, []string{"127.0.0.1", "localhost"}, hostnames)
|
||||
|
||||
config = " 127.0.0.1 ,,localhost , , ,,"
|
||||
hostnames = strings.FieldsFunc(config, splitFields)
|
||||
require.Equal(t, []string{"127.0.0.1", "localhost"}, hostnames)
|
||||
|
||||
config = "127.0.0.1 localhost, 192.168.1.0"
|
||||
hostnames = strings.FieldsFunc(config, splitFields)
|
||||
require.Equal(t, []string{"127.0.0.1", "localhost", "192.168.1.0"}, hostnames)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user