diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b356ab2..3ec5bc6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,10 +10,24 @@ env: CARGO_TERM_COLOR: always jobs: - test: + unit-test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: unit tests + - name: Run unit tests run: cargo test --verbose + + integration-test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + run: | + python -m pip install -r tests/requirements-freeze.txt + cargo build + - name: Run integration tests + run: | + (./target/debug/vmessy --config config/config.toml && sleep 2) & + VMESSY_HOST='127.0.0.1' python3 -m pytest tests diff --git a/.gitignore b/.gitignore index ea8c4bf..a4a44d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +**/__pycache__ diff --git a/tests/requirements-freeze.txt b/tests/requirements-freeze.txt new file mode 100644 index 0000000..85b7b17 --- /dev/null +++ b/tests/requirements-freeze.txt @@ -0,0 +1,2 @@ +pytest==8.1.1 +requests==2.31.0 diff --git a/tests/test_integration.py b/tests/test_integration.py new file mode 100644 index 0000000..507d33f --- /dev/null +++ b/tests/test_integration.py @@ -0,0 +1,16 @@ +import requests +import os + +VMESSY_HOST = os.environ.get("VMESSY_HOST", "localhost") +VMESSY_PORT = 1090 + +def test_basic_response(): + response = requests.get('http://google.com', allow_redirects=False, proxies={ + 'http': f'http://{VMESSY_HOST}:{VMESSY_PORT}', + }).text + + expected = ('\n' + '301 Moved\n

301 Moved

\nThe document has moved\n' + 'here.\r\n\r\n') + assert response == expected +