mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
c578c8651d
This aims to help debug #637.
26 lines
847 B
Go
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"))
|
|
}
|