Skip to content

PYTHON-3297 Test auto decryption occurs after CommandSucceeded events #980

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 5 commits into from
Jun 24, 2022

Conversation

juliusgeo
Copy link
Contributor

No description provided.

Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

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

LGTM!

# /README.rst#14-decryption-events
class TestDecryptProse(EncryptionIntegrationTest):
def setUp(self):
self.setup_client = MongoClient()
Copy link
Member

Choose a reason for hiding this comment

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

We should use self.client (same as client_context.client) instead of creating a new client here. Otherwise the test will fail on auth or tls.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

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 not done. Please re-read my comment.

self.addCleanup(self.encrypted_client.close)

def test_command_error(self):
self.setup_client.admin.command(
Copy link
Member

Choose a reason for hiding this comment

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

We should use the with self.fail_point(...) helper since it always disables the failpoint.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

Choose a reason for hiding this comment

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

FYI you can put multiple context managers in one with-statement. So this:

with self.fail_point(...):
    with self.assertRaises(...):
        pass

Can be written as:

with self.fail_point(...), self.assertRaises(...):
    pass

No need to change anything though.

i = self.listener.results["succeeded"][0]
self.assertEqual(
i.reply["cursor"]["firstBatch"][0]["encrypted"], self.malformed_cipher_text
)
Copy link
Member

Choose a reason for hiding this comment

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

I know the spec doesn't say to but it would be good to assert there are 0 failed events.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

Choose a reason for hiding this comment

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

I don't see this added.

@juliusgeo juliusgeo requested a review from ShaneHarvey June 22, 2022 22:34
i = self.listener.results["succeeded"][0]
self.assertEqual(
i.reply["cursor"]["firstBatch"][0]["encrypted"], self.malformed_cipher_text
)
Copy link
Member

Choose a reason for hiding this comment

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

I don't see this added.

# /README.rst#14-decryption-events
class TestDecryptProse(EncryptionIntegrationTest):
def setUp(self):
self.setup_client = MongoClient()
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 not done. Please re-read my comment.

self.addCleanup(self.encrypted_client.close)

def test_command_error(self):
self.setup_client.admin.command(
Copy link
Member

Choose a reason for hiding this comment

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

FYI you can put multiple context managers in one with-statement. So this:

with self.fail_point(...):
    with self.assertRaises(...):
        pass

Can be written as:

with self.fail_point(...), self.assertRaises(...):
    pass

No need to change anything though.

Copy link
Member

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

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

LGTM!

@juliusgeo juliusgeo merged commit ae71872 into mongodb:master Jun 24, 2022
juliusgeo added a commit to juliusgeo/mongo-python-driver that referenced this pull request Jun 29, 2022
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.

3 participants