Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GODRIVER-2963 Use more environment variables in Azure KMS test #1367

Merged
merged 6 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2228,7 +2228,7 @@ tasks:
export AZUREKMS_VMNAME=${AZUREKMS_VMNAME}
echo '${testazurekms_privatekey}' > /tmp/testazurekms.prikey
export AZUREKMS_PRIVATEKEYPATH=/tmp/testazurekms.prikey
AZUREKMS_CMD="LD_LIBRARY_PATH=./install/libmongocrypt/lib MONGODB_URI='mongodb://localhost:27017' PROVIDER='azure' ./testkms" $DRIVERS_TOOLS/.evergreen/csfle/azurekms/run-command.sh
AZUREKMS_CMD="LD_LIBRARY_PATH=./install/libmongocrypt/lib MONGODB_URI='mongodb://localhost:27017' PROVIDER='azure' AZUREKMS_KEY_NAME='${AZUREKMS_KEY_NAME}' AZUREKMS_KEY_VAULT_ENDPOINT='${AZUREKMS_KEY_VAULT_ENDPOINT}' ./testkms" $DRIVERS_TOOLS/.evergreen/csfle/azurekms/run-command.sh

- name: "testazurekms-fail-task"
# testazurekms-fail-task runs without environment variables.
Expand All @@ -2250,7 +2250,7 @@ tasks:
LD_LIBRARY_PATH=./install/libmongocrypt/lib \
MONGODB_URI='mongodb://localhost:27017' \
EXPECT_ERROR='unable to retrieve azure credentials' \
PROVIDER='azure' \
PROVIDER='azure' AZUREKMS_KEY_NAME='${AZUREKMS_KEY_NAME}' AZUREKMS_KEY_VAULT_ENDPOINT='${AZUREKMS_KEY_VAULT_ENDPOINT}' \
./testkms

- name: "test-fuzz"
Expand Down
20 changes: 18 additions & 2 deletions cmd/testkms/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ var datakeyopts = map[string]primitive.M{
"key": "arn:aws:kms:us-east-1:579766882180:key/89fcc2c4-08b0-4bd9-9f25-e30687b580d0",
},
"azure": bson.M{
"keyVaultEndpoint": "https://keyvault-drivers-2411.vault.azure.net/keys/",
"keyName": "KEY-NAME",
"keyVaultEndpoint": "",
"keyName": "",
},
"gcp": bson.M{
"projectId": "devprod-drivers",
Expand Down Expand Up @@ -53,6 +53,20 @@ func main() {
default:
ok = true
}
if provider == "azure" {
azureKmsKeyName := os.Getenv("AZUREKMS_KEY_NAME")
azureKmsKeyVaultEndpoint := os.Getenv("AZUREKMS_KEY_VAULT_ENDPOINT")
if azureKmsKeyName == "" {
fmt.Println("ERROR: Please set required AZUREKMS_KEY_NAME environment variable.")
ok = false
}
if azureKmsKeyVaultEndpoint == "" {
fmt.Println("ERROR: Please set required AZUREKMS_KEY_VAULT_ENDPOINT environment variable.")
ok = false
}
datakeyopts["azure"]["keyName"] = azureKmsKeyName
datakeyopts["azure"]["keyVaultEndpoint"] = azureKmsKeyVaultEndpoint
}
if !ok {
providers := make([]string, 0, len(datakeyopts))
for p := range datakeyopts {
Expand All @@ -63,6 +77,8 @@ func main() {
fmt.Println("- MONGODB_URI as a MongoDB URI. Example: 'mongodb://localhost:27017'")
fmt.Println("- EXPECT_ERROR as an optional expected error substring.")
fmt.Println("- PROVIDER as a KMS provider, which supports:", strings.Join(providers, ", "))
fmt.Println("- AZUREKMS_KEY_NAME as the Azure key name. Required if PROVIDER=azure.")
fmt.Println("- AZUREKMS_KEY_VAULT_ENDPOINT as the Azure key name. Required if PROVIDER=azure.")
os.Exit(1)
}

Expand Down
Loading