Skip to content

Commit 314286d

Browse files
committed
first commit
0 parents  commit 314286d

File tree

625 files changed

+113098
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

625 files changed

+113098
-0
lines changed

.editorconfig

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
root = true
2+
3+
# Unix-style newlines with a newline ending every file
4+
[*]
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
charset = utf-8
9+
trim_trailing_whitespace
10+
max_line_length = 100
11+
indent_size = 2
12+
13+
[*.py]
14+
indent_size = 4
15+
16+
[Makefile]
17+
indent_style = tab

LICENSE

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2018, Mark Nottingham
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
* Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
.PHONY: server
3+
server:
4+
node server.js
5+
6+
.PHONY: lint
7+
lint:
8+
standard --fix server.js client.js utils.js templates.js tests/*.js

README.md

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# CDN Tests
2+
3+
These tests cover HTTP-specified behaviours for CDNs, primarily from
4+
[RFC7234](http://httpwg.org/specs/rfc7234.html), but as seen through the lens of
5+
[Fetch](https://fetch.spec.whatwg.org/).
6+
7+
A few notes:
8+
9+
* By its nature, caching is optional; some tests expecting a response to be cached might fail
10+
because the client chose not to cache it, or chose to race the cache with a network request.
11+
12+
* Likewise, some tests might fail because there is a separate document-level cache that's
13+
ill-defined; see [this issue](https://github.com/whatwg/fetch/issues/354).
14+
15+
* Some browser caches will behave differently when reloading / shift-reloading, despite the `cache
16+
mode` staying the same.
17+
18+
* They only work reliably on Chrome for the time being; see [this bug](https://github.com/whatwg/fetch/issues/722).
19+
20+
## Running the Tests
21+
22+
First, start the server-side:
23+
24+
> node server.js
25+
26+
Then, configure your CDN to use port `8000` on that hostname as the origin. Point a browser (as above, currently Chrome) to the CDN.
27+
28+
29+
30+
## Test Format
31+
32+
Each test run gets its own URL, randomized content, and operates independently.
33+
34+
Tests are kept in JavaScript files in `tests/`, each file representing a suite.
35+
36+
A suite is an object with a `name` member and a `tests` member; e.g.,
37+
38+
```javascript
39+
export default {
40+
name: 'Example Tests',
41+
tests: [ ... ]
42+
}
43+
```
44+
45+
The `tests` member is an array of objects, with the following members:
46+
47+
- `name` - The name of the test.
48+
- `requests` - a list of request objects (see below).
49+
- `browser_only` - if `true`, will not run on non-browser caches.
50+
- `browser_skip` - if `true, will not run on browser caches.
51+
52+
Possible members of a request object:
53+
54+
- `template` - A template object for the request, by name -- see `templates.js`.
55+
- `request_method` - A string containing the HTTP method to be used.
56+
- `request_headers` - An array of `[header_name_string, header_value_string]` arrays to
57+
emit in the request.
58+
- `request_body` - A string to use as the request body.
59+
- `query_arg` - query arguments to add.
60+
- `filename` - filename to use.
61+
- `mode` - The mode string to pass to `fetch()`.
62+
- `credentials` - The credentials string to pass to `fetch()`.
63+
- `cache` - The cache string to pass to `fetch()`.
64+
- `pause_after` - Boolean controlling a 3-second pause after the request completes.
65+
- `response_status` - A `[number, string]` array containing the HTTP status code
66+
and phrase to return.
67+
- `response_headers` - An array of `[header_name_string, header_value_string]` arrays to
68+
emit in the response. These values will also be checked like
69+
expected_response_headers, unless there is a third value that is
70+
`false`.
71+
- `response_body` - String to send as the response body. If not set, it will contain
72+
the test identifier.
73+
- `expected_type` - One of `["cached", "not_cached", "lm_validate", "etag_validate", "error"]`
74+
- `expected_status` - A number representing a HTTP status code to check the response for.
75+
If not set, the value of `response_status[0]` will be used; if that
76+
is not set, 200 will be used.
77+
- `expected_request_headers` - An array of `[header_name_string, header_value_string]` representing
78+
headers to check the request for.
79+
- `expected_response_headers` - An array of `[header_name_string, header_value_string]` representing
80+
headers to check the response for. See also response_headers.
81+
- `expected_response_text` - A string to check the response body against.
82+
83+
`server.js` stashes an entry containing observed headers for each request it receives. When the
84+
test fetches have run, this state is retrieved and the expected_* lists are checked, including
85+
their length.
86+

0 commit comments

Comments
 (0)