Skip to content

Commit

Permalink
Test key deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
fortuna committed Oct 26, 2018
1 parent cd4e513 commit 4ea0152
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/shadowbox/integration_test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ function remove_color() {
# Create new shadowbox user.
# TODO(bemasc): Verify that the server is using the right certificate
declare -r NEW_USER_JSON=$(client_curl --insecure -X POST https://shadowbox/${SB_API_PREFIX}/access-keys)
[[ ${NEW_USER_JSON} == '{"id":'* ]] || fail "Fail to create user"
[[ ${NEW_USER_JSON} == '{"id":"0"'* ]] || fail "Fail to create user"
declare -r SS_USER_ARGUMENTS=$(ss_arguments_for_user $NEW_USER_JSON)

# Verify that we handle deletions well
client_curl --insecure -X POST https://shadowbox/${SB_API_PREFIX}/access-keys > /dev/null
client_curl --insecure -X DELETE https://shadowbox/${SB_API_PREFIX}/access-keys/2 > /dev/null
client_curl --insecure -X DELETE https://shadowbox/${SB_API_PREFIX}/access-keys/1 > /dev/null

# Start Shadowsocks client and wait for it to be ready
declare -r LOCAL_SOCKS_PORT=5555
Expand All @@ -136,6 +136,12 @@ function remove_color() {
client_curl -x socks5h://localhost:$LOCAL_SOCKS_PORT http://target > $OUTPUT_DIR/actual.html
diff $OUTPUT_DIR/actual.html target/index.html || fail "Target page by hostname does not match"

# Verify we can't access the page anymore after the key is deleted
client_curl --insecure -X DELETE https://shadowbox/${SB_API_PREFIX}/access-keys/0 > /dev/null
# Exit code 56 is "Connection reset by peer".
client_curl -x socks5h://localhost:$LOCAL_SOCKS_PORT --connect-timeout 1 http://target &> /dev/null \
&& fail "Deleted access key is still active" || (($? == 56))

# Verify no errors occurred
docker logs $SHADOWBOX_CONTAINER &> $OUTPUT_DIR/logs.txt
if cat $OUTPUT_DIR/logs.txt | remove_color | grep --quiet -E "^E|level=error|ERROR:"; then
Expand Down

0 comments on commit 4ea0152

Please sign in to comment.