File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,16 +15,21 @@ pushd $SCRIPT_DIR/.. > /dev/null
1515# shellcheck disable=SC2120
1616function connect_mongodb() {
1717 local use_tls=false
18+ local use_auth=false
1819
1920 # Parse flags
2021 while [[ $# -gt 0 ]]; do
2122 case " $1 " in
2223 --ssl) use_tls=true; shift ;;
24+ --auth) use_auth=true; shift ;;
2325 * ) echo " Unknown option: $1 " ; return 1 ;;
2426 esac
2527 done
2628
2729 URI=" mongodb://localhost:27017/?directConnection=true&serverSelectionTimeoutMS=10000"
30+ if [[ " $use_auth " == " true" ]]; then
31+ URI=" mongodb://bob:pwd123@localhost:27017/?directConnection=true&serverSelectionTimeoutMS=10000&authSource=admin"
32+ fi
2833 local TLS_OPTS=()
2934 if [[ " $use_tls " == " true" ]]; then
3035 TLS_OPTS+=(" --tls" " --tlsCertificateKeyFile" " ${DRIVERS_TOOLS} /.evergreen/x509gen/server.pem" )
@@ -49,6 +54,15 @@ connect_mongodb --ssl
4954bash ./run-mongodb.sh start --version latest --topology sharded_cluster --auth --ssl
5055connect_mongodb --ssl
5156
57+ # Verify that auth is enforced when starting with AUTH=auth SSL=yes.
58+ # An unauthenticated connection must be rejected, and an authenticated one must succeed.
59+ AUTH=auth SSL=yes bash ./run-mongodb.sh start
60+ if connect_mongodb --ssl 2> /dev/null; then
61+ echo " ERROR: unauthenticated connection should have been rejected on an auth+ssl server"
62+ exit 1
63+ fi
64+ connect_mongodb --ssl --auth
65+
5266# Ensure that we can use a downloaded mongodb directory.
5367DOWNLOAD_DIR=mongodl_test
5468rm -rf ${DOWNLOAD_DIR}
You can’t perform that action at this time.
0 commit comments