Skip to content

PYTHON-3110 [v3.13] Remove use of example.com in CSFLE tests (#848) #851

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 3 commits into from
Feb 10, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions test/test_encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -1115,14 +1115,14 @@ def setUp(self):
codec_options=OPTS)

kms_providers_invalid = copy.deepcopy(kms_providers)
kms_providers_invalid['azure']['identityPlatformEndpoint'] = 'example.com:443'
kms_providers_invalid['gcp']['endpoint'] = 'example.com:443'

kms_providers_invalid['azure']['identityPlatformEndpoint'] = 'doesnotexist.invalid:443'
kms_providers_invalid['gcp']['endpoint'] = 'doesnotexist.invalid:443'
self.client_encryption_invalid = ClientEncryption(
kms_providers=kms_providers_invalid,
key_vault_namespace='keyvault.datakeys',
key_vault_client=client_context.client,
codec_options=OPTS)

def tearDown(self):
self.client_encryption.close()
self.client_encryption_invalid.close()
Expand Down Expand Up @@ -1202,9 +1202,9 @@ def test_06_aws_endpoint_invalid_host(self):
"region": "us-east-1",
"key": ("arn:aws:kms:us-east-1:579766882180:key/"
"89fcc2c4-08b0-4bd9-9f25-e30687b580d0"),
"endpoint": "example.com"
"endpoint": "doesnotexist.invalid"
}
with self.assertRaisesRegex(EncryptionError, 'parse error'):
with self.assertRaisesRegex(EncryptionError, self.invalid_host_error):
Copy link
Member

Choose a reason for hiding this comment

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

invalid_host_error hasn't been defined

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Member Author

Choose a reason for hiding this comment

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

And rescheduled encryption tasks

self.client_encryption.create_data_key(
'aws', master_key=master_key)

Expand All @@ -1216,8 +1216,8 @@ def test_07_azure(self):
self.run_test_expected_success('azure', master_key)

# The full error should be something like:
# "Invalid JSON in KMS response. HTTP status=404. Error: Got parse error at '<', position 0: 'SPECIAL_EXPECTED'"
with self.assertRaisesRegex(EncryptionError, 'parse error'):
# "[Errno 8] nodename nor servname provided, or not known"
with self.assertRaisesRegex(EncryptionError, self.invalid_host_error):
self.client_encryption_invalid.create_data_key(
'azure', master_key=master_key)

Expand All @@ -1233,8 +1233,8 @@ def test_08_gcp_valid_endpoint(self):
self.run_test_expected_success('gcp', master_key)

# The full error should be something like:
# "Invalid JSON in KMS response. HTTP status=404. Error: Got parse error at '<', position 0: 'SPECIAL_EXPECTED'"
with self.assertRaisesRegex(EncryptionError, 'parse error'):
# "[Errno 8] nodename nor servname provided, or not known"
with self.assertRaisesRegex(EncryptionError, self.invalid_host_error):
self.client_encryption_invalid.create_data_key(
'gcp', master_key=master_key)

Expand All @@ -1246,7 +1246,7 @@ def test_09_gcp_invalid_endpoint(self):
"location": "global",
"keyRing": "key-ring-csfle",
"keyName": "key-name-csfle",
"endpoint": "example.com:443"}
"endpoint": "doesnotexist.invalid:443"}

# The full error should be something like:
# "Invalid KMS response, no access_token returned. HTTP status=200"
Expand Down Expand Up @@ -1335,7 +1335,7 @@ def test_explicit(self):
'AQGVERPgAAAAAAAAAAAAAAAC5DbBSwPwfSlBrDtRuglvNvCXD1KzDuCKY2P+4bRFtHDjpTOE2XuytPAUaAbXf1orsPq59PVZmsbTZbt2CB8qaQ==')

def test_automatic(self):
expected_document_extjson = textwrap.dedent("""
expected_document_extjson = textwrap.dedent("""
{"secret_azure": {
"$binary": {
"base64": "AQGVERPgAAAAAAAAAAAAAAAC5DbBSwPwfSlBrDtRuglvNvCXD1KzDuCKY2P+4bRFtHDjpTOE2XuytPAUaAbXf1orsPq59PVZmsbTZbt2CB8qaQ==",
Expand All @@ -1361,7 +1361,7 @@ def test_explicit(self):
'ARgj/gAAAAAAAAAAAAAAAAACwFd+Y5Ojw45GUXNvbcIpN9YkRdoHDHkR4kssdn0tIMKlDQOLFkWFY9X07IRlXsxPD8DcTiKnl6XINK28vhcGlg==')

def test_automatic(self):
expected_document_extjson = textwrap.dedent("""
expected_document_extjson = textwrap.dedent("""
{"secret_gcp": {
"$binary": {
"base64": "ARgj/gAAAAAAAAAAAAAAAAACwFd+Y5Ojw45GUXNvbcIpN9YkRdoHDHkR4kssdn0tIMKlDQOLFkWFY9X07IRlXsxPD8DcTiKnl6XINK28vhcGlg==",
Expand Down