mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Move HTTPS test to a bash script
See https://github.com/simonw/datasette/issues/1955#issuecomment-1356627931
This commit is contained in:
parent
8b73fc6b47
commit
d1d369456a
3 changed files with 33 additions and 46 deletions
33
tests/test_datasette_https_server.sh
Executable file
33
tests/test_datasette_https_server.sh
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Generate certificates
|
||||
python -m trustme
|
||||
# This creates server.pem, server.key, client.pem
|
||||
|
||||
# Start the server in the background
|
||||
datasette --memory \
|
||||
--ssl-keyfile=server.key \
|
||||
--ssl-certfile=server.pem \
|
||||
-p 8152 &
|
||||
|
||||
# Store the background process ID in a variable
|
||||
server_pid=$!
|
||||
|
||||
# Wait for the server to start
|
||||
sleep 2
|
||||
|
||||
# Make a test request using curl
|
||||
curl -f --cacert client.pem 'https://localhost:8152/_memory.json'
|
||||
|
||||
# Save curl's exit code (-f option causes it to return one on HTTP errors)
|
||||
curl_exit_code=$?
|
||||
|
||||
# Shut down the server
|
||||
kill $server_pid
|
||||
sleep 1
|
||||
|
||||
# Clean up the certificates
|
||||
rm server.pem server.key client.pem
|
||||
|
||||
echo $curl_exit_code
|
||||
exit $curl_exit_code
|
||||
Loading…
Add table
Add a link
Reference in a new issue