Skip to content

PHPC-1545: Require object or array type for "kmsProviders" option #1089

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 2 commits into from
Jan 31, 2020

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Jan 29, 2020

@alcaeus alcaeus requested a review from jmikola January 29, 2020 07:30
@alcaeus alcaeus self-assigned this Jan 29, 2020
Copy link
Member

@jmikola jmikola 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 did you want to do this for schemaMap and extraOptions as well (per my last comment in PHPC-1545)? If so, you can repurpose the Manager test file as "invalid autoEncryption options" and handle all three in sequence.

@alcaeus
Copy link
Member Author

alcaeus commented Jan 29, 2020

That’s what I get for just skimming over comments. I’ll also apply those for other options in this PR 👍

Copy link
Member

@jmikola jmikola left a comment

Choose a reason for hiding this comment

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

Code LGTM but I'd suggest renaming some of the tests for createClientEncryption() (I may have missed the other cases in previous reviews).

@@ -2907,8 +2917,8 @@ static mongoc_client_encryption_opts_t* phongo_clientencryption_opts_from_zval(m
zval* kms_providers = php_array_fetchc(options, "kmsProviders");
bson_t bson_providers = BSON_INITIALIZER;

if (Z_TYPE_P(kms_providers) != IS_ARRAY) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected \"kmsProviders\" encryption option to be an array");
if (Z_TYPE_P(kms_providers) != IS_ARRAY && Z_TYPE_P(kms_providers) != IS_OBJECT) {
Copy link
Member

Choose a reason for hiding this comment

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

Ah, I forgot we were already checking for an array type here. Good to know both instances of "kmsProviders" handling are consistent now!

@@ -0,0 +1,36 @@
--TEST--
MongoDB\Driver\ClientEncryption::__construct() with invalid option types
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be a test for Manager::createClientEncryption() since the constructor is disabled? I see this is clientEncryption-ctor-error-002.phpt, so perhaps move all of those over to the Manager name.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, yes. Those were left over from when I initially built this with a public constructor. I moved them to the manager folder and renamed them accordingly.

alcaeus added a commit that referenced this pull request Jan 31, 2020
@alcaeus alcaeus merged commit 3c10a49 into mongodb:master Jan 31, 2020
@alcaeus alcaeus deleted the phpc-1494 branch January 31, 2020 13:54
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.

2 participants