コード例 #1
0
ファイル: cli_test.py プロジェクト: jskrzypek/certbot
 def _make_test_renewal_conf(self, testfile):
     with open(test_util.vector_path(testfile)) as src:
         # put the correct path for cert.pem, chain.pem etc in the renewal conf
         renewal_conf = src.read().replace("MAGICDIR", test_util.vector_path())
     rd = os.path.join(self.config_dir, "renewal")
     if not os.path.exists(rd):
         os.makedirs(rd)
     rc = os.path.join(rd, "sample-renewal.conf")
     with open(rc, "w") as dest:
         dest.write(renewal_conf)
     return rc
コード例 #2
0
ファイル: util_test.py プロジェクト: crrlos/practicas
    def test_systemd_os_release(self):
        from certbot.util import (get_os_info, get_systemd_os_info,
                                     get_os_info_ua)

        with mock.patch('os.path.isfile', return_value=True):
            self.assertEqual(get_os_info(
                test_util.vector_path("os-release"))[0], 'systemdos')
            self.assertEqual(get_os_info(
                test_util.vector_path("os-release"))[1], '42')
            self.assertEqual(get_systemd_os_info("/dev/null"), ("", ""))
            self.assertEqual(get_os_info_ua(
                test_util.vector_path("os-release")),
                "SystemdOS")
        with mock.patch('os.path.isfile', return_value=False):
            self.assertEqual(get_systemd_os_info(), ("", ""))
コード例 #3
0
ファイル: util_test.py プロジェクト: Torrus/certbot
    def test_systemd_os_release(self):
        from certbot.util import (get_os_info, get_systemd_os_info,
                                     get_os_info_ua)

        with mock.patch('os.path.isfile', return_value=True):
            self.assertEqual(get_os_info(
                test_util.vector_path("os-release"))[0], 'systemdos')
            self.assertEqual(get_os_info(
                test_util.vector_path("os-release"))[1], '42')
            self.assertEqual(get_systemd_os_info("/dev/null"), ("", ""))
            self.assertEqual(get_os_info_ua(
                test_util.vector_path("os-release")),
                "SystemdOS")
        with mock.patch('os.path.isfile', return_value=False):
            self.assertEqual(get_systemd_os_info(), ("", ""))
コード例 #4
0
ファイル: util_test.py プロジェクト: zone-h/certbot
    def test_systemd_os_release_like(self):
        from certbot.util import get_systemd_os_like

        with mock.patch('os.path.isfile', return_value=True):
            id_likes = get_systemd_os_like(test_util.vector_path("os-release"))
            self.assertEqual(len(id_likes), 3)
            self.assertTrue("debian" in id_likes)
コード例 #5
0
ファイル: util_test.py プロジェクト: Torrus/certbot
    def test_systemd_os_release_like(self):
        from certbot.util import get_systemd_os_like

        with mock.patch('os.path.isfile', return_value=True):
            id_likes = get_systemd_os_like(test_util.vector_path(
                "os-release"))
            self.assertEqual(len(id_likes), 3)
            self.assertTrue("debian" in id_likes)
コード例 #6
0
    def test_der_csr(self):
        csrfile = test_util.vector_path('csr.der')
        data = test_util.load_vector('csr.der')

        self.assertEqual((
            OpenSSL.crypto.FILETYPE_ASN1,
            le_util.CSR(file=csrfile, data=data, form="der"),
            ["example.com"],
        ), self._call(csrfile, data))
コード例 #7
0
    def test_pem_csr(self):
        csrfile = test_util.vector_path('csr.pem')
        data = test_util.load_vector('csr.pem')

        self.assertEqual((
            OpenSSL.crypto.FILETYPE_PEM,
            util.CSR(file=csrfile, data=data, form="pem"),
            ["example.com"],
        ), self._call(csrfile, data))
コード例 #8
0
ファイル: crypto_util_test.py プロジェクト: 52M/letsencrypt
    def test_pem_csr(self):
        csrfile = test_util.vector_path('csr.pem')
        data = test_util.load_vector('csr.pem')

        self.assertEqual(
            (OpenSSL.crypto.FILETYPE_PEM,
             util.CSR(file=csrfile,
                      data=data,
                      form="pem"),
             ["example.com"],),
            self._call(csrfile, data))
コード例 #9
0
ファイル: cli_test.py プロジェクト: UFHH01/certbot
 def test_agree_dev_preview_config(self):
     with mock.patch('certbot.main.run') as mocked_run:
         self._call(['-c', test_util.vector_path('cli.ini')])
     self.assertTrue(mocked_run.called)
コード例 #10
0
ファイル: cli_test.py プロジェクト: UFHH01/certbot
 def test_csr_with_no_domains(self):
     self.assertRaises(
         errors.Error, self._call, 'certonly --csr {0}'.format(
             test_util.vector_path('csr-nonames.pem')).split())
コード例 #11
0
ファイル: cli_test.py プロジェクト: UFHH01/certbot
from certbot import configuration
from certbot import constants
from certbot import crypto_util
from certbot import errors
from certbot import util
from certbot import main
from certbot import renewal
from certbot import storage

