-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Fix problem in sanitize_for_serialization for Python (pydantic type SecretStr ) BUG#16086 (2nd pull) #18023
Fix problem in sanitize_for_serialization for Python (pydantic type SecretStr ) BUG#16086 (2nd pull) #18023
Changes from 6 commits
800241d
8e20da6
137ff31
9879006
b5e7bd4
5f8e6ba
737e711
9238ea0
0bf6031
0abbe94
067ecef
5afc2d4
9f0f2cb
8058458
4c3247f
0ed3ba4
b26fc96
ceed176
45a94dc
6b8f27d
045bc2e
14c5972
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
import time | ||
import unittest | ||
|
||
from pydantic import ValidationError | ||
from pydantic import ValidationError, SecretStr, BaseModel, StrictStr, Field | ||
import pytest | ||
|
||
import petstore_api | ||
|
@@ -408,7 +408,12 @@ def test_valdiator(self): | |
self.assertEqual(a.pattern_with_digits_and_delimiter, "image_123") | ||
|
||
# test sanitize for serializaation with SecretStr (format: password) | ||
self.assertEquals(petstore_api.ApiClient().sanitize_for_serialization(a), {'byte': b'string', 'date': '2013-09-17', 'number': 123.45, 'password': 'testing09876', 'pattern_with_digits_and_delimiter': 'image_123'}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for adding another test below shouldn't this test/assertion still pass after this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
yes, you are right... it can make sense to keep this line also as in case of password which will be as default string - it will also work. I added this line back to this pull.. 0ed3ba4 + will check sanitize function based on bytes/date/integer data types There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @wing328 - can you please check and confirm that now is ok? |
||
class LoginTest(BaseModel): | ||
username: StrictStr = Field(min_length=2, strict=True, max_length=64) | ||
password: SecretStr | ||
|
||
l = LoginTest(username="admin", password="testing09876") | ||
self.assertEqual(petstore_api.ApiClient().sanitize_for_serialization(l), {'username': "admin", 'password': "testing09876"}) | ||
|
||
def test_inline_enum_validator(self): | ||
self.pet = petstore_api.Pet(name="test name", photoUrls=["string"]) | ||
|
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.
can you please remove this extra blank line?
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.
done