Roman Loginov
e0ce59fd32
We may have a situation where the domain can be specified in the config without a port, and the host in the header will be with a port. As a result, the host will not match. Now the port is not taken into account when checking for a match. Signed-off-by: Roman Loginov <r.loginov@yadro.com>
36 lines
959 B
Go
36 lines
959 B
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"go.uber.org/zap/zaptest"
|
|
)
|
|
|
|
func TestValidateDomains(t *testing.T) {
|
|
inputDomains := []string{
|
|
"s3dev.frostfs.devenv",
|
|
"s3dev.<invalid>.frostfs.devenv",
|
|
"s3dev.<wildcard>.frostfs.devenv",
|
|
"s3dev.<wildcard.frostfs.devenv",
|
|
"s3dev.wildcard>.frostfs.devenv",
|
|
"s3dev.<wild.card>.frostfs.devenv",
|
|
"<invalid>.frostfs.devenv",
|
|
"<wildcard>.frostfs.devenv>",
|
|
"<wildcard>.frostfs.devenv",
|
|
"s3dev.fro<stfs.devenv",
|
|
"<wildcard>.dev.<wildcard>.frostfs.devenv",
|
|
"<wildcard>.dev.<wildc>ard>.frostfs.devenv",
|
|
"s3dev.frostfs.devenv:8888",
|
|
"<wildcard>.frostfs.devenv:443",
|
|
}
|
|
expectedDomains := []string{
|
|
"s3dev.frostfs.devenv",
|
|
"s3dev.<wildcard>.frostfs.devenv",
|
|
"<wildcard>.frostfs.devenv",
|
|
"<wildcard>.dev.<wildcard>.frostfs.devenv",
|
|
}
|
|
|
|
actualDomains := validateDomains(inputDomains, zaptest.NewLogger(t))
|
|
require.Equal(t, expectedDomains, actualDomains)
|
|
}
|