~whitmo/charm-helpers/hook-name-env-var-default

« back to all changes in this revision

Viewing changes to tests/contrib/ssl/test_service.py

  • Committer: Jorge Niedbalski
  • Date: 2015-04-16 14:14:57 UTC
  • mfrom: (356.1.1 devel)
  • Revision ID: jorge.niedbalski@canonical.com-20150416141457-00n1716dmigepg1k
[niedbalski, r=billy-olsen] Fixes stderr outputs for ssl commands introduced by latest contrib/ssl/test_service.py change.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
import shutil
4
4
import subprocess
5
5
import six
 
6
import mock
6
7
 
7
8
from os.path import exists, join, isdir
8
9
 
19
20
        super(ServiceCATest, self).tearDown()
20
21
        shutil.rmtree(self.temp_dir, ignore_errors=True)
21
22
 
22
 
    def test_init(self):
 
23
    @mock.patch("charmhelpers.contrib.ssl.service.log")
 
24
    def test_init(self, *args):
23
25
        """
24
26
        Tests that a ServiceCA is initialized with the correct directory
25
27
        layout.
50
52
                self.assertTrue(isdir(full_path),
51
53
                                'Path {} is not a dir'.format(full_path))
52
54
 
53
 
    def test_create_cert(self):
 
55
    @mock.patch("charmhelpers.contrib.ssl.service.log")
 
56
    def test_create_cert(self, *args):
54
57
        """
55
58
        Tests that a generated certificate is valid against the ca.
56
59
        """
67
70
        cmd = ['openssl', 'verify', '-verbose',
68
71
               '-CAfile', join(ca_root_dir, 'cacert.pem'), full_cert_path]
69
72
 
70
 
        output = subprocess.check_output(cmd).strip()
 
73
        output = subprocess.check_output(cmd,
 
74
                                         stderr=subprocess.STDOUT).strip()
71
75
        expected = '{}: OK'.format(full_cert_path)
72
76
        if six.PY3:
73
77
            expected = bytes(expected, 'utf-8')