'When passed a string endpoint description beginning with C{tls:},
L{clientFromString} returns a client endpoint initialized with the
values from the string.'

def test_tls(self):

    reactor = MemoryReactor()
    endpoint = endpoints.clientFromString(deterministicResolvingReactor(reactor, ['127.0.0.1']), 'tls:localhost:4321:privateKey={}:certificate={}:trustRoots={}'.format(escapedPEMPathName, escapedPEMPathName, endpoints.quoteStringArgument(pemPath.parent().path)).encode('ascii'))
    d = endpoint.connect(Factory.forProtocol(Protocol))
    (host, port, factory, timeout, bindAddress) = reactor.tcpClients.pop()
    clientProtocol = factory.buildProtocol(None)
    self.assertNoResult(d)
    assert (clientProtocol is not None)
    serverCert = PrivateCertificate.loadPEM(pemPath.getContent())
    serverOptions = CertificateOptions(privateKey=serverCert.privateKey.original, certificate=serverCert.original, extraCertChain=[Certificate.loadPEM(chainPath.getContent()).original], trustRoot=serverCert)
    plainServer = Protocol()
    serverProtocol = TLSMemoryBIOFactory(serverOptions, isClient=False, wrappedFactory=Factory.forProtocol((lambda : plainServer))).buildProtocol(None)
    (sProto, cProto, pump) = connectedServerAndClient((lambda : serverProtocol), (lambda : clientProtocol))
    plainServer.transport.write('hello\r\n')
    plainClient = self.successResultOf(d)
    plainClient.transport.write('hi    you    too\r\n')
    pump.flush()
    self.assertFalse(plainServer.transport.disconnecting)
    self.assertFalse(plainClient.transport.disconnecting)
    self.assertFalse(plainServer.transport.disconnected)
    self.assertFalse(plainClient.transport.disconnected)
    peerCertificate = Certificate.peerFromTransport(plainServer.transport)
    self.assertEqual(peerCertificate, Certificate.loadPEM(pemPath.getContent()))
