summaryrefslogtreecommitdiff
path: root/src/leap/crypto/tests/test_certs.py
blob: e476b630146b4189670fb62840402c1d0cf292c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import unittest

from leap.testing.https_server import where
from leap.crypto import certs


class CertTestCase(unittest.TestCase):

    def test_can_load_client_and_pkey(self):
        with open(where('leaptestscert.pem')) as cf:
            cs = cf.read()
        with open(where('leaptestskey.pem')) as kf:
            ks = kf.read()
        certs.can_load_cert_and_pkey(cs + ks)

        with self.assertRaises(certs.BadCertError):
            # screw header
            certs.can_load_cert_and_pkey(cs.replace("BEGIN", "BEGINN") + ks)


if __name__ == "__main__":
    unittest.main()