Skip to content

Commit 5bd2a86

Browse files
committed
Separate scripts.
1 parent 096d0d5 commit 5bd2a86

File tree

4 files changed

+70
-44
lines changed

4 files changed

+70
-44
lines changed

.github/workflows/test-build-publish.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ jobs:
3131
3232
e2e-tests:
3333
runs-on: ubuntu-latest
34+
env:
35+
MITM_BASIC_AUTH_CONTAINER_NAME: e2e_test_mitm_basic_auth
36+
MITM_CUSTOM_CERT_CONTAINER_NAME: e2e_test_mitm_custom_cert
37+
DOCKER_NETWORK_NAME: e2e_test_docker_network
38+
TEST_USER: integrations_testing
39+
TEST_KEY: ${{ secrets.TEST_KEY }}
3440

3541
steps:
3642
- name: Checkout code
@@ -42,12 +48,17 @@ jobs:
4248
pip install -e .
4349
pip install -r ./requirements/development.txt
4450
51+
- name: Setup E2E environment
52+
run: |
53+
sh ./tests/e2e/scripts/setup_e2e.sh
54+
4555
- name: Run E2E tests
46-
env:
47-
TEST_USER: integrations_testing
48-
TEST_KEY: ${{ secrets.TEST_KEY }}
4956
run: |
50-
sh ./tests/e2e/scripts/test_e2e_runner.sh
57+
python -m pytest -s --capture=sys -v --cov=domaintools tests/e2e
58+
59+
- name: Cleanup E2E environment
60+
run: |
61+
sh ./tests/e2e/scripts/cleanup_e2e.sh
5162
5263
# run only in main and in pull request to `main` and in publish release
5364
release-build:

tests/e2e/scripts/cleanup_e2e.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
# Script Requirements
4+
# docker
5+
6+
# Clean up containers
7+
echo "Bringing down containers..."
8+
docker stop ${MITM_BASIC_AUTH_CONTAINER_NAME} || true
9+
docker stop ${MITM_CUSTOM_CERT_CONTAINER_NAME} || true
10+
docker network rm ${DOCKER_NETWORK_NAME} || true
11+
12+
# Clean up custom certs
13+
echo "Removing custom certs..."
14+
sudo rm -rf tests/e2e/mitmproxy-ca.pem
15+
sudo rm -rf ~/.test_mitmproxy

tests/e2e/scripts/setup_e2e.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
# Script Requirements
4+
# docker
5+
6+
echo "Create a bridge network for the containers to communicate"
7+
docker network create ${DOCKER_NETWORK_NAME}
8+
9+
echo "Spinning ${MITM_BASIC_AUTH_CONTAINER_NAME}"
10+
docker run --rm -d \
11+
--name ${MITM_BASIC_AUTH_CONTAINER_NAME} \
12+
--network ${DOCKER_NETWORK_NAME} \
13+
-p 8080:8080 mitmproxy/mitmproxy mitmdump \
14+
--set proxyauth="username:pass"
15+
16+
echo "Spinning ${MITM_CUSTOM_CERT_CONTAINER_NAME}"
17+
docker run --rm -d -v ~/.test_mitmproxy:/home/mitmproxy/.mitmproxy \
18+
--name ${MITM_CUSTOM_CERT_CONTAINER_NAME} \
19+
--network ${DOCKER_NETWORK_NAME} \
20+
-p 8090:8090 mitmproxy/mitmproxy mitmdump \
21+
--set listen_port=8090
22+
23+
# Check until custom cert from mitmproxy container is copied locally
24+
echo "Checking for valid custom cert..."
25+
while [ ! -f ~/.test_mitmproxy/mitmproxy-ca.pem ] ;
26+
do
27+
sleep 2
28+
done
29+
echo "Valid custom cert found!"
30+
31+
# Copy valid custom cert to target dir
32+
cp ~/.test_mitmproxy/mitmproxy-ca.pem tests/e2e/mitmproxy-ca.pem
33+
34+
pip install -e .
35+
pip install -r ./requirements/development.txt

tests/e2e/scripts/test_e2e_runner.sh

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,15 @@
33
# Script Requirements
44
# docker
55

6-
MITM_BASIC_AUTH_CONTAINER_NAME="e2e_test_mitm_basic_auth"
7-
MITM_CUSTOM_CERT_CONTAINER_NAME="e2e_test_mitm_custom_cert"
8-
DOCKER_NETWORK_NAME="e2e_test_docker_network"
6+
export MITM_BASIC_AUTH_CONTAINER_NAME="e2e_test_mitm_basic_auth"
7+
export MITM_CUSTOM_CERT_CONTAINER_NAME="e2e_test_mitm_custom_cert"
8+
export DOCKER_NETWORK_NAME="e2e_test_docker_network"
99

1010
echo "Starting e2e tests..."
1111

12-
echo "Create a bridge network for the containers to communicate"
13-
docker network create ${DOCKER_NETWORK_NAME}
14-
15-
echo "Spinning ${MITM_BASIC_AUTH_CONTAINER_NAME}"
16-
docker run --rm -d \
17-
--name ${MITM_BASIC_AUTH_CONTAINER_NAME} \
18-
--network ${DOCKER_NETWORK_NAME} \
19-
-p 8080:8080 mitmproxy/mitmproxy mitmdump \
20-
--set proxyauth="username:pass"
21-
22-
echo "Spinning ${MITM_CUSTOM_CERT_CONTAINER_NAME}"
23-
docker run --rm -d -v ~/.test_mitmproxy:/home/mitmproxy/.mitmproxy \
24-
--name ${MITM_CUSTOM_CERT_CONTAINER_NAME} \
25-
--network ${DOCKER_NETWORK_NAME} \
26-
-p 8090:8090 mitmproxy/mitmproxy mitmdump \
27-
--set listen_port=8090
28-
29-
# Check until custom cert from mitmproxy container is copied locally
30-
echo "Checking for valid custom cert..."
31-
while [ ! -f ~/.test_mitmproxy/mitmproxy-ca.pem ] ;
32-
do
33-
sleep 2
34-
done
35-
echo "Valid custom cert found!"
36-
37-
# Copy valid custom cert to target dir
38-
sudo cp ~/.test_mitmproxy/mitmproxy-ca.pem tests/e2e/mitmproxy-ca.pem
12+
sh ./tests/e2e/scripts/setup_e2e.sh
3913

4014
echo "E2E processing..."
4115
python -m pytest -s --capture=sys -v --cov=domaintools tests/e2e
4216

43-
# Clean up containers
44-
echo "Bringing down containers..."
45-
docker stop ${MITM_BASIC_AUTH_CONTAINER_NAME} || true
46-
docker stop ${MITM_CUSTOM_CERT_CONTAINER_NAME} || true
47-
docker network rm ${DOCKER_NETWORK_NAME} || true
48-
49-
# Clean up custom certs
50-
echo "Removing custom certs..."
51-
sudo rm -rf tests/e2e/mitmproxy-ca.pem
52-
sudo rm -rf ~/.test_mitmproxy
17+
sh ./tests/e2e/scripts/cleanup_e2e.sh

0 commit comments

Comments
 (0)