|
| 1 | +# |
| 2 | +# (C) Copyright 2022 Enthought, Inc., Austin, TX |
| 3 | +# All right reserved. |
| 4 | +# |
| 5 | +# This file is open source software distributed according to the terms in |
| 6 | +# LICENSE.txt |
| 7 | +# |
| 8 | +import unittest |
| 9 | + |
| 10 | +from win32ctypes.core._authentication import CREDENTIAL |
| 11 | +from win32ctypes.constants import ( |
| 12 | + CRED_TYPE_GENERIC, CRED_PERSIST_ENTERPRISE) |
| 13 | + |
| 14 | + |
| 15 | +class TestCREDENTIAL(unittest.TestCase): |
| 16 | + |
| 17 | + def test_from_dict(self): |
| 18 | + # given |
| 19 | + username = u"john" |
| 20 | + password = u"doefsajfsakfj" |
| 21 | + comment = u"Created by MiniPyWin32Cred test suite" |
| 22 | + target = "{0}@{1}".format(username, password) |
| 23 | + data = { |
| 24 | + "Type": CRED_TYPE_GENERIC, |
| 25 | + "TargetName": target, |
| 26 | + "UserName": username, |
| 27 | + "CredentialBlob": password, |
| 28 | + "Comment": comment, |
| 29 | + "Persist": CRED_PERSIST_ENTERPRISE} |
| 30 | + |
| 31 | + # when |
| 32 | + result = CREDENTIAL.fromdict(data) |
| 33 | + |
| 34 | + # then |
| 35 | + self.assertEqual(result.Type, CRED_TYPE_GENERIC) |
| 36 | + self.assertEqual(result.TargetName, target) |
| 37 | + self.assertEqual(result.UserName, username) |
| 38 | + self.assertEqual(result.CredentialBlobSize, 26) |
| 39 | + self.assertEqual(result.Comment, comment) |
| 40 | + self.assertEqual(result.Persist, CRED_PERSIST_ENTERPRISE) |
0 commit comments