Test Server Configs is a collection of test scripts for server validation.
This repository contains unit tests suites helping validate correctness of a server. Some steps are required to make them ready to run.
Create a workflow .yml file in your repositories .github/workflows directory.
An example workflow is available below.
For more information, reference the GitHub Help Documentation for
Creating a workflow file.
Make sure to use the grafana/setup-k6-action action to install k6.
See action.yml. For more information on these inputs, see the API Documentation.
steps:
- uses: actions/checkout@v4
- uses: grafana/setup-k6-action@v1
- name: Test with server-configs-test
uses: h5bp/server-configs-test@main
with:
command: test
server: nginx
root-path: /var/www/server.localhost
certs-path: /etc/nginx/certs
configs-volumes: test/vhosts:/etc/nginx/conf.d;h5bp:/etc/nginx/h5bp;nginx.conf:/etc/nginx/nginx.conf;mime.types:/etc/nginx/mime.types
tests: basic-file-access;caching;cache-busting;custom-errors;forbidden-files;precompressed-files-gzip;rewrites;ssl
npm install
npm run build
server.localhostwww.server.localhostsecure.server.localhostwww.secure.server.localhostsecure. hosts, possibly with certs within certs/fixtures/ to be the root of files served by the serverTo run all tests, execute:
$ k6 run lib/index.js
To run only specific tests, use the environment variable TESTS with all wanted
test names separated by : as value.
The environment variable can be passed as an argument:
$ k6 run lib/index.js -e TESTS=basic-file-access:rewrites
basic-file-accessCheck if all common files are served correctly.
The requested file should be served exactly as expected, all HTTP headers should be valid.
cache-bustingCheck if cache-busting is working.
The requests that contain a hashed-key extension prefix ([name].[hash].[ext])
should serve the target file correctly.
concatenationCheck if concatenation is working.
The requests for [name].combined.[ext] should be served as a concatenation of
he a.[ext] and b.[ext] files.
custom-errorsCheck if errors are served as desired.
The erroneous requests should be served with the custom document provided.
enforce-gzipCheck if gzip is enable even if mangled headers.
forbidden-filesCheck if forbidden files are well handled.
The requests should be answered with 403 errors when:
.well-known directory;precompressed-files-(gzip|brotli)Check if server use gzip/brotli precompressed-files if available.
The requests should be served with a valid gzip/brotli file if a precompressed-files is available.
rewritesCheck redirection behavior.
The redirection should follow the following paths:
www. but require not to;www. but require to;sslCheck correctness for the TLS/SSL configuration.
The requests should be served with:
benchmarkBonus test file to run a load benchmark. This test is not included in the run-all script. A separate command is required to run it:
$ k6 run lib/benchmark.js
[
{
"name": "unit tests suite 1",
"domain": "http://server.localhost/ (optional)",
"default": { // optional default values
"requestHeaders": {
"Header-Name": "header to add to all the requests"
},
"responseHeaders": {
"Header-Name": "header and its value to test for all the requests"
},
"statusCode": 311, // status to validate for all the requests
},
"requests": [
"request1", // use only default values
{
"target": "request2",
"responseHeaders": {
"Header-Name": "custom header and its value to test for this request"
}
}
]
}
]
Anyone is welcome to contribute, however, if you decide to get involved, please take a moment to review the guidelines:
Test Server Configs is only possible thanks to all the awesome contributors!
The code is available under the MIT license.
JavaScript
97.7%
HTML
1.6%
Test Server Configs is a collection of test scripts for server validation.
This repository contains unit tests suites helping validate correctness of a server. Some steps are required to make them ready to run.
Create a workflow .yml file in your repositories .github/workflows directory.
An example workflow is available below.
For more information, reference the GitHub Help Documentation for
Creating a workflow file.
Make sure to use the grafana/setup-k6-action action to install k6.
See action.yml. For more information on these inputs, see the API Documentation.
steps:
- uses: actions/checkout@v4
- uses: grafana/setup-k6-action@v1
- name: Test with server-configs-test
uses: h5bp/server-configs-test@main
with:
command: test
server: nginx
root-path: /var/www/server.localhost
certs-path: /etc/nginx/certs
configs-volumes: test/vhosts:/etc/nginx/conf.d;h5bp:/etc/nginx/h5bp;nginx.conf:/etc/nginx/nginx.conf;mime.types:/etc/nginx/mime.types
tests: basic-file-access;caching;cache-busting;custom-errors;forbidden-files;precompressed-files-gzip;rewrites;ssl
npm install
npm run build
server.localhostwww.server.localhostsecure.server.localhostwww.secure.server.localhostsecure. hosts, possibly with certs within certs/fixtures/ to be the root of files served by the serverTo run all tests, execute:
$ k6 run lib/index.js
To run only specific tests, use the environment variable TESTS with all wanted
test names separated by : as value.
The environment variable can be passed as an argument:
$ k6 run lib/index.js -e TESTS=basic-file-access:rewrites
basic-file-accessCheck if all common files are served correctly.
The requested file should be served exactly as expected, all HTTP headers should be valid.
cache-bustingCheck if cache-busting is working.
The requests that contain a hashed-key extension prefix ([name].[hash].[ext])
should serve the target file correctly.
concatenationCheck if concatenation is working.
The requests for [name].combined.[ext] should be served as a concatenation of
he a.[ext] and b.[ext] files.
custom-errorsCheck if errors are served as desired.
The erroneous requests should be served with the custom document provided.
enforce-gzipCheck if gzip is enable even if mangled headers.
forbidden-filesCheck if forbidden files are well handled.
The requests should be answered with 403 errors when:
.well-known directory;precompressed-files-(gzip|brotli)Check if server use gzip/brotli precompressed-files if available.
The requests should be served with a valid gzip/brotli file if a precompressed-files is available.
rewritesCheck redirection behavior.
The redirection should follow the following paths:
www. but require not to;www. but require to;sslCheck correctness for the TLS/SSL configuration.
The requests should be served with:
benchmarkBonus test file to run a load benchmark. This test is not included in the run-all script. A separate command is required to run it:
$ k6 run lib/benchmark.js
[
{
"name": "unit tests suite 1",
"domain": "http://server.localhost/ (optional)",
"default": { // optional default values
"requestHeaders": {
"Header-Name": "header to add to all the requests"
},
"responseHeaders": {
"Header-Name": "header and its value to test for all the requests"
},
"statusCode": 311, // status to validate for all the requests
},
"requests": [
"request1", // use only default values
{
"target": "request2",
"responseHeaders": {
"Header-Name": "custom header and its value to test for this request"
}
}
]
}
]
Anyone is welcome to contribute, however, if you decide to get involved, please take a moment to review the guidelines:
Test Server Configs is only possible thanks to all the awesome contributors!
The code is available under the MIT license.
JavaScript
97.7%
HTML
1.6%