from certbot.plugins import disco
from certbot.plugins import manual

from certbot.tests import storage_test
from certbot.tests import test_util

CERT = test_util.vector_path('cert.pem')
CSR = test_util.vector_path('csr.der')
KEY = test_util.vector_path('rsa256_key.pem')


class CLITest(unittest.TestCase):  # pylint: disable=too-many-public-methods
    """Tests for different commands."""
    def setUp(self):
        self.tmp_dir = tempfile.mkdtemp()
        self.config_dir = os.path.join(self.tmp_dir, 'config')
        self.work_dir = os.path.join(self.tmp_dir, 'work')
        self.logs_dir = os.path.join(self.tmp_dir, 'logs')
        self.standard_args = [
            '--config-dir', self.config_dir, '--work-dir', self.work_dir,
            '--logs-dir', self.logs_dir, '--text'
        ]
コード例 #12
0
import shutil
import tempfile
import unittest

import OpenSSL
import mock
import zope.component

from certbot import errors
from certbot import interfaces
from certbot.tests import test_util


RSA256_KEY = test_util.load_vector('rsa256_key.pem')
RSA512_KEY = test_util.load_vector('rsa512_key.pem')
CERT_PATH = test_util.vector_path('cert.pem')
CERT = test_util.load_vector('cert.pem')
SAN_CERT = test_util.load_vector('cert-san.pem')


class InitSaveKeyTest(unittest.TestCase):
    """Tests for certbot.crypto_util.init_save_key."""
    def setUp(self):
        logging.disable(logging.CRITICAL)
        zope.component.provideUtility(
            mock.Mock(strict_permissions=True), interfaces.IConfig)
        self.key_dir = tempfile.mkdtemp('key_dir')

    def tearDown(self):
        logging.disable(logging.NOTSET)
        shutil.rmtree(self.key_dir)
コード例 #13
0
 def test_bad_csr(self):
     self.assertRaises(errors.Error, self._call,
                       test_util.vector_path('cert.pem'),
                       test_util.load_vector('cert.pem'))
コード例 #14
0
import shutil
import tempfile
import unittest

import OpenSSL
import mock
import zope.component

from certbot import errors
from certbot import interfaces
from certbot import util
from certbot.tests import test_util

RSA256_KEY = test_util.load_vector('rsa256_key.pem')
RSA512_KEY = test_util.load_vector('rsa512_key.pem')
CERT_PATH = test_util.vector_path('cert.pem')
CERT = test_util.load_vector('cert.pem')
SAN_CERT = test_util.load_vector('cert-san.pem')


class InitSaveKeyTest(unittest.TestCase):
    """Tests for certbot.crypto_util.init_save_key."""
    def setUp(self):
        logging.disable(logging.CRITICAL)
        zope.component.provideUtility(mock.Mock(strict_permissions=True),
                                      interfaces.IConfig)
        self.key_dir = tempfile.mkdtemp('key_dir')

    def tearDown(self):
        logging.disable(logging.NOTSET)
        shutil.rmtree(self.key_dir)
コード例 #15
0
ファイル: cli_test.py プロジェクト: jskrzypek/certbot
 def test_agree_dev_preview_config(self):
     with mock.patch('certbot.main.run') as mocked_run:
         self._call(['-c', test_util.vector_path('cli.ini')])
     self.assertTrue(mocked_run.called)
コード例 #16
0
ファイル: cli_test.py プロジェクト: jskrzypek/certbot
 def test_csr_with_no_domains(self):
     self.assertRaises(
         errors.Error, self._call,
         'certonly --csr {0}'.format(
             test_util.vector_path('csr-nonames.pem')).split())
コード例 #17
0
ファイル: cli_test.py プロジェクト: jskrzypek/certbot
from certbot import constants
from certbot import crypto_util
from certbot import errors
from certbot import le_util
from certbot import main
from certbot import renewal
from certbot import storage

from certbot.plugins import disco
from certbot.plugins import manual

from certbot.tests import storage_test
from certbot.tests import test_util


CERT = test_util.vector_path('cert.pem')
CSR = test_util.vector_path('csr.der')
KEY = test_util.vector_path('rsa256_key.pem')


class CLITest(unittest.TestCase):  # pylint: disable=too-many-public-methods
    """Tests for different commands."""

    def setUp(self):
        self.tmp_dir = tempfile.mkdtemp()
        self.config_dir = os.path.join(self.tmp_dir, 'config')
        self.work_dir = os.path.join(self.tmp_dir, 'work')
        self.logs_dir = os.path.join(self.tmp_dir, 'logs')
        self.standard_args = ['--config-dir', self.config_dir,
                              '--work-dir', self.work_dir,
                              '--logs-dir', self.logs_dir, '--text']
コード例 #18
0
ファイル: crypto_util_test.py プロジェクト: 52M/letsencrypt
 def test_bad_csr(self):
     self.assertRaises(errors.Error, self._call,
                       test_util.vector_path('cert.pem'),
                       test_util.load_vector('cert.pem'))