Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use mkcert to set up trusted development certificates #1168

Merged
merged 7 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ jobs:
docker images
docker inspect --format='{{json .Config.Labels}}' ${{ env.DOCKER_TAG }} | jq

- name: Run tests inside the Docker container
- name: Run phantomas CLI script inside the container
run: |
./test/server-start.sh

docker run \
--network=host \
--security-opt seccomp=$(pwd)/chrome-seccomp.json \
${{ env.DOCKER_TAG }} npm t
${{ env.DOCKER_TAG }} ./bin/phantomas.js http://127.0.0.1:8888/ --pretty
22 changes: 19 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Install mkcert and generate trusted development certificates
run: |
sudo apt update -y && sudo apt install -y libnss3-tools
curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64"
chmod +x mkcert-v*-linux-amd64
sudo cp mkcert-v*-linux-amd64 /usr/local/bin/mkcert

mkcert -version

# https://github.com/FiloSottile/mkcert/issues/219
mkdir -p $HOME/.pki/nssdb
certutil -d sql:$HOME/.pki/nssdb -N --empty-password
mkcert -install

./test/ssl-certificate/generate.sh

- name: Start the test server
run: ./test/server-start.sh

- name: Run example script
env:
DEBUG: "phantomas:browser"
Expand All @@ -37,9 +56,6 @@ jobs:
- name: Run tests
run: |
set -o pipefail

./test/server-start.sh

npm test 2>&1 | tee /tmp/npm-test.log

- name: Code coverage to be improved
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
"global": {
"statements": 89,
"branches": 85,
"functions": 90,
"lines": 90
"functions": 89,
"lines": 89
}
}
}
Expand Down
18 changes: 10 additions & 8 deletions test/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
phantomas tests
===============

## Initial set up

We use [`mkcert`](https://github.com/FiloSottile/mkcert) for setting up trusted development certificates to be used when testing locally.

1. Follow [the instruction steps](https://github.com/FiloSottile/mkcert#installation).
2. Run `mkcert -install`
3. Run `./test/ssl-certificate/generate.sh`

## Run the tests

Start the testing server:

```
Expand All @@ -12,11 +22,3 @@ And then run the test suite:
```
phantomas$ npm test
```

### Travis CI

```
$ which google-chrome-stable && google-chrome-stable --version
/usr/bin/google-chrome-stable
Google Chrome 71.0.3578.98
```
6 changes: 0 additions & 6 deletions test/integration-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,6 @@
# http/1.1 (legacy one)
- url: "https://127.0.0.1:8889"
label: "localhost with http/1.1 and TLS 1.2"
options:
ignore-ssl-errors: true
metrics:
mainDomainHttpProtocol: "http/1.1"
oldHttpProtocol: 1
Expand All @@ -853,8 +851,6 @@
# http/2
- url: "https://127.0.0.1:9000"
label: "localhost h2 version"
options:
ignore-ssl-errors: true
metrics:
mainDomainHttpProtocol: "h2"
oldHttpProtocol: 0
Expand All @@ -866,8 +862,6 @@
- url: "https://gf.dev/http3-test"
label: "h3"
flaky: Reaches the timeout of 5000 ms
options:
ignore-ssl-errors: true
metrics:
mainDomainHttpProtocol: "h3"
mainDomainTlsProtocol: "QUIC"
Expand Down
5 changes: 4 additions & 1 deletion test/ssl-certificate/generate.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/bin/sh
# https://github.com/FiloSottile/mkcert#installation
mkcert -cert-file localhost.crt -key-file localhost.key localhost 127.0.0.1 0.0.0.0 ::1
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"

echo "Using $SCRIPTPATH directory ..."

mkcert -cert-file ${SCRIPTPATH}/localhost.crt -key-file ${SCRIPTPATH}/localhost.key localhost 127.0.0.1 0.0.0.0 ::1
28 changes: 28 additions & 0 deletions test/ssl-certificatelocalhost.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCkMrSe8FBeoPky
Qs/367iYrzThU8lg0HTh2I9amUY4FQSxOf71J2R52D6sgy7xlugBLcZT+xnrTSFt
3dH508Tvi62sNrMWqNcCOlchzleI+yF/reW7fiDaG1+NcklQUC6U2FsVCYgcpFCy
RM8owylk4YyCTP1LxjKmCNk/o52SBJyo5yfM2Y/SYyfokuL0bpXh39//27pvA6fV
hWaRlAqnVxapE+debSieySSjjsn95pr0Oh2vT9Qb57h+BaLTPYlr0yq34iKBhEPs
+rbyegaZU/wJV/K2S8tHkRXt2xnLdv/zbfPZp5k/b+ULHpOt3S/+W8kwsTNxLop7
x9SVviKPAgMBAAECggEATR/gBRO9vGUCB+CoDLx0zYrmXLxdR5NCg16UHysFd4wv
0wr5va8OG8k9zwwjPajzOrKEiKfWSdbFz/Q0D5Ov2hCSt+RNhGQz8cDzclaYeSf0
WSOWV9XrmmbnH+pBk27GInXpel0qyMFJgiKd53ib9d2XgRCmnTPwUFqxqJmyhoXR
NeE3tDYqKsaso/PSb3x5l7sGcHQBTX/Oeu6rlCBT6LtHnKiO0/cPSUY6Uh1SIfsd
xG1pL7/nddC2R5nOWHF6w2xOA7h86B8CbNTeJghBpr5+vNiQ4UkaF5V++hUzHksM
uU8zdIPf/JQ2EHIH3pOVMrmIAYUQHc02Ud0KtZOJoQKBgQDXV0FOa0vtEt2+A0fb
z6DklFrUS+xBYS+U3nYTqW1j6zlq82wgg92q9id4kNIqKbFQzVCDGyVG/InBEYL9
ElZ5OdkILrpw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