mirror of
https://github.com/openSUSE/osc.git
synced 2025-09-07 05:38:43 +02:00
passx encode/decode functions
The string.encode('bz2') does not work in python3. Implement passx_encode/passx_decode functions compatible with python 2.6, 2.7 and 3.3. Add a simple unit test.
This commit is contained in:
committed by
Marcus Huewe
parent
f85c76bd42
commit
111fd87715
32
tests/test_conf.py
Normal file
32
tests/test_conf.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from osc.conf import passx_encode, passx_decode
|
||||
from common import OscTestCase
|
||||
|
||||
import os
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.getcwd(), 'conf_fixtures')
|
||||
|
||||
def suite():
|
||||
import unittest
|
||||
return unittest.makeSuite(TestAddFiles)
|
||||
|
||||
class TestConf(OscTestCase):
|
||||
def _get_fixtures_dir(self):
|
||||
return FIXTURES_DIR
|
||||
|
||||
def setUp(self):
|
||||
return super(TestConf, self).setUp(copytree=False)
|
||||
|
||||
def testPassxEncodeDecode(self):
|
||||
|
||||
passwd = "J0e'sPassword!@#"
|
||||
passx = passx_encode(passwd)
|
||||
#base64.b64encode(passwd.encode('bz2'))
|
||||
passx27 = "QlpoOTFBWSZTWaDg4dQAAAKfgCiAQABAEEAAJgCYgCAAMQAACEyYmTyei67AsYSDSaLuSKcKEhQcHDqA"
|
||||
|
||||
self.assertEqual(passwd, passx_decode(passx))
|
||||
self.assertEqual(passwd, passx_decode(passx27))
|
||||
self.assertEqual(passx, passx27)
|
||||
|
||||
if __name__ == '__main__':
|
||||
import unittest
|
||||
unittest.main()
|
Reference in New Issue
Block a user