From 2d27fcb990bd1f5787e4a2c2e34993469164f5b2 Mon Sep 17 00:00:00 2001 From: Bernie Hackett Date: Wed, 8 Mar 2017 16:32:35 -0800 Subject: [PATCH] PYTHON-1201 - Test GSSAPI and PLAIN authentication --- .evergreen/config.yml | 40 +++++++++++++++++++++++++ .evergreen/run-enterprise-auth-tests.sh | 33 ++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 .evergreen/run-enterprise-auth-tests.sh diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 781470ed3..ee75b5b5c 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -336,6 +336,16 @@ functions: ${PREPARE_SHELL} PYTHON_BINARY=${PYTHON_BINARY} GREEN_FRAMEWORK=${GREEN_FRAMEWORK} C_EXTENSIONS=${C_EXTENSIONS} AUTH=${AUTH} SSL=${SSL} MONGODB_URI="${MONGODB_URI}" sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh + "run enterprise auth tests": + - command: shell.exec + type: test + params: + silent: true + working_dir: "src" + script: | + # DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does) + PYTHON_BINARY=${PYTHON_BINARY} SASL_HOST=${sasl_host} SASL_PORT=${sasl_port} SASL_USER=${sasl_user} SASL_PASS=${sasl_pass} SASL_DB=${sasl_db} PRINCIPAL=${principal} GSSAPI_DB=${gssapi_db} KEYTAB_BASE64=${keytab_base64} PROJECT_DIRECTORY=${PROJECT_DIRECTORY} sh ${PROJECT_DIRECTORY}/.evergreen/run-enterprise-auth-tests.sh + "cleanup": - command: shell.exec params: @@ -603,6 +613,15 @@ tasks: TOPOLOGY: "sharded_cluster" - func: "run tests" + - name: "test-enterprise-auth" + tags: ["enterprise-auth"] + commands: + - func: "bootstrap mongo-orchestration" + vars: + VERSION: "latest" + TOPOLOGY: "server" + - func: "run enterprise auth tests" + # }}} @@ -1195,6 +1214,27 @@ buildvariants: add_tasks: - "test-3.0-standalone" +- matrix_name: "test-linux-enterprise-auth" + matrix_spec: {"python-version": "*", auth: "auth"} + display_name: "Enterprise Auth Linux ${python-version}" + run_on: ubuntu1604-test + tasks: + - name: "test-enterprise-auth" + +- matrix_name: "tests-windows-vs2010-enterprise-auth" + matrix_spec: {"windows-vs2010-python-version": "*", auth: "auth"} + display_name: "Enterprise Auth Windows ${windows-vs2010-python-version}" + run_on: windows-64-vs2010-test + tasks: + - name: "test-enterprise-auth" + +- matrix_name: "tests-windows-vs2015-enterprise-auth" + matrix_spec: {"windows-vs2015-python-version": "*", auth: "auth"} + display_name: "Enterprise Auth Windows ${windows-vs2015-python-version}" + run_on: windows-64-vs2015-test + tasks: + - name: "test-enterprise-auth" + # Platform notes # i386 builds of OpenSSL or Cyrus SASL are not available # Ubuntu14.04 only supports 2.6+ with SSL diff --git a/.evergreen/run-enterprise-auth-tests.sh b/.evergreen/run-enterprise-auth-tests.sh new file mode 100644 index 000000000..d92d6b59e --- /dev/null +++ b/.evergreen/run-enterprise-auth-tests.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Don't trace to avoid secrets showing up in the logs +set -o errexit + +echo "Running enterprise authentication tests" + +PLATFORM="$(${PYTHON_BINARY} -c 'import platform; print(platform.system())')" + +export DB_USER="bob" +export DB_PASSWORD="pwd123" + +# There is no kerberos package for Jython, but we do want to test PLAIN. +if [ ${PLATFORM} != "Java" ]; then + if [ "Windows_NT" = "$OS" ]; then + echo "Setting GSSAPI_PASS" + export GSSAPI_PASS=${SASL_PASS} + else + echo "Writing keytab" + echo ${KEYTAB_BASE64} | base64 -d > ${PROJECT_DIRECTORY}/.evergreen/drivers.keytab + echo "Running kinit" + kinit -k -t ${PROJECT_DIRECTORY}/.evergreen/drivers.keytab -p ${PRINCIPAL} + fi + echo "Setting GSSAPI variables" + export GSSAPI_HOST=${SASL_HOST} + export GSSAPI_PORT=${SASL_PORT} + export GSSAPI_PRINCIPAL=${PRINCIPAL} +fi + + +echo "Running tests" +${PYTHON_BINARY} setup.py clean +${PYTHON_BINARY} setup.py test --xunit-output=xunit-results