-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not decode attribute values of post read control
Fixes: https://github.com/python-ldap/python-ldap/issues/399 https://github.com/python-ldap/python-ldap/pull/400
- Loading branch information
Florian Best
authored and
GitHub
committed
Dec 4, 2020
1 parent
0ef6175
commit 4993d4a
Showing
3 changed files
with
32 additions
and
1 deletion.
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
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,28 @@ | ||
import os | ||
import unittest | ||
|
||
# Switch off processing .ldaprc or ldap.conf before importing _ldap | ||
os.environ['LDAPNOINIT'] = '1' | ||
|
||
from ldap.controls import readentry # noqa: E402 | ||
|
||
|
||
PRC_ENC = b'db\x04)uid=Administrator,cn=users,l=school,l=dev0503\x04\tentryUUID1&\x04$5d96cc2c-8e13-103a-8ca5-2f74868e0e44' | ||
PRC_DEC = b'0\x0b\x04\tentryUUID' | ||
|
||
|
||
class TestLibldapControls(unittest.TestCase): | ||
|
||
def test_pagedresults_encode(self): | ||
pr = readentry.PostReadControl(True, ['entryUUID']) | ||
self.assertEqual(pr.encodeControlValue(), PRC_DEC) | ||
|
||
def test_readentry_decode(self): | ||
pr = readentry.PostReadControl(True, ['entryUUID']) | ||
pr.decodeControlValue(PRC_ENC) | ||
self.assertIsInstance(pr.dn, str) | ||
self.assertEqual(pr.entry, {'entryUUID': [b'5d96cc2c-8e13-103a-8ca5-2f74868e0e44']}) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |