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())
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)))
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())
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)))