Skip to content

TEST!

TEST! #18

Workflow file for this run

name: Run HTTP Server Tests
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'
- name: Start HTTP Server
run: |
python server.py --directory ./store/ &
shell: bash
- name: Wait for server to start
run: |
sleep 5
- name: GET /
run: |
response=$(curl -si http://localhost:4221/ --output response.raw)
printf "HTTP/1.1 200 OK\r\n\r\n" > expected.raw
if ! diff response.raw expected.raw; then
echo "Test failed!"
exit 1
fi
- name: GET non-existent
run: |
response=$(curl --output response.raw -si http://localhost:4221/non-existent)
printf "HTTP/1.1 404 Not Found\r\n\r\n" > expected.raw
if ! diff response.raw expected.raw; then
echo "Test failed!"
exit 1
fi
- name: ECHO strawberry
run: |
response=$(curl --output response.raw -si http://localhost:4221/echo/strawberry)
printf "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 10\r\n\r\nstrawberry" > expected.raw
if ! diff response.raw expected.raw; then
echo "Test failed!"
exit 1
fi
- name: GET user-agent
run: |
response=$(curl --output response.raw -si http://localhost:4221/user-agent -H "User-Agent: apple/mango-mango")
printf "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 17\r\n\r\napple/mango-mango" > expected.raw
if ! diff response.raw expected.raw; then
echo "Test failed!"
exit 1
fi
- name: POST file
run: |
curl -si -X POST http://localhost:4221/files/pineapple_grape_grape_pineapple \
-H "Content-Length: 69" \
-H "Content-Type: application/octet-stream" \
-d 'blueberry blueberry orange mango raspberry blueberry banana blueberry' \
--output response.raw
printf "HTTP/1.1 201 Created\r\n\r\n" > expected.raw
if ! diff response.raw expected.raw; then
echo "Test failed!"
exit 1
fi
- name: case insensitivity test
run: |
curl -si -X POST http://localhost:4221/files/pineapple_grape_grape_pineapple \
-H "ConteNt-LEngth:69" \
-H "Content-type :application/octet-stream" \
-d 'blueberry blueberry orange mango raspberry blueberry banana blueberry' \
--output response.raw
printf "HTTP/1.1 201 Created\r\n\r\n" > expected.raw
if ! diff response.raw expected.raw; then
echo "Test failed!"
exit 1
fi
- name: gzip test 1/2
run: |
curl --output response0.raw -si -H "Accept-Encoding: gzip" http://localhost:4221/echo/abc
head -n 5 response0.raw > response.raw
printf "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 23\r\nContent-Encoding: gzip\r\n\r\n" > expected.raw
if ! diff response.raw expected.raw; then
echo "Test failed!"
fi
- name: gzip test 2/2
run: |
curl --raw --output response0.raw -H "Accept-Encoding: gzip" http://localhost:4221/echo/abc
xxd response0.raw > response.raw
printf "00000000: 1f8b 0800 e92c 7a66 02ff 4b4c 4a06 00c2 .....,zf..KLJ...\n00000010: 4124 3503 0000 00 A$5....\n" > expected.raw
if ! diff response.raw expected.raw; then
echo "Test failed!"
exit 1
fi
- name: Compression not known
run: |
response=$(curl --output response.raw -si -H "Accept-Encoding: this-isnt-real-lol" http://localhost:4221/echo/abc)
printf "HTTP/1.1 406 Not Acceptable\r\nContent-Type: text/plain\r\n\r\n" > expected.raw
if ! diff response.raw expected.raw; then
echo "Test failed!"
exit 1
fi
- name: HEAD a file
run: |
response=$(curl --output response.raw -si -X HEAD http://localhost:4221/files/pineapple_grape_grape_pineapple)
printf "HTTP/1.1 200 OK\r\nContent-Type: application/octet-stream\r\nContent-Length: 69\r\n\r\n" > expected.raw
if ! diff response.raw expected.raw; then
echo "Test failed!"
exit 1
fi
- name: Test concurrent connections
run: |
seq 1 10 | xargs -n1 -P10 curl -s -o /dev/null -w "%{http_code} %{time_total}\n" http://localhost:4221/