Skip to content

Commit

Permalink
Fix windows tests
Browse files Browse the repository at this point in the history
Just ignore /../ tests on windows until we have proper suppor.
  • Loading branch information
erikdubbelboer committed Mar 3, 2022
1 parent f54ffa1 commit 282b5b2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 7 additions & 3 deletions server_test.go
Expand Up @@ -16,6 +16,7 @@ import (
"os"
"reflect"
"regexp"
"runtime"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -573,12 +574,15 @@ func TestRequestCtxRedirect(t *testing.T) {
testRequestCtxRedirect(t, "http://qqq/foo/bar?baz=111", "x.html?b=1#aaa=bbb&cc=ddd", "http://qqq/foo/x.html?b=1#aaa=bbb&cc=ddd")
testRequestCtxRedirect(t, "http://qqq/foo/bar?baz=111", "/x.html", "http://qqq/x.html")
testRequestCtxRedirect(t, "http://qqq/foo/bar?baz=111", "/x.html#aaa=bbb&cc=ddd", "http://qqq/x.html#aaa=bbb&cc=ddd")
testRequestCtxRedirect(t, "http://qqq/foo/bar?baz=111", "../x.html", "http://qqq/x.html")
testRequestCtxRedirect(t, "http://qqq/foo/bar?baz=111", "../../x.html", "http://qqq/x.html")
testRequestCtxRedirect(t, "http://qqq/foo/bar?baz=111", "./.././../x.html", "http://qqq/x.html")
testRequestCtxRedirect(t, "http://qqq/foo/bar?baz=111", "http://foo.bar/baz", "http://foo.bar/baz")
testRequestCtxRedirect(t, "http://qqq/foo/bar?baz=111", "https://foo.bar/baz", "https://foo.bar/baz")
testRequestCtxRedirect(t, "https://foo.com/bar?aaa", "//google.com/aaa?bb", "https://google.com/aaa?bb")

if runtime.GOOS != "windows" {
testRequestCtxRedirect(t, "http://qqq/foo/bar?baz=111", "../x.html", "http://qqq/x.html")
testRequestCtxRedirect(t, "http://qqq/foo/bar?baz=111", "../../x.html", "http://qqq/x.html")
testRequestCtxRedirect(t, "http://qqq/foo/bar?baz=111", "./.././../x.html", "http://qqq/x.html")
}
}

func testRequestCtxRedirect(t *testing.T, origURL, redirectURL, expectedURL string) {
Expand Down
11 changes: 10 additions & 1 deletion uri_test.go
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"reflect"
"runtime"
"testing"
"time"
)
Expand Down Expand Up @@ -120,12 +121,16 @@ func TestURIUpdate(t *testing.T) {

// relative uri
testURIUpdate(t, "http://example.com/baz/xxx.html?aaa=22#aaa", "bb.html?xx=12#pp", "http://example.com/baz/bb.html?xx=12#pp")
testURIUpdate(t, "http://example.com/a/b/c/d", "../qwe/p?zx=34", "http://example.com/a/b/qwe/p?zx=34")

testURIUpdate(t, "http://example.com/aaa.html?foo=bar", "?baz=434&aaa#xcv", "http://example.com/aaa.html?baz=434&aaa#xcv")
testURIUpdate(t, "http://example.com/baz", "~a/%20b=c,тест?йцу=ке", "http://example.com/~a/%20b=c,%D1%82%D0%B5%D1%81%D1%82?йцу=ке")
testURIUpdate(t, "http://example.com/baz", "/qwe#fragment", "http://example.com/qwe#fragment")
testURIUpdate(t, "http://example.com/baz/xxx", "aaa.html#bb?cc=dd&ee=dfd", "http://example.com/baz/aaa.html#bb?cc=dd&ee=dfd")

if runtime.GOOS != "windows" {
testURIUpdate(t, "http://example.com/a/b/c/d", "../qwe/p?zx=34", "http://example.com/a/b/qwe/p?zx=34")
}

// hash
testURIUpdate(t, "http://example.com/#fragment1", "#fragment2", "http://example.com/#fragment2")

Expand All @@ -147,6 +152,10 @@ func testURIUpdate(t *testing.T, base, update, result string) {
}

func TestURIPathNormalize(t *testing.T) {
if runtime.GOOS == "windows" {
t.SkipNow()
}

t.Parallel()

var u URI
Expand Down

0 comments on commit 282b5b2

Please sign in to comment.