Skip to content

Conversation

@blink1073
Copy link
Member

@blink1073 blink1073 commented Sep 26, 2022

Integration tests are in mongodb/mongo-python-driver#1064

{'aws': {'secretAccessKey': 'foo'}}]:
with self.assertRaisesRegex(
ValueError, "kms_providers\['aws'\] must contain "
ValueError, r"kms_providers\['aws'\] must contain "
Copy link
Member Author

Choose a reason for hiding this comment

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

These changes address warnings seen while running the tests:

test/test_mongocrypt.py:139
  /Users/steve.silvester/workspace/libmongocrypt/bindings/python/test/test_mongocrypt.py:139: DeprecationWarning: invalid escape sequence '\('
    "instance of bytes or str \(unicode in Python 2\)"):

Copy link
Member

Choose a reason for hiding this comment

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

Noted.

"""Get on-demand GCP credentials"""
metadata_host = "metadata.google.internal"
if os.getenv("GCE_METADATA_HOST"):
metadata_host = os.environ["GCE_METADATA_HOST"]
Copy link
Member

Choose a reason for hiding this comment

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

Suggest:

metadata_host = os.getenv("GCE_METADATA_HOST") or "metadata.google.internal"

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

url = "http://%s/computeMetadata/v1/instance/service-accounts/default/token" % metadata_host

headers = {"Metadata-Flavor": "Google"}
response = requests.get(url, headers=headers)
Copy link
Member

Choose a reason for hiding this comment

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

Do we need exception handling here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

raise ValueError(msg)
try:
data = response.json()
except Exception :
Copy link
Member

Choose a reason for hiding this comment

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

Exception : -> Exception:

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

response = requests.get(url, headers=headers)
if response.status_code != 200:
msg = "Unable to retrieve GCP credentials: expected StatusCode 200, got StatusCode: %s. Response body:\n%s" % (response.status_code, response.content)
raise ValueError(msg)
Copy link
Member

Choose a reason for hiding this comment

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

ValueError is usually used to indicate an invalid argument was passed whereas here the problem is elsewhere. Perhaps MongoCryptError would be more appropriate here and below?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

{'aws': {'secretAccessKey': 'foo'}}]:
with self.assertRaisesRegex(
ValueError, "kms_providers\['aws'\] must contain "
ValueError, r"kms_providers\['aws'\] must contain "
Copy link
Member

Choose a reason for hiding this comment

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

Noted.

@blink1073 blink1073 requested a review from ShaneHarvey October 6, 2022 18:05

# The libmongocrypt git revision release to embed in our wheels.
REVISION=$(git rev-list -n 1 1.5.2)
REVISION=$(git rev-list -n 1 1.6.0)
Copy link
Member

Choose a reason for hiding this comment

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

1.6.1 is out now.

Copy link
Member

Choose a reason for hiding this comment

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

Oh I see 1.6.1 had no code changes so 1.6.0 is fine.

@blink1073 blink1073 marked this pull request as ready for review October 6, 2022 20:15
@blink1073 blink1073 requested a review from juliusgeo as a code owner October 6, 2022 20:15
@blink1073 blink1073 requested a review from ShaneHarvey October 6, 2022 20:16
@blink1073 blink1073 merged commit 0bfad9f into mongodb:master Oct 6, 2022
@blink1073 blink1073 deleted the PYTHON-3367 branch October 6, 2022 21:44
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