Skip to content

Commit

Permalink
fixup: review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
addaleax committed Dec 2, 2021
1 parent 534fab0 commit a2722ab
Show file tree
Hide file tree
Showing 11 changed files with 200 additions and 7,631 deletions.
27 changes: 27 additions & 0 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,29 @@ functions:
bash ${PROJECT_DIRECTORY}/.evergreen/run-atlas-tests.sh
run socks5 tests:
- command: shell.exec
type: test
params:
silent: true
working_dir: src
script: |
${PREPARE_SHELL}
cat <<EOT > prepare_client_encryption.sh
export CLIENT_ENCRYPTION=${CLIENT_ENCRYPTION}
export CSFLE_KMS_PROVIDERS='${CSFLE_KMS_PROVIDERS}'
export AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}"
export AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}"
export CSFLE_GIT_REF="${CSFLE_GIT_REF}"
export CDRIVER_GIT_REF="${CDRIVER_GIT_REF}"
EOT
- command: shell.exec
type: test
params:
working_dir: src
script: >
${PREPARE_SHELL}
export PYTHON_BINARY=$([ "Windows_NT" = "$OS" ] && echo "/cygdrive/c/python/python38/python.exe" || echo
"/opt/mongodbtoolchain/v3/bin/python3")
Expand All @@ -313,6 +331,15 @@ functions:
export SSL="${SSL}"
# Disable xtrace (just in case it was accidentally set).
set +x
. ./prepare_client_encryption.sh
rm -f ./prepare_client_encryption.sh
bash ${PROJECT_DIRECTORY}/.evergreen/run-socks5-tests.sh
run kerberos tests:
- command: shell.exec
Expand Down
22 changes: 22 additions & 0 deletions .evergreen/config.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -327,18 +327,40 @@ functions:
bash ${PROJECT_DIRECTORY}/.evergreen/run-atlas-tests.sh

"run socks5 tests":
- command: shell.exec
type: test
params:
silent: true
working_dir: "src"
script: |
${PREPARE_SHELL}
cat <<EOT > prepare_client_encryption.sh
export CLIENT_ENCRYPTION=${CLIENT_ENCRYPTION}
export CSFLE_KMS_PROVIDERS='${CSFLE_KMS_PROVIDERS}'
export AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}"
export AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}"
export CSFLE_GIT_REF="${CSFLE_GIT_REF}"
export CDRIVER_GIT_REF="${CDRIVER_GIT_REF}"
EOT
- command: shell.exec
type: test
params:
working_dir: "src"
script: |
${PREPARE_SHELL}

export PYTHON_BINARY=$([ "Windows_NT" = "$OS" ] && echo "/cygdrive/c/python/python38/python.exe" || echo "/opt/mongodbtoolchain/v3/bin/python3")
export PROJECT_DIRECTORY="$(pwd)"
export DRIVERS_TOOLS="${DRIVERS_TOOLS}"
export NODE_LTS_NAME='${NODE_LTS_NAME}'
export MONGODB_URI="${MONGODB_URI}"
export SSL="${SSL}"

# Disable xtrace (just in case it was accidentally set).
set +x
. ./prepare_client_encryption.sh
rm -f ./prepare_client_encryption.sh

bash ${PROJECT_DIRECTORY}/.evergreen/run-socks5-tests.sh

"run kerberos tests":
Expand Down
2 changes: 2 additions & 0 deletions .evergreen/run-custom-csfle-tests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#! /usr/bin/env bash

set +o xtrace # Do not write AWS credentials to stderr

# Initiail checks for running these tests
if [ -z ${AWS_ACCESS_KEY_ID+omitted} ]; then echo "AWS_ACCESS_KEY_ID is unset" && exit 1; fi
if [ -z ${AWS_SECRET_ACCESS_KEY+omitted} ]; then echo "AWS_SECRET_ACCESS_KEY is unset" && exit 1; fi
Expand Down
8 changes: 6 additions & 2 deletions .evergreen/run-socks5-tests.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"

set -o errexit # Exit the script with error if any of the commands fail
set -o xtrace # For debuggability, no external credentials are used here

source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"

PYTHON_BINARY=${PYTHON_BINARY:-python3}

# ssl setup
Expand All @@ -30,12 +30,16 @@ fi
"$PYTHON_BINARY" "$SOCKS5_SERVER_SCRIPT" --port 1080 --auth username:p4ssw0rd --map "localhost:12345 to $FIRST_HOST" &
PID=$!
env SOCKS5_CONFIG='["localhost",1080,"username","p4ssw0rd"]' npm run check:socks5
env MONGODB_URI='mongodb://localhost:12345/?proxyHost=localhost&proxyUsername=username&proxyPassword=p4ssw0rd' \
bash "${PROJECT_DIRECTORY}/.evergreen/run-custom-csfle-tests.sh"
kill $PID

# Second, test with Socks5 + no authentication
"$PYTHON_BINARY" "$SOCKS5_SERVER_SCRIPT" --port 1081 --map "localhost:12345 to $FIRST_HOST" &
PID=$!
env SOCKS5_CONFIG='["localhost",1081]' npm run check:socks5
env MONGODB_URI='mongodb://localhost:12345/?proxyHost=localhost&proxyPort=1081' \
bash "${PROJECT_DIRECTORY}/.evergreen/run-custom-csfle-tests.sh"
kill $PID

# TODO: It might be worth using something more robust to control
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/socks5srv.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AddressRemapper:
"""A helper for remapping (host, port) tuples to new (host, port) tuples
This is useful for Socks5 servers used in testing environments,
because the succesful use of the Socks5 proxy can be demonstrated
because the successful use of the Socks5 proxy can be demonstrated
by being able to 'connect' to a redirected port, which would always
fail without the proxy, even on localhost-only environments
"""
Expand Down

0 comments on commit a2722ab

Please sign in to comment.