config: fix commit-graph related config docs
[alt-git.git] / t / t0110-urlmatch-normalization.sh
blobf99529d83853e2c468b1c948f3ec4408a58fb919
1 #!/bin/sh
3 test_description='urlmatch URL normalization'
4 . ./test-lib.sh
6 # The base name of the test url files
7 tu="$TEST_DIRECTORY/t0110/url"
9 # Note that only file: URLs should be allowed without a host
11 test_expect_success 'url scheme' '
12 ! test-tool urlmatch-normalization "" &&
13 ! test-tool urlmatch-normalization "_" &&
14 ! test-tool urlmatch-normalization "scheme" &&
15 ! test-tool urlmatch-normalization "scheme:" &&
16 ! test-tool urlmatch-normalization "scheme:/" &&
17 ! test-tool urlmatch-normalization "scheme://" &&
18 ! test-tool urlmatch-normalization "file" &&
19 ! test-tool urlmatch-normalization "file:" &&
20 ! test-tool urlmatch-normalization "file:/" &&
21 test-tool urlmatch-normalization "file://" &&
22 ! test-tool urlmatch-normalization "://acme.co" &&
23 ! test-tool urlmatch-normalization "x_test://acme.co" &&
24 ! test-tool urlmatch-normalization "-test://acme.co" &&
25 ! test-tool urlmatch-normalization "0test://acme.co" &&
26 ! test-tool urlmatch-normalization "+test://acme.co" &&
27 ! test-tool urlmatch-normalization ".test://acme.co" &&
28 ! test-tool urlmatch-normalization "schem%6e://" &&
29 test-tool urlmatch-normalization "x-Test+v1.0://acme.co" &&
30 test "$(test-tool urlmatch-normalization -p "AbCdeF://x.Y")" = "abcdef://x.y/"
33 test_expect_success 'url authority' '
34 ! test-tool urlmatch-normalization "scheme://user:pass@" &&
35 ! test-tool urlmatch-normalization "scheme://?" &&
36 ! test-tool urlmatch-normalization "scheme://#" &&
37 ! test-tool urlmatch-normalization "scheme:///" &&
38 ! test-tool urlmatch-normalization "scheme://:" &&
39 ! test-tool urlmatch-normalization "scheme://:555" &&
40 test-tool urlmatch-normalization "file://user:pass@" &&
41 test-tool urlmatch-normalization "file://?" &&
42 test-tool urlmatch-normalization "file://#" &&
43 test-tool urlmatch-normalization "file:///" &&
44 test-tool urlmatch-normalization "file://:" &&
45 ! test-tool urlmatch-normalization "file://:555" &&
46 test-tool urlmatch-normalization "scheme://user:pass@host" &&
47 test-tool urlmatch-normalization "scheme://@host" &&
48 test-tool urlmatch-normalization "scheme://%00@host" &&
49 ! test-tool urlmatch-normalization "scheme://%%@host" &&
50 ! test-tool urlmatch-normalization "scheme://host_" &&
51 test-tool urlmatch-normalization "scheme://user:pass@host/" &&
52 test-tool urlmatch-normalization "scheme://@host/" &&
53 test-tool urlmatch-normalization "scheme://host/" &&
54 test-tool urlmatch-normalization "scheme://host?x" &&
55 test-tool urlmatch-normalization "scheme://host#x" &&
56 test-tool urlmatch-normalization "scheme://host/@" &&
57 test-tool urlmatch-normalization "scheme://host?@x" &&
58 test-tool urlmatch-normalization "scheme://host#@x" &&
59 test-tool urlmatch-normalization "scheme://[::1]" &&
60 test-tool urlmatch-normalization "scheme://[::1]/" &&
61 ! test-tool urlmatch-normalization "scheme://hos%41/" &&
62 test-tool urlmatch-normalization "scheme://[invalid....:/" &&
63 test-tool urlmatch-normalization "scheme://invalid....:]/" &&
64 ! test-tool urlmatch-normalization "scheme://invalid....:[/" &&
65 ! test-tool urlmatch-normalization "scheme://invalid....:["
68 test_expect_success 'url port checks' '
69 test-tool urlmatch-normalization "xyz://q@some.host:" &&
70 test-tool urlmatch-normalization "xyz://q@some.host:456/" &&
71 ! test-tool urlmatch-normalization "xyz://q@some.host:0" &&
72 ! test-tool urlmatch-normalization "xyz://q@some.host:0000000" &&
73 test-tool urlmatch-normalization "xyz://q@some.host:0000001?" &&
74 test-tool urlmatch-normalization "xyz://q@some.host:065535#" &&
75 test-tool urlmatch-normalization "xyz://q@some.host:65535" &&
76 ! test-tool urlmatch-normalization "xyz://q@some.host:65536" &&
77 ! test-tool urlmatch-normalization "xyz://q@some.host:99999" &&
78 ! test-tool urlmatch-normalization "xyz://q@some.host:100000" &&
79 ! test-tool urlmatch-normalization "xyz://q@some.host:100001" &&
80 test-tool urlmatch-normalization "http://q@some.host:80" &&
81 test-tool urlmatch-normalization "https://q@some.host:443" &&
82 test-tool urlmatch-normalization "http://q@some.host:80/" &&
83 test-tool urlmatch-normalization "https://q@some.host:443?" &&
84 ! test-tool urlmatch-normalization "http://q@:8008" &&
85 ! test-tool urlmatch-normalization "http://:8080" &&
86 ! test-tool urlmatch-normalization "http://:" &&
87 test-tool urlmatch-normalization "xyz://q@some.host:456/" &&
88 test-tool urlmatch-normalization "xyz://[::1]:456/" &&
89 test-tool urlmatch-normalization "xyz://[::1]:/" &&
90 ! test-tool urlmatch-normalization "xyz://[::1]:000/" &&
91 ! test-tool urlmatch-normalization "xyz://[::1]:0%300/" &&
92 ! test-tool urlmatch-normalization "xyz://[::1]:0x80/" &&
93 ! test-tool urlmatch-normalization "xyz://[::1]:4294967297/" &&
94 ! test-tool urlmatch-normalization "xyz://[::1]:030f/"
97 test_expect_success 'url port normalization' '
98 test "$(test-tool urlmatch-normalization -p "http://x:800")" = "http://x:800/" &&
99 test "$(test-tool urlmatch-normalization -p "http://x:0800")" = "http://x:800/" &&
100 test "$(test-tool urlmatch-normalization -p "http://x:00000800")" = "http://x:800/" &&
101 test "$(test-tool urlmatch-normalization -p "http://x:065535")" = "http://x:65535/" &&
102 test "$(test-tool urlmatch-normalization -p "http://x:1")" = "http://x:1/" &&
103 test "$(test-tool urlmatch-normalization -p "http://x:80")" = "http://x/" &&
104 test "$(test-tool urlmatch-normalization -p "http://x:080")" = "http://x/" &&
105 test "$(test-tool urlmatch-normalization -p "http://x:000000080")" = "http://x/" &&
106 test "$(test-tool urlmatch-normalization -p "https://x:443")" = "https://x/" &&
107 test "$(test-tool urlmatch-normalization -p "https://x:0443")" = "https://x/" &&
108 test "$(test-tool urlmatch-normalization -p "https://x:000000443")" = "https://x/"
111 test_expect_success 'url general escapes' '
112 ! test-tool urlmatch-normalization "http://x.y?%fg" &&
113 test "$(test-tool urlmatch-normalization -p "X://W/%7e%41^%3a")" = "x://w/~A%5E%3A" &&
114 test "$(test-tool urlmatch-normalization -p "X://W/:/?#[]@")" = "x://w/:/?#[]@" &&
115 test "$(test-tool urlmatch-normalization -p "X://W/$&()*+,;=")" = "x://w/$&()*+,;=" &&
116 test "$(test-tool urlmatch-normalization -p "X://W/'\''")" = "x://w/'\''" &&
117 test "$(test-tool urlmatch-normalization -p "X://W?'\!'")" = "x://w/?'\!'"
120 test_expect_success !MINGW 'url high-bit escapes' '
121 test "$(test-tool urlmatch-normalization -p "$(cat "$tu-1")")" = "x://q/%01%02%03%04%05%06%07%08%0E%0F%10%11%12" &&
122 test "$(test-tool urlmatch-normalization -p "$(cat "$tu-2")")" = "x://q/%13%14%15%16%17%18%19%1B%1C%1D%1E%1F%7F" &&
123 test "$(test-tool urlmatch-normalization -p "$(cat "$tu-3")")" = "x://q/%80%81%82%83%84%85%86%87%88%89%8A%8B%8C%8D%8E%8F" &&
124 test "$(test-tool urlmatch-normalization -p "$(cat "$tu-4")")" = "x://q/%90%91%92%93%94%95%96%97%98%99%9A%9B%9C%9D%9E%9F" &&
125 test "$(test-tool urlmatch-normalization -p "$(cat "$tu-5")")" = "x://q/%A0%A1%A2%A3%A4%A5%A6%A7%A8%A9%AA%AB%AC%AD%AE%AF" &&
126 test "$(test-tool urlmatch-normalization -p "$(cat "$tu-6")")" = "x://q/%B0%B1%B2%B3%B4%B5%B6%B7%B8%B9%BA%BB%BC%BD%BE%BF" &&
127 test "$(test-tool urlmatch-normalization -p "$(cat "$tu-7")")" = "x://q/%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF" &&
128 test "$(test-tool urlmatch-normalization -p "$(cat "$tu-8")")" = "x://q/%D0%D1%D2%D3%D4%D5%D6%D7%D8%D9%DA%DB%DC%DD%DE%DF" &&
129 test "$(test-tool urlmatch-normalization -p "$(cat "$tu-9")")" = "x://q/%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF" &&
130 test "$(test-tool urlmatch-normalization -p "$(cat "$tu-10")")" = "x://q/%F0%F1%F2%F3%F4%F5%F6%F7%F8%F9%FA%FB%FC%FD%FE%FF"
133 test_expect_success 'url utf-8 escapes' '
134 test "$(test-tool urlmatch-normalization -p "$(cat "$tu-11")")" = "x://q/%C2%80%DF%BF%E0%A0%80%EF%BF%BD%F0%90%80%80%F0%AF%BF%BD"
137 test_expect_success 'url username/password escapes' '
138 test "$(test-tool urlmatch-normalization -p "x://%41%62(^):%70+d@foo")" = "x://Ab(%5E):p+d@foo/"
141 test_expect_success 'url normalized lengths' '
142 test "$(test-tool urlmatch-normalization -l "Http://%4d%65:%4d^%70@The.Host")" = 25 &&
143 test "$(test-tool urlmatch-normalization -l "http://%41:%42@x.y/%61/")" = 17 &&
144 test "$(test-tool urlmatch-normalization -l "http://@x.y/^")" = 15
147 test_expect_success 'url . and .. segments' '
148 test "$(test-tool urlmatch-normalization -p "x://y/.")" = "x://y/" &&
149 test "$(test-tool urlmatch-normalization -p "x://y/./")" = "x://y/" &&
150 test "$(test-tool urlmatch-normalization -p "x://y/a/.")" = "x://y/a" &&
151 test "$(test-tool urlmatch-normalization -p "x://y/a/./")" = "x://y/a/" &&
152 test "$(test-tool urlmatch-normalization -p "x://y/.?")" = "x://y/?" &&
153 test "$(test-tool urlmatch-normalization -p "x://y/./?")" = "x://y/?" &&
154 test "$(test-tool urlmatch-normalization -p "x://y/a/.?")" = "x://y/a?" &&
155 test "$(test-tool urlmatch-normalization -p "x://y/a/./?")" = "x://y/a/?" &&
156 test "$(test-tool urlmatch-normalization -p "x://y/a/./b/.././../c")" = "x://y/c" &&
157 test "$(test-tool urlmatch-normalization -p "x://y/a/./b/../.././c/")" = "x://y/c/" &&
158 test "$(test-tool urlmatch-normalization -p "x://y/a/./b/.././../c/././.././.")" = "x://y/" &&
159 ! test-tool urlmatch-normalization "x://y/a/./b/.././../c/././.././.." &&
160 test "$(test-tool urlmatch-normalization -p "x://y/a/./?/././..")" = "x://y/a/?/././.." &&
161 test "$(test-tool urlmatch-normalization -p "x://y/%2e/")" = "x://y/" &&
162 test "$(test-tool urlmatch-normalization -p "x://y/%2E/")" = "x://y/" &&
163 test "$(test-tool urlmatch-normalization -p "x://y/a/%2e./")" = "x://y/" &&
164 test "$(test-tool urlmatch-normalization -p "x://y/b/.%2E/")" = "x://y/" &&
165 test "$(test-tool urlmatch-normalization -p "x://y/c/%2e%2E/")" = "x://y/"
168 # http://@foo specifies an empty user name but does not specify a password
169 # http://foo specifies neither a user name nor a password
170 # So they should not be equivalent
171 test_expect_success 'url equivalents' '
172 test-tool urlmatch-normalization "httP://x" "Http://X/" &&
173 test-tool urlmatch-normalization "Http://%4d%65:%4d^%70@The.Host" "hTTP://Me:%4D^p@the.HOST:80/" &&
174 ! test-tool urlmatch-normalization "https://@x.y/^" "httpS://x.y:443/^" &&
175 test-tool urlmatch-normalization "https://@x.y/^" "httpS://@x.y:0443/^" &&
176 test-tool urlmatch-normalization "https://@x.y/^/../abc" "httpS://@x.y:0443/abc" &&
177 test-tool urlmatch-normalization "https://@x.y/^/.." "httpS://@x.y:0443/"
180 test_done