mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
25 lines
867 B
Go
25 lines
867 B
Go
|
package authorization
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestPathMatcher(t *testing.T) {
|
||
|
// Matching any path if no regexp is provided
|
||
|
assert.True(t, isPathMatching("/", []string{}))
|
||
|
|
||
|
assert.False(t, isPathMatching("/", []string{"^/api"}))
|
||
|
assert.True(t, isPathMatching("/api/test", []string{"^/api"}))
|
||
|
assert.False(t, isPathMatching("/api/test", []string{"^/api$"}))
|
||
|
assert.True(t, isPathMatching("/api", []string{"^/api$"}))
|
||
|
assert.True(t, isPathMatching("/api/test", []string{"^/api/?.*"}))
|
||
|
assert.True(t, isPathMatching("/apitest", []string{"^/api/?.*"}))
|
||
|
assert.True(t, isPathMatching("/api/test", []string{"^/api/.*"}))
|
||
|
assert.True(t, isPathMatching("/api/", []string{"^/api/.*"}))
|
||
|
assert.False(t, isPathMatching("/api", []string{"^/api/.*"}))
|
||
|
|
||
|
assert.False(t, isPathMatching("/api", []string{"xyz", "^/api/.*"}))
|
||
|
}
|