mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-10 06:46:15 +01:00
Fix Password.encode() on python < 3.8
This commit is contained in:
parent
3d7f79b706
commit
0413179709
@ -119,6 +119,12 @@ class Password(collections.UserString):
|
||||
return f"{self.__str__():{format_spec}}"
|
||||
return super().__format__(format_spec)
|
||||
|
||||
def encode(self, *args, **kwargs):
|
||||
if sys.version_info < (3, 8):
|
||||
# avoid returning the Password object on python < 3.8
|
||||
return str(self).encode(*args, **kwargs)
|
||||
return super().encode(*args, **kwargs)
|
||||
|
||||
|
||||
HttpHeader = NewType("HttpHeader", Tuple[str, str])
|
||||
|
||||
|
17
tests/test_credentials.py
Normal file
17
tests/test_credentials.py
Normal file
@ -0,0 +1,17 @@
|
||||
import unittest
|
||||
|
||||
import osc.conf
|
||||
from osc.credentials import ObfuscatedConfigFileCredentialsManager
|
||||
|
||||
|
||||
class TestObfuscatedConfigFileCredentialsManager(unittest.TestCase):
|
||||
def test_decode_password(self):
|
||||
# obfuscated "opensuse"
|
||||
password_str = "QlpoOTFBWSZTWeTSblkAAAGBgAIBygAgADDACGNEHxaYXckU4UJDk0m5ZA=="
|
||||
password = osc.conf.Password(password_str)
|
||||
decoded = ObfuscatedConfigFileCredentialsManager.decode_password(password)
|
||||
self.assertEqual(decoded, "opensuse")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
Loading…
Reference in New Issue
Block a user