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

feat(NODE-3777): add csfle kmip support #3070

Merged
merged 73 commits into from Feb 9, 2022
Merged

feat(NODE-3777): add csfle kmip support #3070

merged 73 commits into from Feb 9, 2022

Conversation

durran
Copy link
Member

@durran durran commented Dec 7, 2021

Description

Adds KMIP support to client side encryption. Includes NODE-3967 (remove example.com usages)

What is changing?

  • Adds the updated spec tests and allows KMIP to be used as a KMS provider.
  • Properly passes through TLS options per KMS provider.
Is there new documentation needed for these changes?

None

What is the motivation for this change?

NODE-3777

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: <type>(NODE-xxxx)<!>: <description>
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

https://spruce.mongodb.com/version/6203b999a4cf4724f9db3342/tasks?sorts=STATUS%3AASC%3BBASE_STATUS%3ADESC

@durran
Copy link
Member Author

durran commented Jan 19, 2022

CSFLE tests on the main run fail due to the main suite of tests pointing at mongodb-client-encryption@2.0.0-beta.2 but we need a beta.3 released for those to pass. The https://spruce.mongodb.com/version/61e753873066153369a025de/tasks?sorts=STATUS%3AASC%3BBASE_STATUS%3ADESC patch which points at my PR on mongodb/libmongocrypt#235 for just the CSFLE tests shows they will pass when this happens.

.evergreen/run-tests.sh Outdated Show resolved Hide resolved
@durran durran added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Jan 25, 2022
@durran durran force-pushed the NODE-3777 branch 3 times, most recently from 95bc5c9 to 3965ae3 Compare February 1, 2022 12:54
@baileympearson baileympearson added Team Review Needs review from team and removed Primary Review In Review with primary reviewer, not yet ready for team's eyes labels Feb 1, 2022
@durran durran force-pushed the NODE-3777 branch 3 times, most recently from 90a1b26 to d348e10 Compare February 3, 2022 16:45
test/manual/kerberos.test.js Outdated Show resolved Hide resolved
Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've got some test clean up needed here, unfotunately it's a little manual becuase chai can't take async functions inside expect(x).to.throw

.evergreen/config.yml.in Outdated Show resolved Hide resolved
.evergreen/config.yml.in Outdated Show resolved Hide resolved
.evergreen/config.yml.in Show resolved Hide resolved
}
}
// TODO: NODE-3927 - these cannot run in lb mode but are not skipping based on metadata.
if (!process.env.LOAD_BALANCER) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting that the metadata is not working, could we try skipping inside a beforeEach hook if possible? Currently we have a consistent test count across all runs, it would be nice to keep that for LB too.

It appears we currently don't run FLE against lb because we don't have the CSFLE_KMS_PROVIDERS var defined in that environment, I don't see anything in the evergreen changes that would've brought it in, what made this crop up?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated to skip in the before/beforeEach blocks now and removed this conditional.

The CSFLE_KMS_PROVIDERS variable is not in the env, but the metadata isn't skipping for some reason and the test attempts to JSON.parse that env variable anyways causing a parse error on the string 'NOT_PROVIDED'. So I tried to change that string to be empty just to get around it but the before hooks are still running. I suspect there's some funkiness with mocha and async functions but I haven't been able to confirm what the exact issue yet is, and didn't want to rewrite all the tests without async await since it made it way easier to read. But I can do that if we want.

@durran
Copy link
Member Author

durran commented Feb 9, 2022

I moved the CSFLE tests into manual so now they don't attempt to run with all the other variants so I could remove the skip hook hacks (they also expect to run no auth). I felt this was an appropriate special case and we already have the precedent for this and spec tests with socks5 (and soon kerberos prose spec tests). When moving them I also added the custom dependency variant to run on patches so they will run when opening pull requests now.

baileympearson
baileympearson previously approved these changes Feb 9, 2022
Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should investigate further why the metadata skip isn't working for us rather than moving csfle to manual, unlike socks5 we were testing against the package published on npm while the custom version variant pulls from master of libmongocrypt, I think its important for us to keep the full integration test with what users have available.

You mentioned the before hooks were still running in LB (and probably now auth variants), sorry I did not recall earlier but this is a known limitation. And you can see how I already had to work around it for some of our FLE tests here

@durran
Copy link
Member Author

durran commented Feb 9, 2022

We should investigate further why the metadata skip isn't working for us rather than moving csfle to manual, unlike socks5 we were testing against the package published on npm while the custom version variant pulls from master of libmongocrypt, I think its important for us to keep the full integration test with what users have available.

You mentioned the before hooks were still running in LB (and probably now auth variants), sorry I did not recall earlier but this is a known limitation. And you can see how I already had to work around it for some of our FLE tests here

Yeah I also ran across this as well: mochajs/mocha#2456

I can rewrite all those new tests in the other way or should I just make a ticket to come back to them as moving them to manual circumvents the issue?

@dariakp
Copy link
Contributor

dariakp commented Feb 9, 2022

We should investigate further why the metadata skip isn't working for us rather than moving csfle to manual, unlike socks5 we were testing against the package published on npm while the custom version variant pulls from master of libmongocrypt, I think its important for us to keep the full integration test with what users have available.
You mentioned the before hooks were still running in LB (and probably now auth variants), sorry I did not recall earlier but this is a known limitation. And you can see how I already had to work around it for some of our FLE tests here

Yeah I also ran across this as well: mochajs/mocha#2456

I can rewrite all those new tests in the other way or should I just make a ticket to come back to them as moving them to manual circumvents the issue?

I think it would be better not to move them to manual if we don't have to, because like Neal mentioned, it is potentially losing us some coverage and increasing work that we'll have to do to revamp the manual suite. So if we can avoid introducing that tech debt now, that's better than relying on eventually getting it fixed.

@durran
Copy link
Member Author

durran commented Feb 9, 2022

I have moved the csfle tests back to integration and refactored the tests to do all the client related activity in the it blocks and not in the before/after. Everything is passing now and no metadata issues on the main test runs and no explicit skips.

const dataDbName = 'db';
const dataCollName = 'coll';
const dataNamespace = `${dataDbName}.${dataCollName}`;
const keyVaultDbName = 'keyvault';
const keyVaultCollName = 'datakeys';
const keyVaultNamespace = `${keyVaultDbName}.${keyVaultCollName}`;

const shared = require('../shared');
const shared = require('../../integration/shared');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would ../shared work here?

# Get access to the AWS temporary credentials:
echo "adding temporary AWS credentials to environment"
# CSFLE_AWS_TEMP_ACCESS_KEY_ID, CSFLE_AWS_TEMP_SECRET_ACCESS_KEY, CSFLE_AWS_TEMP_SESSION_TOKEN
. $DRIVERS_TOOLS/.evergreen/csfle/set-temp-creds.sh
fi

npm install mongodb-client-encryption@">=2.0.0-beta.3"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to block this PR but wanna bump this to beta.4 :)

Copy link
Contributor

@dariakp dariakp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but we can probably put the ../../integration/shared requires back to just ../shared in both the prose.deadlock and prose test files now

@baileympearson baileympearson merged commit 44bbd6e into main Feb 9, 2022
@baileympearson baileympearson deleted the NODE-3777 branch February 9, 2022 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team Review Needs review from team
Projects
None yet
4 participants