diff options
| author | yum <yum.food.vr@gmail.com> | 2023-07-03 18:44:43 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2023-07-03 19:36:13 -0700 |
| commit | 76ae7c28ea6224b2c919122d5dc71bcc00a0ecaa (patch) | |
| tree | 9723fd02715d747cfc439d1f66d36821a56069e9 /BrowserSource/Proxy/integration_test.sh | |
| parent | 7888ccc96d001512dd3bdc01f299856e86c876f5 (diff) | |
Begin work on proxy server
Create a simple server with 3 endpoints:
* /create_session: Create a session and return its identifier.
* /set_transcript: Update a session's transcript.
* /get_transcript: Fetch a session's transcript.
Right now the session ID provides authentication *and* authorization.
There is no public/private ID so you have to trust whoever you share
your ID with.
IDs are long and generated by the server, so it should be somewhat
secure against low-effort hacking.
Other updates:
* Drop whisper_requirements.txt - no longer needed.
* Vendor curl to make it easier to interact with the server.
TODO:
* Fuzz test the server.
Diffstat (limited to 'BrowserSource/Proxy/integration_test.sh')
| -rw-r--r-- | BrowserSource/Proxy/integration_test.sh | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/BrowserSource/Proxy/integration_test.sh b/BrowserSource/Proxy/integration_test.sh new file mode 100644 index 0000000..5aabc9e --- /dev/null +++ b/BrowserSource/Proxy/integration_test.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +SERVER_IP="$1" +if [ -z "$SERVER_IP" ]; then + echo "Usage: $0 server_ip" + exit 1 +fi +echo "Testing server at $SERVER_IP" + +SESSION_ID_0=$(curl -s -X GET $SERVER_IP:8080/api/v0/create_session | awk -F':' '{print $2}' | tr -d '}') +echo "Got session id $SESSION_ID_0" +if [ -z "$SESSION_ID_0" ]; then + echo "Expected session ID to be non-empty" + exit 1 +fi + +echo "Initial transcript should be empty" +T0=$(curl -s -X GET -d "$SESSION_ID_0" $SERVER_IP:8080/api/v0/get_transcript) +if [ "$T0" != "" ]; then + echo "Expected initial transcript to be empty, but got $T0" + exit 1 +fi +echo "Pass!" + +echo "Should be able to update transcript once" +T1_EXP="foo bar" +curl -s -X POST -d "$SESSION_ID_0 $T1_EXP" $SERVER_IP:8080/api/v0/set_transcript + +T1=$(curl -s -X GET -d "$SESSION_ID_0" $SERVER_IP:8080/api/v0/get_transcript) +if [ "$T1" != "$T1_EXP" ]; then + echo "Expected transcript to be $T1_EXP, but got $T1" + exit 1 +fi +echo "Pass!" + +echo "Subsequent update should overwrite" +T2_EXP="baz qux" +curl -s -X POST -d "$SESSION_ID_0 $T2_EXP" $SERVER_IP:8080/api/v0/set_transcript + +T2=$(curl -s -X GET -d "$SESSION_ID_0" $SERVER_IP:8080/api/v0/get_transcript) +if [ "$T2" != "$T2_EXP" ]; then + echo "Expected transcript to be $T2_EXP, but got $T2" + exit 1 +fi +echo "Pass!" + |
