Commit a3143f42 authored by ale's avatar ale
Browse files

add a full integration test via main()

parent 1c063489
import getpass
import os
import shutil
import subprocess
import sys
import tempfile
import unittest
from cam import main
class MainTest(unittest.TestCase):
def setUp(self):
self.tmpdir = tempfile.mkdtemp()
self.cfgfile = os.path.join(self.tmpdir, 'test.conf')
with open(self.cfgfile, 'w') as fd:
cn = Test Ca
org = Test
country = IE
email =
bits = 1024
cn =
def _fake_getpass(prompt):
return 'testpass'
getpass.getpass = _fake_getpass
def tearDown(self):
def _run(self, *args):
sys.argv = ['cam', '--config=%s' % self.cfgfile] + list(args)
return main.main()
except SystemExit, e:
return e.code
def test_init_and_sanity_check(self):
self.assertEquals(None, self._run('init'))
self.assertEquals(None, self._run('gen', 'web'))
ca_file = os.path.join(self.tmpdir, 'public/ca.pem')
crt_file = os.path.join(self.tmpdir, 'public/certs/web.pem')
pipe = subprocess.Popen(
['openssl', 'verify', '-CAfile', ca_file, '-verbose', crt_file],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output = pipe.communicate()[0]
result = pipe.returncode
self.assertEquals(0, result)
print output
self.assertTrue('error ' not in output)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment