mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
828f565290
This is going to be the v4. Expected improvements: - More reliable due to static typing. - Bump of performance. - Improvement of logging. - Authelia can be shipped as a single binary. - Will likely work on ARM architecture.
26 lines
782 B
Go
26 lines
782 B
Go
package handlers
|
|
|
|
import (
|
|
"net/url"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func isURLSafe(requestURI string, domain string) bool {
|
|
url, _ := url.ParseRequestURI(requestURI)
|
|
return isRedirectionSafe(*url, domain)
|
|
}
|
|
|
|
func TestShouldReturnFalseOnBadScheme(t *testing.T) {
|
|
assert.False(t, isURLSafe("http://secure.example.com", "example.com"))
|
|
assert.False(t, isURLSafe("ftp://secure.example.com", "example.com"))
|
|
assert.True(t, isURLSafe("https://secure.example.com", "example.com"))
|
|
}
|
|
|
|
func TestShouldReturnFalseOnBadDomain(t *testing.T) {
|
|
assert.False(t, isURLSafe("https://secure.example.com.c", "example.com"))
|
|
assert.False(t, isURLSafe("https://secure.example.comc", "example.com"))
|
|
assert.False(t, isURLSafe("https://secure.example.co", "example.com"))
|
|
}
|