Beispiel #1
0
    def test_ok(self, tmpdir):
        ca_key = os.path.join(tmpdir, 'some.key')
        ca_crt = os.path.join(tmpdir, 'some.crt')
        ca = Ca(ca_key=ca_key, ca_crt=ca_crt)
        ca.make_ca_key()

        assert ca.make_ca_crt() is None
Beispiel #2
0
 def test_no_key(self, tmpdir):
     ca_key = os.path.join(tmpdir, 'some.key')
     ca_crt = os.path.join(tmpdir, 'some.crt')
     ca = Ca(ca_key=ca_key, ca_crt=ca_crt)
     with pytest.raises(SystemExit) as excinfo:
         ca.make_ca_crt()
     err_str = excinfo.value.code
     assert 'No such file or directory' in err_str
Beispiel #3
0
    def test_write_err(self, tmpdir):
        ca_key = os.path.join(tmpdir, 'some.key')
        open(ca_key, 'a').close()
        os.chmod(ca_key, 0o000)

        ca = Ca(ca_key=ca_key)
        with pytest.raises(SystemExit) as excinfo:
            ca.make_ca_key()
        assert 'Permission denied' in excinfo.value.code
Beispiel #4
0
    def test_ok(self, tmpdir):
        ca_key = os.path.join(tmpdir, 'some.key')
        ca_crt = os.path.join(tmpdir, 'some.crt')

        ca = Ca(ca_key=ca_key, ca_crt=ca_crt)
        ca.make_ca_key()
        ca.make_ca_crt()

        serial = Ca.get_crt_serial(ca_crt)
        assert len(serial) == 59
        assert re.search(r'^[a-f0-9:]+$', serial)
Beispiel #5
0
 def test_dir_not_exists(self, tmpdir):
     ca_key = os.path.join(tmpdir, 'non_exists', 'some.key')
     ca = Ca(ca_key=ca_key)
     with pytest.raises(SystemExit) as excinfo:
         ca.make_ca_key()
     assert 'No such file or directory' in excinfo.value.code
Beispiel #6
0
 def test_ok(self, tmpdir):
     ca_key = os.path.join(tmpdir, 'some.key')
     ca = Ca(ca_key=ca_key)
     ca.make_ca_key()
     assert ca.check_ca_key()
Beispiel #7
0
    def test_empty(self, tmpdir):
        ca_key = os.path.join(tmpdir, 'some.key')
        open(ca_key, 'a').close()

        ca = Ca(ca_key=ca_key)
        assert not ca.check_ca_key()
Beispiel #8
0
    def test_not_exists(self, tmpdir):
        ca_key = os.path.join(tmpdir, 'some.key')

        ca = Ca(ca_key=ca_key)
        assert not ca.check_ca_key()
Beispiel #9
0
 def test_not_exists(self, tmpdir):
     crt = os.path.join(tmpdir, 'some.crt')
     assert not Ca.get_crt_serial(crt)