authelia/internal/authorization/domain_matcher_test.go
2020-02-19 09:15:09 +11:00

26 lines
847 B
Go

package authorization
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestDomainMatcher(t *testing.T) {
assert.True(t, isDomainMatching("example.com", "example.com"))
assert.False(t, isDomainMatching("example.com", "*.example.com"))
assert.True(t, isDomainMatching("abc.example.com", "*.example.com"))
assert.True(t, isDomainMatching("abc.def.example.com", "*.example.com"))
// Character * must be followed by . to be valid.
assert.False(t, isDomainMatching("example.com", "*example.com"))
assert.False(t, isDomainMatching("example.com", "*.example.com"))
assert.False(t, isDomainMatching("example.com", "*.exampl.com"))
assert.False(t, isDomainMatching("example.com", "*.other.net"))
assert.False(t, isDomainMatching("example.com", "*other.net"))
assert.False(t, isDomainMatching("example.com", "other.net"))
}