|
1 | 1 | # Note: Since Aug 2019 we move all e2e tests into test_e2e.py,
|
2 | 2 | # so this test_application file contains only unit tests without dependency.
|
3 | 3 | from msal.application import *
|
| 4 | +from msal.application import _str2bytes |
4 | 5 | import msal
|
5 | 6 | from msal.application import _merge_claims_challenge_and_capabilities
|
6 | 7 | from tests import unittest
|
@@ -39,31 +40,12 @@ def test_extract_multiple_tag_enclosed_certs(self):
|
39 | 40 | self.assertEqual(["my_cert1", "my_cert2"], extract_certs(pem))
|
40 | 41 |
|
41 | 42 |
|
42 |
| -class TestEncryptedKeyAsClientCredential(unittest.TestCase): |
43 |
| - # Internally, we use serialization.load_pem_private_key() to load an encrypted private key with a passphrase |
44 |
| - # This function takes in encrypted key in bytes and passphrase in bytes too |
45 |
| - # Our code handles such a conversion, adding test cases to verify such a conversion is needed |
| 43 | +class TestBytesConversion(unittest.TestCase): |
| 44 | + def test_string_to_bytes(self): |
| 45 | + self.assertEqual(type(_str2bytes("some string")), type(b"bytes")) |
46 | 46 |
|
47 |
| - def test_encyrpted_key_in_bytes_and_string_password_should_error(self): |
48 |
| - private_key = b""" |
49 |
| - -----BEGIN ENCRYPTED PRIVATE KEY----- |
50 |
| - test_private_key |
51 |
| - -----END ENCRYPTED PRIVATE KEY----- |
52 |
| - """ |
53 |
| - with self.assertRaises(TypeError): |
54 |
| - # Using a unicode string for Python 2 to identify it as a string and not default to bytes |
55 |
| - serialization.load_pem_private_key( |
56 |
| - private_key, password=u"string_password", backend=default_backend()) |
57 |
| - |
58 |
| - def test_encyrpted_key_is_string_and_bytes_password_should_error(self): |
59 |
| - private_key = u""" |
60 |
| - -----BEGIN ENCRYPTED PRIVATE KEY----- |
61 |
| - test_private_key |
62 |
| - -----END ENCRYPTED PRIVATE KEY----- |
63 |
| - """ |
64 |
| - with self.assertRaises(TypeError): |
65 |
| - serialization.load_pem_private_key( |
66 |
| - private_key, password=b"byte_password", backend=default_backend()) |
| 47 | + def test_bytes_to_bytes(self): |
| 48 | + self.assertEqual(type(_str2bytes(b"some bytes")), type(b"bytes")) |
67 | 49 |
|
68 | 50 |
|
69 | 51 | class TestClientApplicationAcquireTokenSilentErrorBehaviors(unittest.TestCase):
|
|
0 commit comments