mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
[MISC] Fix unit tests for Go 1.14+ (#1075)
Due to a [change in net/url](https://golang.org/doc/go1.14#net/url) tests need to be adjusted: When parsing of a URL fails (for example by Parse or ParseRequestURI), the resulting Error message will now quote the unparsable URL. This provides clearer structure and consistency with other parsing errors.
This commit is contained in:
parent
0fba68f62a
commit
24c2375b21
|
@ -58,7 +58,7 @@ func TestShouldGetOriginalURLFromForwardedHeadersWithURI(t *testing.T) {
|
||||||
mock.Ctx.Request.Header.Set("X-Original-URL", "htt-ps//home?-.example.com")
|
mock.Ctx.Request.Header.Set("X-Original-URL", "htt-ps//home?-.example.com")
|
||||||
_, err := getOriginalURL(mock.Ctx)
|
_, err := getOriginalURL(mock.Ctx)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
assert.Equal(t, "Unable to parse URL extracted from X-Original-URL header: parse htt-ps//home?-.example.com: invalid URI for request", err.Error())
|
assert.Equal(t, "Unable to parse URL extracted from X-Original-URL header: parse \"htt-ps//home?-.example.com\": invalid URI for request", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestShouldRaiseWhenTargetUrlIsMalformed(t *testing.T) {
|
func TestShouldRaiseWhenTargetUrlIsMalformed(t *testing.T) {
|
||||||
|
@ -102,7 +102,7 @@ func TestShouldRaiseWhenXForwardedProtoIsNotParsable(t *testing.T) {
|
||||||
|
|
||||||
_, err := getOriginalURL(mock.Ctx)
|
_, err := getOriginalURL(mock.Ctx)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
assert.Equal(t, "Unable to parse URL !:;;:,://myhost.local: parse !:;;:,://myhost.local: invalid URI for request", err.Error())
|
assert.Equal(t, "Unable to parse URL !:;;:,://myhost.local: parse \"!:;;:,://myhost.local\": invalid URI for request", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestShouldRaiseWhenXForwardedURIIsNotParsable(t *testing.T) {
|
func TestShouldRaiseWhenXForwardedURIIsNotParsable(t *testing.T) {
|
||||||
|
@ -115,7 +115,7 @@ func TestShouldRaiseWhenXForwardedURIIsNotParsable(t *testing.T) {
|
||||||
|
|
||||||
_, err := getOriginalURL(mock.Ctx)
|
_, err := getOriginalURL(mock.Ctx)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
assert.Equal(t, "Unable to parse URL https://myhost.local!:;;:,: parse https://myhost.local!:;;:,: invalid port \":,\" after host", err.Error())
|
assert.Equal(t, "Unable to parse URL https://myhost.local!:;;:,: parse \"https://myhost.local!:;;:,\": invalid port \":,\" after host", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test parseBasicAuth.
|
// Test parseBasicAuth.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user