Skip to content

PHPLIB-892: Require crypt_shared and/or mongocryptd for tests utilizing enterprise CSFLE features #1072

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 4 commits into from
Jun 26, 2023

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented May 17, 2023

Fix PHPLIB-892.

According to the doc, automatic CSFLE is only supported by Enterprise (and Atlas) servers. But this is a client-side feature, the tests are skipped when Client-Side encryption is not supported.

@GromNaN GromNaN force-pushed the PHPLIB-892 branch 2 times, most recently from d50f912 to 2354b3f Compare June 1, 2023 20:55
@GromNaN GromNaN changed the title PHPLIB-892: Skip CSFLE automatic encryption tests for non-enterprise servers PHPLIB-892: Skip CSFLE automatic encryption tests when client-site encryption is not supported Jun 14, 2023
@GromNaN GromNaN marked this pull request as ready for review June 14, 2023 08:58
@GromNaN GromNaN requested review from alcaeus and jmikola June 14, 2023 08:59
Copy link
Member

@alcaeus alcaeus left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -1821,9 +1821,7 @@ public function testQueryableEncryption(): void
$this->markTestSkipped('Explicit encryption tests require MongoDB 7.0 or later');
}

if (! $this->isEnterprise()) {
Copy link
Member

Choose a reason for hiding this comment

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

In PHPLIB-892 you wrote:

I'll run the DocumentationExamplesTest::testQueryableEncryption() with crypt_shared and/or mongocryptd available with the community server. If it passes, let's remove the isEnterprise() method and change the logic in DocumentationExamplesTest::testQueryableEncryption() to instead check if either crypt_shared or mongocryptd is available.

skipIfClientSideEncryptionIsNotSupported() doesn't check for either of those things. Did something change since you wrote that comment?

Also, in an earlier comment on that issue I pointed out that DocumentationExamplesTest::testQueryableEncryption() did require crypt_shared and/or mongocryptd (since it uses queryable encryption) but the prose test did not (since it explicitly encrypts). You could run the prose tests w/o crypt_shared and mongocryptd to verify that.

Copy link
Member

Choose a reason for hiding this comment

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

@GromNaN: In light of mongodb/specifications#1439, I would be in favor of adding a check for crypt_shared and/or mongocryptd to the base skipIfClientSideEncryptionIsNotSupported() method.

A call to skipIfClientSideEncryptionIsNotSupported() could then be used here (after the topology and 7.0+ version check). I'm aware the version check in skipIfClientSideEncryptionIsNotSupported() would be redundant, but that's OK.

You could then also remove the explicit crypt_shared/mongocryptd check in ClientSideEncryptionSpecTest::setUp().

With that done, skipIfClientSideEncryptionIsNotSupported() would become consistent with UnifiedTestRunner::isClientSideEncryptionSupported() and all of our tests would perform the same checks.

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'm aware the version check in skipIfClientSideEncryptionIsNotSupported() would be redundant, but that's OK.

There is a slight difference between the server version check and the feature compatibility version check in skipIfClientSideEncryptionIsNotSupported. So this is not redundant.

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 followed your instructions.

Copy link
Member

Choose a reason for hiding this comment

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

Aye, technically different checks. I said "redundant" as our test suite is never run on mixed-version or upgraded replica sets, so FCV will always equate the server version.

@GromNaN
Copy link
Member Author

GromNaN commented Jun 20, 2023

The skipped tests effectively fail when both are disabled.

MongoDB\Driver\Exception\ConnectionTimeoutException : mongocryptd error: No suitable servers found: serverselectiontimeoutms timed out: [connection refused calling hello on 'localhost:27020']:

@jmikola jmikola changed the title PHPLIB-892: Skip CSFLE automatic encryption tests when client-site encryption is not supported PHPLIB-892: Skip CSFLE automatic encryption tests when client-side encryption is not supported Jun 20, 2023
@@ -357,30 +353,6 @@ private function isClientSideEncryptionSupported(): bool
return static::isCryptSharedLibAvailable() || static::isMongocryptdAvailable();
}

private static function isCryptSharedLibAvailable(): bool
Copy link
Member

Choose a reason for hiding this comment

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

@eramongodb, @kevinAlbs: The csfle runOnRequirement dates back to mongodb/specifications@0f65908 and DRIVERS-2017. Reading the existing language in the unified spec, there's no indication that crypt_shared and/or mongocryptd are required.

If true, the tests MUST only run if the driver and server support Client-Side Field Level Encryption. A server supports CSFLE if it is version 4.2.0 or higher. If false, tests MUST only run if CSFLE is not enabled. If this field is omitted, there is no CSFLE requirement.

The PHPLIB unified test runner currently checks three things:

  • Server FCV >= 4.2
  • PHPC is compiled with libmongocrypt (not just libmongoc)
  • At least one of crypt_shared and mongocryptd is available

I realize that the only unified CSFLE tests at the moment are for key management, which isn't an enterprise feature. But ignoring that for a moment and assuming legacy tests will eventually be ported to the unified format, was it your intention that the csfle requirement also ensure that queryable encryption be supported?

If yes, then I'd like to clarify this in the unified test spec. If no, then I think we should remove the crypt_shared/mongocryptd check from PHPLIB's unified test runner (and maybe still clarify that in the unified spec).

Choose a reason for hiding this comment

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

At least one of crypt_shared and mongocryptd is available

I expect crypt_shared or mongocryptd would be required once the unified test format supports automatic encryption. I expect it is not necessary for the current unified test format. I suggest keeping the check for crypt_shared or mongocryptd, as I expect it will be needed in the future.

was it your intention that the csfle requirement also ensure that queryable encryption be supported?

I think yes. Both "Client-Side Field Level Encryption" and "Queryable Encryption" require libmongocrypt. As of DRIVERS-2454, "In-Use Encryption" can be used to refer to both features.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks. I opened mongodb/specifications#1439 and DRIVERS-2661 to update the unified/legacy test docs.

Copy link

@eramongodb eramongodb Jun 26, 2023

Choose a reason for hiding this comment

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

The csfle requirement was added as an (overly?) simple all-or-nothing check for whether anything related to Client Side Encryption is required by the test, which implicitly requires - or at least, was assumed to require - either mongocryptd (the only consideration back then) or crypt_shared (a new option since the wording was added), since most CSE functions cannot fulfill their specified behavior without them, including the Key Management API. I support the clarification of wording that documents the mongocryptd/crypt_shared requirement; submitted an approving review for mongodb/specifications#1439 accordingly.

}

return false;
return FunctionalTestCase::isCryptSharedLibAvailable() || FunctionalTestCase::isMongocryptdAvailable();
Copy link
Member

Choose a reason for hiding this comment

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

This is one thing I had in mind when creating PHPLIB-1170.

@GromNaN GromNaN changed the title PHPLIB-892: Skip CSFLE automatic encryption tests when client-side encryption is not supported PHPLIB-892: Require crypt_shared and/or mongocryptd for tests utilizing enterprise CSFLE features Jun 26, 2023
@GromNaN GromNaN merged commit 28f6ee8 into mongodb:master Jun 26, 2023
@GromNaN GromNaN deleted the PHPLIB-892 branch June 26, 2023 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants