-
Notifications
You must be signed in to change notification settings - Fork 372
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
unicode type check #3211
unicode type check #3211
Conversation
azurelinuxagent/ga/exthandlers.py
Outdated
""" | ||
if not isinstance(value, bool): | ||
return True if isinstance(value, str) and value.lower() == "true" else default_val | ||
return True if isinstance(value, (ustr, str)) and value.lower() == "true" else default_val |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return True if isinstance(value, (ustr, str)) and value.lower() == "true" else default_val | |
return True if value.lower() == ustr("true") else default_val |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial intention was protecting against non-string/non-boolean and use default otherwise value.lower() will raise an error and will not process the extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is your intention we are ok break the extension in that case? non-string/boolean totally unacceptable?
azurelinuxagent/ga/exthandlers.py
Outdated
""" | ||
if not isinstance(value, bool): | ||
return True if isinstance(value, str) and value.lower() == "true" else default_val | ||
return True if isinstance(value, (ustr, str)) and value.lower() == "true" else default_val |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need unit test
tests/ga/test_extension.py
Outdated
@@ -3527,6 +3527,23 @@ def test_handler_manifest_boolen_fields(self): | |||
self.assertFalse(manifest.is_report_heartbeat()) | |||
self.assertFalse(manifest.supports_multiple_extensions()) | |||
|
|||
def test_unicode_values_for_boolean_fields_in_handler_manifest(self): | |||
handler_json = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should do this test loading the json from a file, which is what exposed the problem
Other similar tests should probably also be modified
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #3211 +/- ##
===========================================
+ Coverage 71.97% 72.32% +0.34%
===========================================
Files 103 114 +11
Lines 15692 16978 +1286
Branches 2486 2452 -34
===========================================
+ Hits 11295 12280 +985
- Misses 3881 4132 +251
- Partials 516 566 +50 ☔ View full report in Codecov by Sentry. |
Description
Issue #
PR information
Quality of Code and Contribution Guidelines