def test_servername(self):
    '\n        When a client specifies a server name in its hello message, the\n        callback passed to `Contexts.set_tlsext_servername_callback` is\n        invoked and the result of `Connection.get_servername` is that\n        server name.\n        '
    args = []

    def servername(conn):
        args.append((conn, conn.get_servername()))
    context = Context(TLSv1_METHOD)
    context.set_tlsext_servername_callback(servername)
    context.use_privatekey(load_privatekey(FILETYPE_PEM, server_key_pem))
    context.use_certificate(load_certificate(FILETYPE_PEM, server_cert_pem))
    server = Connection(context, None)
    server.set_accept_state()
    client = Connection(Context(TLSv1_METHOD), None)
    client.set_connect_state()
    client.set_tlsext_host_name(b'foo1.example.com')
    interact_in_memory(server, client)
    assert (args == [(server, b'foo1.example.com')])
When a client specifies a server name in its hello message, the
callback passed to `Contexts.set_tlsext_servername_callback` is
invoked and the result of `Connection.get_servername` is that
server name.
def test_servername(self):
    '\n        When a client specifies a server name in its hello message, the\n        callback passed to `Contexts.set_tlsext_servername_callback` is\n        invoked and the result of `Connection.get_servername` is that\n        server name.\n        '
    args = []

    def servername(conn):
        args.append((conn, conn.get_servername()))
    context = Context(TLSv1_METHOD)
    context.set_tlsext_servername_callback(servername)
    context.use_privatekey(load_privatekey(FILETYPE_PEM, server_key_pem))
    context.use_certificate(load_certificate(FILETYPE_PEM, server_cert_pem))
    server = Connection(context, None)
    server.set_accept_state()
    client = Connection(Context(TLSv1_METHOD), None)
    client.set_connect_state()
    client.set_tlsext_host_name(b'foo1.example.com')
    interact_in_memory(server, client)
    assert (args == [(server, b'foo1.example.com')])