コード例 #1
0
 def setUp(self):
     super(EndpointTests, self).setUp()
     clock = Clock()
     clock.rightNow = (
         datetime.now() - datetime(1970, 1, 1)).total_seconds()
     client = FakeClient(RSA_KEY_512, clock)
     self.endpoint = AutoTLSEndpoint(
         reactor=clock,
         directory=URL.fromText(u'https://example.com/'),
         client_creator=lambda reactor, directory: succeed(client),
         cert_store=MemoryStore(),
         cert_mapping={},
         sub_endpoint=DummyEndpoint())
コード例 #2
0
class EndpointTests(TestCase):
    """
    Tests for `~txacme.endpoint.AutoTLSEndpoint`.
    """
    def setUp(self):
        super(EndpointTests, self).setUp()
        clock = Clock()
        clock.rightNow = (
            datetime.now() - datetime(1970, 1, 1)).total_seconds()
        client = FakeClient(RSA_KEY_512, clock)
        self.endpoint = AutoTLSEndpoint(
            reactor=clock,
            directory=URL.fromText(u'https://example.com/'),
            client_creator=lambda reactor, directory: succeed(client),
            cert_store=MemoryStore(),
            cert_mapping={},
            sub_endpoint=DummyEndpoint())

    def test_directory_url_type(self):
        """
        `~txacme.endpoint.AutoTLSEndpoint` expects a ``twisted.python.url.URL``
        instance for the ``directory`` argument.
        """
        with ExpectedException(TypeError):
            AutoTLSEndpoint(
                reactor=Clock(),
                directory='/wrong/kind/of/directory',
                client_creator=None,
                cert_store=None,
                cert_mapping={},
                sub_endpoint=DummyEndpoint())

    def test_listen_starts_service(self):
        """
        ``AutoTLSEndpoint.listen`` starts an ``AcmeIssuingService``.  Stopping
        the port stops the service.
        """
        factory = Factory()
        d = self.endpoint.listen(factory)
        self.assertThat(
            d,
            succeeded(
                MatchesPredicate(
                    IListeningPort.providedBy,
                    '%r does not provide IListeningPort')))
        port = d.result
        self.assertThat(
            self.endpoint.service,
            MatchesStructure(running=Equals(True)))
        self.assertThat(port.stopListening(), succeeded(Always()))
        self.assertThat(
            self.endpoint.service,
            MatchesStructure(running=Equals(False)))
コード例 #3
0
ファイル: test_endpoint.py プロジェクト: ra2003/txacme
 def test_directory_url_type(self):
     """
     `~txacme.endpoint.AutoTLSEndpoint` expects a ``twisted.python.url.URL``
     instance for the ``directory`` argument.
     """
     with ExpectedException(TypeError):
         AutoTLSEndpoint(reactor=Clock(),
                         directory='/wrong/kind/of/directory',
                         client=None,
                         cert_store=None,
                         cert_mapping={},
                         sub_endpoint=DummyEndpoint())
コード例 #4
0
ファイル: test_endpoint.py プロジェクト: habnabit/txacme
class EndpointTests(TestCase):
    """
    Tests for `~txacme.endpoint.AutoTLSEndpoint`.
    """
    def setUp(self):
        super(EndpointTests, self).setUp()
        clock = Clock()
        clock.rightNow = (
            datetime.now() - datetime(1970, 1, 1)).total_seconds()
        client = FakeClient(RSA_KEY_512, clock)
        self.endpoint = AutoTLSEndpoint(
            reactor=clock,
            directory=None,
            client_creator=lambda reactor, directory: succeed(client),
            cert_store=MemoryStore(),
            cert_mapping={},
            sub_endpoint=DummyEndpoint())

    def test_listen_starts_service(self):
        """
        ``AutoTLSEndpoint.listen`` starts an ``AcmeIssuingService``.  Stopping
        the port stops the service.
        """
        factory = Factory()
        d = self.endpoint.listen(factory)
        self.assertThat(
            d,
            succeeded(
                MatchesPredicate(
                    IListeningPort.providedBy,
                    '%r does not provide IListeningPort')))
        port = d.result
        self.assertThat(
            self.endpoint.service,
            MatchesStructure(running=Equals(True)))
        self.assertThat(port.stopListening(), succeeded(Always()))
        self.assertThat(
            self.endpoint.service,
            MatchesStructure(running=Equals(False)))