コード例 #1
0
ファイル: standalone_test.py プロジェクト: luannalita/artrvl
    def setUp(self):
        from certbot.plugins.standalone import ServerManager
        self.certs = {
        }  # type: Dict[bytes, Tuple[OpenSSL.crypto.PKey, OpenSSL.crypto.X509]]
        self.http_01_resources = {} \
        # type: Set[acme_standalone.HTTP01RequestHandler.HTTP01Resource]

        self.mgr = ServerManager(self.certs, self.http_01_resources)
コード例 #2
0
 def setUp(self):
     from certbot.plugins.standalone import ServerManager
     from certbot.configuration import NamespaceConfig
     self.certs = {}
     self.http_01_resources = {}
     self.mgr = ServerManager(
         self.certs, self.http_01_resources,
         NamespaceConfig(mock.MagicMock(http01_use_tls=False)))
コード例 #3
0
 def test_run_stop_http_01_use_tls(self):
     from certbot.plugins.standalone import ServerManager
     from certbot.configuration import NamespaceConfig
     old_mgr = self.mgr
     self.mgr = ServerManager(
         self.certs, self.http_01_resources,
         NamespaceConfig(mock.MagicMock(http01_use_tls=True)))
     self._test_run_stop(challenges.HTTP01)
     self.mgr = old_mgr
コード例 #4
0
ファイル: standalone_test.py プロジェクト: benileo/certbot
 def setUp(self):
     from certbot.plugins.standalone import ServerManager
     from certbot.configuration import NamespaceConfig
     self.certs = {}
     self.http_01_resources = {}
     self.mgr = ServerManager(self.certs, self.http_01_resources,
                              NamespaceConfig(mock.MagicMock(
                                  http01_use_tls=False)))
コード例 #5
0
ファイル: standalone_test.py プロジェクト: benileo/certbot
 def test_run_stop_http_01_use_tls(self):
     from certbot.plugins.standalone import ServerManager
     from certbot.configuration import NamespaceConfig
     old_mgr = self.mgr
     self.mgr = ServerManager(self.certs, self.http_01_resources,
                              NamespaceConfig(mock.MagicMock(
                                  http01_use_tls=True)))
     self._test_run_stop(challenges.HTTP01)
     self.mgr = old_mgr
コード例 #6
0
 def setUp(self):
     from certbot.plugins.standalone import ServerManager
     self.certs = {}
     self.http_01_resources = {}
     self.mgr = ServerManager(self.certs, self.http_01_resources)
コード例 #7
0
class ServerManagerTest(unittest.TestCase):
    """Tests for certbot.plugins.standalone.ServerManager."""
    def setUp(self):
        from certbot.plugins.standalone import ServerManager
        self.certs = {}
        self.http_01_resources = {}
        self.mgr = ServerManager(self.certs, self.http_01_resources)

    def test_init(self):
        self.assertTrue(self.mgr.certs is self.certs)
        self.assertTrue(self.mgr.http_01_resources is self.http_01_resources)

    def _test_run_stop(self, challenge_type):
        server = self.mgr.run(port=0, challenge_type=challenge_type)
        port = server.getsocknames()[0][1]  # pylint: disable=no-member
        self.assertEqual(self.mgr.running(), {port: server})
        self.mgr.stop(port=port)
        self.assertEqual(self.mgr.running(), {})

    def test_run_stop_tls_sni_01(self):
        self._test_run_stop(challenges.TLSSNI01)

    def test_run_stop_http_01(self):
        self._test_run_stop(challenges.HTTP01)

    def test_run_idempotent(self):
        server = self.mgr.run(port=0, challenge_type=challenges.HTTP01)
        port = server.getsocknames()[0][1]  # pylint: disable=no-member
        server2 = self.mgr.run(port=port, challenge_type=challenges.HTTP01)
        self.assertEqual(self.mgr.running(), {port: server})
        self.assertTrue(server is server2)
        self.mgr.stop(port)
        self.assertEqual(self.mgr.running(), {})

    def test_run_bind_error(self):
        some_server = socket.socket(socket.AF_INET6)
        some_server.bind(("", 0))
        port = some_server.getsockname()[1]
        maybe_another_server = socket.socket()
        try:
            maybe_another_server.bind(("", port))
        except socket.error:
            pass
        self.assertRaises(errors.StandaloneBindError,
                          self.mgr.run,
                          port,
                          challenge_type=challenges.HTTP01)
        self.assertEqual(self.mgr.running(), {})
コード例 #8
0
    def setUp(self):
        from certbot.plugins.standalone import ServerManager

        self.certs = {}
        self.http_01_resources = {}
        self.mgr = ServerManager(self.certs, self.http_01_resources)
コード例 #9
0
class ServerManagerTest(unittest.TestCase):
    """Tests for certbot.plugins.standalone.ServerManager."""

    def setUp(self):
        from certbot.plugins.standalone import ServerManager

        self.certs = {}
        self.http_01_resources = {}
        self.mgr = ServerManager(self.certs, self.http_01_resources)

    def test_init(self):
        self.assertTrue(self.mgr.certs is self.certs)
        self.assertTrue(self.mgr.http_01_resources is self.http_01_resources)

    def _test_run_stop(self, challenge_type):
        server = self.mgr.run(port=0, challenge_type=challenge_type)
        port = server.socket.getsockname()[1]  # pylint: disable=no-member
        self.assertEqual(self.mgr.running(), {port: server})
        self.mgr.stop(port=port)
        self.assertEqual(self.mgr.running(), {})

    def test_run_stop_tls_sni_01(self):
        self._test_run_stop(challenges.TLSSNI01)

    def test_run_stop_http_01(self):
        self._test_run_stop(challenges.HTTP01)

    def test_run_idempotent(self):
        server = self.mgr.run(port=0, challenge_type=challenges.HTTP01)
        port = server.socket.getsockname()[1]  # pylint: disable=no-member
        server2 = self.mgr.run(port=port, challenge_type=challenges.HTTP01)
        self.assertEqual(self.mgr.running(), {port: server})
        self.assertTrue(server is server2)
        self.mgr.stop(port)
        self.assertEqual(self.mgr.running(), {})

    def test_run_bind_error(self):
        some_server = socket.socket()
        some_server.bind(("", 0))
        port = some_server.getsockname()[1]
        self.assertRaises(errors.StandaloneBindError, self.mgr.run, port, challenge_type=challenges.HTTP01)
        self.assertEqual(self.mgr.running(), {})
