|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -o xtrace # Write all commands first to stderr |
| 4 | +set -o errexit # Exit the script with error if any of the commands fail |
| 5 | + |
| 6 | +# Supported/used environment variables: |
| 7 | +# MONGODB_URI Set the suggested connection MONGODB_URI (including credentials and topology info) |
| 8 | +# JAVA_VERSION Set the version of java to be used. Java versions can be set from the java toolchain /opt/java |
| 9 | +# AWS_ACCESS_KEY_ID The AWS access key identifier for client-side encryption |
| 10 | +# AWS_SECRET_ACCESS_KEY The AWS secret access key for client-side encryption |
| 11 | +# AWS_TEMP_ACCESS_KEY_ID The temporary AWS access key identifier for client-side encryption |
| 12 | +# AWS_TEMP_SECRET_ACCESS_KEY The temporary AWS secret access key for client-side encryption |
| 13 | +# AWS_TEMP_SESSION_TOKEN The temporary AWS session token for client-side encryption |
| 14 | +# AZURE_TENANT_ID The Azure tenant identifier for client-side encryption |
| 15 | +# AZURE_CLIENT_ID The Azure client identifier for client-side encryption |
| 16 | +# AZURE_CLIENT_SECRET The Azure client secret for client-side encryption |
| 17 | +# GCP_EMAIL The GCP email for client-side encryption |
| 18 | +# GCP_PRIVATE_KEY The GCP private key for client-side encryption |
| 19 | +# AZUREKMS_KEY_VAULT_ENDPOINT The Azure key vault endpoint for integration tests |
| 20 | +# AZUREKMS_KEY_NAME The Azure key name endpoint for integration tests |
| 21 | + |
| 22 | +MONGODB_URI=${MONGODB_URI:-} |
| 23 | + |
| 24 | +RELATIVE_DIR_PATH="$(dirname "${BASH_SOURCE:-$0}")" |
| 25 | +. "${RELATIVE_DIR_PATH}/javaConfig.bash" |
| 26 | + |
| 27 | +############################################ |
| 28 | +# Functions # |
| 29 | +############################################ |
| 30 | + |
| 31 | +provision_ssl () { |
| 32 | + # We generate the keystore and truststore on every run with the certs in the drivers-tools repo |
| 33 | + if [ ! -f client.pkc ]; then |
| 34 | + openssl pkcs12 -CAfile ${DRIVERS_TOOLS}/.evergreen/x509gen/ca.pem -export -in ${DRIVERS_TOOLS}/.evergreen/x509gen/client.pem -out client.pkc -password pass:bithere |
| 35 | + fi |
| 36 | + |
| 37 | + cp ${JAVA_HOME}/lib/security/cacerts mongo-truststore |
| 38 | + ${JAVA_HOME}/bin/keytool -importcert -trustcacerts -file ${DRIVERS_TOOLS}/.evergreen/x509gen/ca.pem -keystore mongo-truststore -storepass changeit -storetype JKS -noprompt |
| 39 | + |
| 40 | + # We add extra gradle arguments for SSL |
| 41 | + export GRADLE_EXTRA_VARS="-Pssl.enabled=true -Pssl.keyStoreType=pkcs12 -Pssl.keyStore=`pwd`/client.pkc -Pssl.keyStorePassword=bithere -Pssl.trustStoreType=jks -Pssl.trustStore=`pwd`/mongo-truststore -Pssl.trustStorePassword=changeit" |
| 42 | +} |
| 43 | + |
| 44 | +############################################ |
| 45 | +# Main Program # |
| 46 | +############################################ |
| 47 | + |
| 48 | +# Set up keystore/truststore regardless, as they are required for testing KMIP |
| 49 | +provision_ssl |
| 50 | + |
| 51 | +echo "Running tests with Java ${JAVA_VERSION}" |
| 52 | +./gradlew -version |
| 53 | + |
| 54 | +# By not specifying the path to the `crypt_shared` via the `org.mongodb.test.crypt.shared.lib.path` Java system property, |
| 55 | +# we force the driver to start `mongocryptd` instead of loading and using `crypt_shared`. |
| 56 | +./gradlew -PjavaVersion=${JAVA_VERSION} -Dorg.mongodb.test.uri=${MONGODB_URI} \ |
| 57 | + -Dorg.mongodb.test.fle.on.demand.credential.test.failure.enabled="true" \ |
| 58 | + -Dorg.mongodb.test.fle.on.demand.credential.test.azure.keyVaultEndpoint="${AZUREKMS_KEY_VAULT_ENDPOINT}" \ |
| 59 | + -Dorg.mongodb.test.fle.on.demand.credential.test.azure.keyName="${AZUREKMS_KEY_NAME}" \ |
| 60 | + -Dorg.mongodb.test.awsAccessKeyId=${AWS_ACCESS_KEY_ID} -Dorg.mongodb.test.awsSecretAccessKey=${AWS_SECRET_ACCESS_KEY} \ |
| 61 | + -Dorg.mongodb.test.tmpAwsAccessKeyId=${AWS_TEMP_ACCESS_KEY_ID} -Dorg.mongodb.test.tmpAwsSecretAccessKey=${AWS_TEMP_SECRET_ACCESS_KEY} -Dorg.mongodb.test.tmpAwsSessionToken=${AWS_TEMP_SESSION_TOKEN} \ |
| 62 | + -Dorg.mongodb.test.azureTenantId=${AZURE_TENANT_ID} -Dorg.mongodb.test.azureClientId=${AZURE_CLIENT_ID} -Dorg.mongodb.test.azureClientSecret=${AZURE_CLIENT_SECRET} \ |
| 63 | + -Dorg.mongodb.test.gcpEmail=${GCP_EMAIL} -Dorg.mongodb.test.gcpPrivateKey=${GCP_PRIVATE_KEY} \ |
| 64 | + ${GRADLE_EXTRA_VARS} \ |
| 65 | + --stacktrace --info --continue \ |
| 66 | + driver-legacy:test \ |
| 67 | + --tests com.mongodb.ClientSideEncryptionLegacyTest \ |
| 68 | + driver-sync:test \ |
| 69 | + --tests com.mongodb.client.ClientSideEncryptionTest \ |
| 70 | + --tests com.mongodb.client.unified.ClientSideEncryptionTest \ |
| 71 | + driver-reactive-streams:test \ |
| 72 | + --tests com.mongodb.reactivestreams.client.ClientSideEncryptionTest \ |
| 73 | + --tests com.mongodb.reactivestreams.client.unified.ClientSideEncryptionTest \ |
| 74 | + driver-scala:integrationTest \ |
| 75 | + --tests org.mongodb.scala.ClientSideEncryptionTest |
0 commit comments