Repository navigation
Expand file tree
/
Copy pathCodeoriginTest.php
More file actions
200 lines (169 loc) · 5.79 KB
/
Copy pathCodeoriginTest.php
File metadata and controls
200 lines (169 loc) · 5.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<?php
/**
* Usage:
*
* $ php test/CodeoriginTest.php
*
* $ php test/CodeoriginTest.php "http://localhost:4000"
*
* $ php test/CodeoriginTest.php "http://code.jquery.com"
* $ php test/CodeoriginTest.php "https://code.jquery.com"
*/
require_once __DIR__ . '/Unit.php';
$origin = @$argv[1] ?: 'http://localhost:4000';
Unit::start();
// Domain root
Unit::testHttp( $origin, '/', [], [
'status' => '301',
'server' => 'nginx',
'location' => 'https://releases.jquery.com/',
] );
// Static assets
Unit::testHttp( $origin, '/jquery-3.0.0.js', [], [
'status' => '200',
'server' => 'nginx',
'content-type' => 'application/javascript; charset=utf-8',
'content-length' => '263268',
'last-modified' => 'Fri, 18 Oct 1991 12:00:00 GMT',
'vary' => 'Accept-Encoding',
'etag' => '"28feccc0-40464"',
'cache-control' => 'public, max-age=31536000, stale-while-revalidate=604800',
'access-control-allow-origin' => '*',
'accept-ranges' => 'bytes',
'cross-origin-resource-policy' => 'cross-origin',
] );
Unit::testHttp( $origin, '/qunit/qunit-2.0.0.css', [], [
'status' => '200',
'server' => 'nginx',
'content-type' => 'text/css',
'content-length' => '7456',
'last-modified' => 'Fri, 18 Oct 1991 12:00:00 GMT',
'vary' => 'Accept-Encoding',
'etag' => '"28feccc0-1d20"',
'cache-control' => 'public, max-age=31536000, stale-while-revalidate=604800',
'access-control-allow-origin' => '*',
'accept-ranges' => 'bytes',
'cross-origin-resource-policy' => 'cross-origin',
] );
Unit::testHttp( $origin, '/ui/1.10.0/themes/base/images/ui-icons_222222_256x240.png', [], [
'status' => '200',
'server' => 'nginx',
'content-type' => 'image/png',
'content-length' => '4369',
'last-modified' => 'Fri, 18 Oct 1991 12:00:00 GMT',
'etag' => '"28feccc0-1111"',
'cache-control' => 'public, max-age=31536000, stale-while-revalidate=604800',
'access-control-allow-origin' => '*',
'accept-ranges' => 'bytes',
'cross-origin-resource-policy' => 'cross-origin',
] );
Unit::testHttp( $origin, '/jquery-2.0.0.min.map', [], [
'status' => '200',
'server' => 'nginx',
'content-type' => 'application/octet-stream',
'content-length' => '126081',
'last-modified' => 'Fri, 18 Oct 1991 12:00:00 GMT',
'etag' => '"28feccc0-1ec81"',
'cache-control' => 'public, max-age=31536000, stale-while-revalidate=604800',
'access-control-allow-origin' => '*',
'accept-ranges' => 'bytes',
'cross-origin-resource-policy' => 'cross-origin',
] );
// Static asset
Unit::testHttp( $origin, '/jquery-3.0.0.js', [
"x-cdn-access: there-is-no-spoon"
], [
'status' => '200',
'server' => 'nginx',
'content-type' => 'application/javascript; charset=utf-8',
'content-length' => '263268',
'last-modified' => 'Fri, 18 Oct 1991 12:00:00 GMT',
'vary' => 'Accept-Encoding',
'etag' => '"28feccc0-40464"',
'cache-control' => 'public, max-age=31536000, stale-while-revalidate=604800',
'access-control-allow-origin' => '*',
'accept-ranges' => 'bytes',
'cross-origin-resource-policy' => 'cross-origin',
] );
// Gzip Compression
Unit::testHttp( $origin, '/jquery-3.0.0.js', [
"Accept-Encoding: gzip, deflate, br, zstd",
], [
'status' => '200',
'server' => 'nginx',
'content-type' => 'application/javascript; charset=utf-8',
'content-encoding' => 'gzip',
'last-modified' => 'Fri, 18 Oct 1991 12:00:00 GMT',
'vary' => 'Accept-Encoding',
'etag' => '"28feccc0-40464"',
'cache-control' => 'public, max-age=31536000, stale-while-revalidate=604800',
'access-control-allow-origin' => '*',
'cross-origin-resource-policy' => 'cross-origin',
] );
Unit::testHttp( $origin, '/qunit/qunit-2.0.0.css', [
"Accept-Encoding: gzip, deflate, br, zstd",
], [
'status' => '200',
'server' => 'nginx',
'content-type' => 'text/css',
'content-encoding' => 'gzip',
'last-modified' => 'Fri, 18 Oct 1991 12:00:00 GMT',
'vary' => 'Accept-Encoding',
'etag' => '"28feccc0-1d20"',
'cache-control' => 'public, max-age=31536000, stale-while-revalidate=604800',
'access-control-allow-origin' => '*',
'cross-origin-resource-policy' => 'cross-origin',
] );
// Renamed files
Unit::testHttp( $origin, '/jquery-git2.js', [], [
'status' => '301',
'server' => 'nginx',
'location' => 'https://code.jquery.com/jquery-git.js',
] );
// Moved to releases, WordPress page
Unit::testHttp( $origin, '/jquery/', [], [
'status' => '301',
'server' => 'nginx',
'location' => 'https://releases.jquery.com/jquery/',
] );
// Moved to releases, WordPress page without trailing slash
Unit::testHttp( $origin, '/jquery', [], [
'status' => '301',
'server' => 'nginx',
'location' => 'https://releases.jquery.com/jquery/',
] );
// Moved to releases, root -git file
Unit::testHttp( $origin, '/jquery-git.js', [], [
'status' => '301',
'server' => 'nginx',
'location' => 'https://releases.jquery.com/git/jquery-git.js',
] );
// Moved to releases, nested -git file
Unit::testHttp( $origin, '/color/jquery.color-git.min.js', [], [
'status' => '301',
'server' => 'nginx',
'location' => 'https://releases.jquery.com/git/color/jquery.color-git.min.js',
] );
Unit::testHttp( $origin, '/qunit/qunit-git.css', [], [
'status' => '301',
'server' => 'nginx',
'location' => 'https://releases.jquery.com/git/qunit/qunit-git.css',
] );
Unit::testHttp( $origin, '/mobile/git/jquery.mobile-git.min.map', [], [
'status' => '301',
'server' => 'nginx',
'location' => 'https://releases.jquery.com/git/mobile/git/jquery.mobile-git.min.map',
] );
// Moved to releases, any file under /mobile/git
Unit::testHttp( $origin, '/mobile/git/images/icons-png/power-black.png', [], [
'status' => '301',
'server' => 'nginx',
'location' => 'https://releases.jquery.com/git/mobile/git/images/icons-png/power-black.png',
] );
// Moved to releases, any file under /git (new-style URL)
Unit::testHttp( $origin, '/git/qunit/qunit-git.css', [], [
'status' => '301',
'server' => 'nginx',
'location' => 'https://releases.jquery.com/git/qunit/qunit-git.css',
] );
Unit::end();