コード例 #10
0
 def setUp(self):
     from certbot.plugins.standalone import ServerManager
     self.certs = {}  # type: Dict[bytes, Tuple[OpenSSL.crypto.PKey, OpenSSL.crypto.X509]]
     self.http_01_resources = {} \
     # type: Set[acme_standalone.HTTP01RequestHandler.HTTP01Resource]
     self.mgr = ServerManager(self.certs, self.http_01_resources)
コード例 #11
0
class ServerManagerTest(unittest.TestCase):
    """Tests for certbot.plugins.standalone.ServerManager."""

    def setUp(self):
        from certbot.plugins.standalone import ServerManager
        self.certs = {}  # type: Dict[bytes, Tuple[OpenSSL.crypto.PKey, OpenSSL.crypto.X509]]
        self.http_01_resources = {} \
        # type: Set[acme_standalone.HTTP01RequestHandler.HTTP01Resource]
        self.mgr = ServerManager(self.certs, self.http_01_resources)

    def test_init(self):
        self.assertTrue(self.mgr.certs is self.certs)
        self.assertTrue(
            self.mgr.http_01_resources is self.http_01_resources)

    def _test_run_stop(self, challenge_type):
        server = self.mgr.run(port=0, challenge_type=challenge_type)
        port = server.getsocknames()[0][1]  # pylint: disable=no-member
        self.assertEqual(self.mgr.running(), {port: server})
        self.mgr.stop(port=port)
        self.assertEqual(self.mgr.running(), {})

    def test_run_stop_http_01(self):
        self._test_run_stop(challenges.HTTP01)

    def test_run_idempotent(self):
        server = self.mgr.run(port=0, challenge_type=challenges.HTTP01)
        port = server.getsocknames()[0][1]  # pylint: disable=no-member
        server2 = self.mgr.run(port=port, challenge_type=challenges.HTTP01)
        self.assertEqual(self.mgr.running(), {port: server})
        self.assertTrue(server is server2)
        self.mgr.stop(port)
        self.assertEqual(self.mgr.running(), {})

    def test_run_bind_error(self):
        some_server = socket.socket(socket.AF_INET6)
        some_server.bind(("", 0))
        port = some_server.getsockname()[1]
        maybe_another_server = socket.socket()
        try:
            maybe_another_server.bind(("", port))
        except socket.error:
            pass
        self.assertRaises(
            errors.StandaloneBindError, self.mgr.run, port,
            challenge_type=challenges.HTTP01)
        self.assertEqual(self.mgr.running(), {})
        some_server.close()
        maybe_another_server.close()
コード例 #12
0
class ServerManagerTest(unittest.TestCase):
    """Tests for certbot.plugins.standalone.ServerManager."""
    def setUp(self):
        from certbot.plugins.standalone import ServerManager
        from certbot.configuration import NamespaceConfig
        self.certs = {}
        self.http_01_resources = {}
        self.mgr = ServerManager(
            self.certs, self.http_01_resources,
            NamespaceConfig(mock.MagicMock(http01_use_tls=False)))

    def test_init(self):
        self.assertTrue(self.mgr.certs is self.certs)
        self.assertTrue(self.mgr.http_01_resources is self.http_01_resources)

    def _test_run_stop(self, challenge_type):
        server = self.mgr.run(port=0, challenge_type=challenge_type)
        port = server.socket.getsockname()[1]  # pylint: disable=no-member
        self.assertEqual(self.mgr.running(), {port: server})
        self.mgr.stop(port=port)
        self.assertEqual(self.mgr.running(), {})

    def test_run_stop_tls_sni_01(self):
        self._test_run_stop(challenges.TLSSNI01)

    def test_run_stop_http_01(self):
        self._test_run_stop(challenges.HTTP01)

    def test_run_stop_http_01_use_tls(self):
        from certbot.plugins.standalone import ServerManager
        from certbot.configuration import NamespaceConfig
        old_mgr = self.mgr
        self.mgr = ServerManager(
            self.certs, self.http_01_resources,
            NamespaceConfig(mock.MagicMock(http01_use_tls=True)))
        self._test_run_stop(challenges.HTTP01)
        self.mgr = old_mgr

    def test_run_idempotent(self):
        server = self.mgr.run(port=0, challenge_type=challenges.HTTP01)
        port = server.socket.getsockname()[1]  # pylint: disable=no-member
        server2 = self.mgr.run(port=port, challenge_type=challenges.HTTP01)
        self.assertEqual(self.mgr.running(), {port: server})
        self.assertTrue(server is server2)
        self.mgr.stop(port)
        self.assertEqual(self.mgr.running(), {})

    def test_run_bind_error(self):
        some_server = socket.socket()
        some_server.bind(("", 0))
        port = some_server.getsockname()[1]
        self.assertRaises(errors.StandaloneBindError,
                          self.mgr.run,
                          port,
                          challenge_type=challenges.HTTP01)
        self.assertEqual(self.mgr.running(), {})