-
Notifications
You must be signed in to change notification settings - Fork 455
CDRIVER-4435 Add support for GCP service accounts in GCP KMS #1140
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
Merged
Merged
Changes from 27 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
e3a7cb1
CDRIVER-4435 WIP set up test for gcp and create new files
galon1 cc6edb9
CDRIVER-4435 get gcp token from localhost and set new error codes
galon1 06647fa
CDRIVER-4435 create gcp token and send data to libmongocrypt
galon1 d6df2e0
CDRIVER-44345 upgrade libmongocrypt dependency to 1.6.0
galon1 4324f86
CDRIVER-4435 document upgrade to libmongocrypt 1.6.0
galon1 29e7990
CDRIVER-4435 add expiration time for gcp token
galon1 5349799
CDRIVER-4435 removing caching GCP token
galon1 512fa40
CDRIVER-4435 add test file without install command for gce engine
galon1 840f75b
CDRIVER-4435 GCP KMS working on remote gcp engine
galon1 2fffad9
CDRIVER-4435 create test file for service-gcp
galon1 6bcbe1d
CDRIVER-4435 add tests to service-gcp
galon1 58dce8a
CDRIVER-4435 WIP integration testing config
galon1 a03bf31
CDRIVER-4435 remove whitespace and permission fix for integration test
galon1 a4fe866
CDRIVER-4435 add DRIVER_TOOLS variable to integration test
galon1 387ce2d
CDRIVER-4435 fix comment and regenerate evergreen config
galon1 bd53ffe
CDRIVER-4435 add fake mock server tests to gcp
galon1 0c2ae1a
CDRIVER-4435 add new error code and domain to documentation
galon1 2a24a03
CDRIVER-4435 Fix comments and update dependency to 1.6.0
galon1 a5b46d8
CDRIVER-4435 remove printline
galon1 cf5dbe0
CDRIVER-4435 remove whitespace and change paths
galon1 a6479f2
CDRIVER-4435 rename fake_azure server to general test server
galon1 65d4173
CDRIVER-4435 rename server file
galon1 5e0d199
CDRIVER-4435 correctly add pass paths and remove whitespace
galon1 f8f49f7
CDRIVER-4435 remove whitespace
galon1 e6b3c6e
CDRIVER-4435 combine identical error codes
galon1 ddd3a3c
CDRIVER-4435 fix errors documentation indent
galon1 61fc809
Merge branch 'master' of github.com:galon1/mongo-c-driver into CDRIVE…
galon1 8fefbee
CDRIVER-4435 Change GCP to debian 11 and revert spec changes
galon1 69e03fc
CDRIVER-4435 change evergreen config for GCP debian 11
galon1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env bash | ||
set -o errexit | ||
set -o pipefail | ||
set -o nounset | ||
|
||
# Working directory is expected to be mongo-c-driver repo. | ||
ROOT=$(pwd) | ||
INSTALL_DIR=$ROOT/install | ||
. .evergreen/find-cmake.sh | ||
echo "Installing libmongocrypt ... begin" | ||
git clone --depth=1 https://github.com/mongodb/libmongocrypt --branch 1.6.0 | ||
$CMAKE -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \ | ||
-DBUILD_TESTING=OFF \ | ||
"-H$ROOT/libmongocrypt" \ | ||
"-B$ROOT/libmongocrypt" | ||
$CMAKE --build "$ROOT/libmongocrypt" --target install | ||
echo "Installing libmongocrypt ... end" | ||
|
||
echo "Compile test-gcpkms ... begin" | ||
# Disable unnecessary dependencies. test-gcpkms is copied to a remote host for testing, which may not have all dependent libraries. | ||
$CMAKE \ | ||
-DENABLE_SASL=OFF \ | ||
-DENABLE_SNAPPY=OFF \ | ||
-DENABLE_ZSTD=OFF \ | ||
-DENABLE_ZLIB=OFF \ | ||
-DENABLE_ICU=OFF \ | ||
-DENABLE_SRV=OFF \ | ||
-DENABLE_CLIENT_SIDE_ENCRYPTION=ON \ | ||
-DCMAKE_PREFIX_PATH=$INSTALL_DIR \ | ||
. | ||
$CMAKE --build . --target test-gcpkms | ||
echo "Compile test-gcpkms ... end" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ BuildRequires: mongodb-server | |
BuildRequires: openssl | ||
%endif | ||
%if %{with libmongocrypt} | ||
BuildRequires: cmake(mongocrypt) >= 1.5.2 | ||
BuildRequires: cmake(mongocrypt) >= 1.6.0 | ||
%endif | ||
BuildRequires: perl-interpreter | ||
# From man pages | ||
|
@@ -236,6 +236,9 @@ exit $ret | |
|
||
|
||
%changelog | ||
* Wed Oct 26 2022 Gil Alon <[email protected]> - 1.23.1-2 | ||
- raise dependency to libmongocrypt 1.6.0 | ||
|
||
* Thu Oct 20 2022 Remi Collet <[email protected]> - 1.23.1-2 | ||
- update to 1.23.1 | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
#!/usr/bin/env python | ||
# | ||
#Copyright 2022 - present MongoDB, Inc. | ||
# | ||
#Licensed under the Apache License, Version 2.0(the "License"); | ||
#you may not use this file except in compliance with the License. | ||
#You may obtain a copy of the License at | ||
# | ||
#http: // www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
#Unless required by applicable law or agreed to in writing, software | ||
#distributed under the License is distributed on an "AS IS" BASIS, | ||
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
#See the License for the specific language governing permissions and | ||
#limitations under the License. | ||
|
||
from collections import OrderedDict as OD | ||
|
||
from evergreen_config_generator.functions import (shell_exec, func) | ||
from evergreen_config_generator.tasks import (NamedTask) | ||
from evergreen_config_generator.variants import (Variant) | ||
from evergreen_config_generator.taskgroups import (TaskGroup) | ||
|
||
def _create_tasks(): | ||
passtask = NamedTask (task_name="testgcpkms-task") | ||
|
||
passtask.commands = [ | ||
func("fetch source"), | ||
shell_exec (r''' | ||
echo "Building test-gcpkms ... begin" | ||
pushd mongoc | ||
./.evergreen/compile-test-gcpkms.sh | ||
popd | ||
echo "Building test-gcpkms ... end" | ||
echo "Copying files ... begin" | ||
export GCPKMS_GCLOUD=${GCPKMS_GCLOUD} | ||
export GCPKMS_PROJECT=${GCPKMS_PROJECT} | ||
export GCPKMS_ZONE=${GCPKMS_ZONE} | ||
export GCPKMS_INSTANCENAME=${GCPKMS_INSTANCENAME} | ||
DRIVERS_TOOLS=$(pwd)/drivers-evergreen-tools | ||
mkdir testgcpkms | ||
cp ./mongoc/src/libmongoc/test-gcpkms ./mongoc/install/lib/libmongocrypt.* testgcpkms | ||
tar czf testgcpkms.tgz testgcpkms/* | ||
GCPKMS_SRC="testgcpkms.tgz" GCPKMS_DST=$GCPKMS_INSTANCENAME: $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/copy-file.sh | ||
echo "Copying files ... end" | ||
echo "Untarring file ... begin" | ||
GCPKMS_CMD="tar xf testgcpkms.tgz" $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/run-command.sh | ||
echo "Untarring file ... end" | ||
''', test=False), | ||
shell_exec (r''' | ||
export GCPKMS_GCLOUD=${GCPKMS_GCLOUD} | ||
export GCPKMS_PROJECT=${GCPKMS_PROJECT} | ||
export GCPKMS_ZONE=${GCPKMS_ZONE} | ||
export GCPKMS_INSTANCENAME=${GCPKMS_INSTANCENAME} | ||
DRIVERS_TOOLS=$(pwd)/drivers-evergreen-tools | ||
GCPKMS_CMD="LD_LIBRARY_PATH=./testgcpkms MONGODB_URI='mongodb://localhost:27017' ./testgcpkms/test-gcpkms" $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/run-command.sh | ||
''')] | ||
|
||
failtask = NamedTask(task_name="testgcpkms-fail-task") | ||
failtask.commands = [ | ||
func("fetch source"), | ||
shell_exec (r''' | ||
pushd mongoc | ||
./.evergreen/compile-test-gcpkms.sh | ||
popd''', test=False), | ||
shell_exec (r''' | ||
export GCPKMS_GCLOUD=${GCPKMS_GCLOUD} | ||
export GCPKMS_PROJECT=${GCPKMS_PROJECT} | ||
export GCPKMS_ZONE=${GCPKMS_ZONE} | ||
export GCPKMS_INSTANCENAME=${GCPKMS_INSTANCENAME} | ||
LD_LIBRARY_PATH=$(pwd)/install MONGODB_URI='mongodb://localhost:27017' EXPECT_ERROR='Failed to connect to: metadata.google.internal' ./mongoc/src/libmongoc/test-gcpkms''')] | ||
|
||
return [passtask, failtask] | ||
|
||
def _create_variant(): | ||
return Variant( | ||
name="testgcpkms-variant", | ||
display_name="GCP KMS", | ||
# GCP Virtual Machine created is Debian 10. | ||
run_on="debian10-small", tasks=[ | ||
galon1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"testgcpkms_task_group", | ||
"testgcpkms-fail-task" | ||
], batchtime=20160) # Use a batchtime of 14 days as suggested by the CSFLE test README | ||
|
||
def _create_task_group(): | ||
task_group = TaskGroup(name="testgcpkms_task_group") | ||
task_group.setup_group_can_fail_task = True | ||
task_group.setup_group_timeout_secs = 1800 # 30 minutes | ||
task_group.setup_group = [ | ||
# Create and set up a GCE instance using driver tools script | ||
shell_exec(r''' | ||
git clone --depth=1 https://github.com/mongodb-labs/drivers-evergreen-tools.git | ||
DRIVERS_TOOLS=$(pwd)/drivers-evergreen-tools | ||
echo '${testgcpkms_key_file}' > /tmp/testgcpkms_key_file.json | ||
export GCPKMS_KEYFILE=/tmp/testgcpkms_key_file.json | ||
export GCPKMS_DRIVERS_TOOLS=$DRIVERS_TOOLS | ||
export GCPKMS_SERVICEACCOUNT="${testgcpkms_service_account}" | ||
$DRIVERS_TOOLS/.evergreen/csfle/gcpkms/create-and-setup-instance.sh''', test=False), | ||
|
||
# Load the GCPKMS_GCLOUD, GCPKMS_INSTANCE, GCPKMS_PROJECT, and GCPKMS_ZONE expansions. | ||
OD([('command', 'expansions.update'), | ||
('params', OD([ | ||
('file', 'testgcpkms-expansions.yml')]))])] | ||
|
||
task_group.teardown_group = [ | ||
shell_exec(r''' | ||
DRIVERS_TOOLS=$(pwd)/drivers-evergreen-tools | ||
export GCPKMS_GCLOUD=${GCPKMS_GCLOUD} | ||
export GCPKMS_PROJECT=${GCPKMS_PROJECT} | ||
export GCPKMS_ZONE=${GCPKMS_ZONE} | ||
export GCPKMS_INSTANCENAME=${GCPKMS_INSTANCENAME} | ||
$DRIVERS_TOOLS/.evergreen/csfle/gcpkms/delete-instance.sh''', test=False) | ||
] | ||
task_group.tasks= ["testgcpkms-task"] | ||
return task_group | ||
|
||
def testgcpkms_generate(all_tasks, all_variants, all_task_groups): | ||
all_tasks.extend(_create_tasks()) | ||
all_variants.append(_create_variant()) | ||
all_task_groups.append(_create_task_group()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.