Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use base64.decodebytes() and base64.encodebytes(). [Issue #338]
This commit also adds test coverage for tsigkeyring, and fixes to_text() on python 3, which had never worked properly due to an extra .decode().
- Loading branch information
Showing
2 changed files
with
37 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright (C) Dnspython Contributors, see LICENSE for text of ISC license | ||
|
||
import base64 | ||
import unittest | ||
|
||
import dns.tsigkeyring | ||
|
||
text_keyring = { | ||
'keyname.' : 'NjHwPsMKjdN++dOfE5iAiQ==' | ||
} | ||
|
||
rich_keyring = { | ||
dns.name.from_text('keyname.') : \ | ||
base64.decodebytes('NjHwPsMKjdN++dOfE5iAiQ=='.encode()) | ||
} | ||
|
||
class TSIGKeyRingTestCase(unittest.TestCase): | ||
|
||
def test_from_text(self): | ||
"""text keyring -> rich keyring""" | ||
rkeyring = dns.tsigkeyring.from_text(text_keyring) | ||
self.assertEqual(rkeyring, rich_keyring) | ||
|
||
def test_to_text(self): | ||
"""text keyring -> rich keyring -> text keyring""" | ||
tkeyring = dns.tsigkeyring.to_text(rich_keyring) | ||
self.assertEqual(tkeyring, text_keyring) | ||
|
||
def test_from_and_to_text(self): | ||
"""text keyring -> rich keyring -> text keyring""" | ||
rkeyring = dns.tsigkeyring.from_text(text_keyring) | ||
tkeyring = dns.tsigkeyring.to_text(rkeyring) | ||
self.assertEqual(tkeyring, text_keyring) |