'Wrap L{AgentTestsMixin.integrationTest} with TLS.'

def integrationTest(self, hostName, expectedAddress, addressType):

    (authority, server) = certificatesForAuthorityAndServer(hostName.decode('ascii'))
    def tlsify(serverFactory):
        return TLSMemoryBIOFactory(server.options(), False, serverFactory)
    def tlsagent(reactor):
        from twisted.web.iweb import IPolicyForHTTPS
        from zope.interface import implementer
        @implementer(IPolicyForHTTPS)
        class Policy(object, ):
            def creatorForNetloc(self, hostname, port):
                return optionsForClientTLS(hostname.decode('ascii'), trustRoot=authority)
        return client.Agent(reactor, contextFactory=Policy())
    super(AgentHTTPSTests, self).integrationTest(hostName, expectedAddress, addressType, serverWrapper=tlsify, createAgent=tlsagent, scheme='https')
