-
Notifications
You must be signed in to change notification settings - Fork 252
Key.to_dict() now always returns JSON encodeable keys and values. #139
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
Changes from all commits
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 |
---|---|---|
|
@@ -194,6 +194,10 @@ def assert_parameters(self, as_dict, private): | |
# Private parameters should be absent | ||
assert 'd' not in as_dict | ||
|
||
# as_dict should be serializable to JSON | ||
import json | ||
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. Nitpick: |
||
json.dumps(as_dict) | ||
|
||
def test_to_dict(self): | ||
key = ECKey(private_key, ALGORITHMS.ES256) | ||
self.assert_parameters(key.to_dict(), private=True) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ def test_RSA_key(self): | |
|
||
def test_to_dict(self): | ||
passphrase = 'The quick brown fox jumps over the lazy dog' | ||
encoded = b'VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw' | ||
encoded = 'VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw' | ||
key = HMACKey(passphrase, ALGORITHMS.HS256) | ||
|
||
as_dict = key.to_dict() | ||
|
@@ -43,3 +43,7 @@ def test_to_dict(self): | |
|
||
assert 'k' in as_dict | ||
assert as_dict['k'] == encoded | ||
|
||
# as_dict should be serializable to JSON | ||
import json | ||
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. Same nitpick here: |
||
json.dumps(as_dict) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -370,6 +370,10 @@ def assert_parameters(self, as_dict, private): | |
assert 'dq' not in as_dict | ||
assert 'qi' not in as_dict | ||
|
||
# as_dict should be serializable to JSON | ||
import json | ||
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. Same nitpick here: |
||
json.dumps(as_dict) | ||
|
||
def assert_roundtrip(self, key): | ||
assert RSAKey( | ||
key.to_dict(), | ||
|
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.
Nitpick: I know that the encoding names get normalized anyway, but I'd prefer to have one style.
ASCII
is capitalized everywhere else, so I'd like it capitalized here as well.