def test_alpn_success(self):
    '\n            Clients and servers that agree on the negotiated ALPN protocol can\n            correct establish a connection, and the agreed protocol is reported\n            by the connections.\n            '
    select_args = []

    def select(conn, options):
        select_args.append((conn, options))
        return b'spdy/2'
    client_context = Context(TLSv1_METHOD)
    client_context.set_alpn_protos([b'http/1.1', b'spdy/2'])
    server_context = Context(TLSv1_METHOD)
    server_context.set_alpn_select_callback(select)
    server_context.use_privatekey(load_privatekey(FILETYPE_PEM, server_key_pem))
    server_context.use_certificate(load_certificate(FILETYPE_PEM, server_cert_pem))
    server = Connection(server_context, None)
    server.set_accept_state()
    client = Connection(client_context, None)
    client.set_connect_state()
    interact_in_memory(server, client)
    assert (select_args == [(server, [b'http/1.1', b'spdy/2'])])
    assert (server.get_alpn_proto_negotiated() == b'spdy/2')
    assert (client.get_alpn_proto_negotiated() == b'spdy/2')
Clients and servers that agree on the negotiated ALPN protocol can
correct establish a connection, and the agreed protocol is reported
by the connections.
def test_alpn_success(self):
    '\n            Clients and servers that agree on the negotiated ALPN protocol can\n            correct establish a connection, and the agreed protocol is reported\n            by the connections.\n            '
    select_args = []

    def select(conn, options):
        select_args.append((conn, options))
        return b'spdy/2'
    client_context = Context(TLSv1_METHOD)
    client_context.set_alpn_protos([b'http/1.1', b'spdy/2'])
    server_context = Context(TLSv1_METHOD)
    server_context.set_alpn_select_callback(select)
    server_context.use_privatekey(load_privatekey(FILETYPE_PEM, server_key_pem))
    server_context.use_certificate(load_certificate(FILETYPE_PEM, server_cert_pem))
    server = Connection(server_context, None)
    server.set_accept_state()
    client = Connection(client_context, None)
    client.set_connect_state()
    interact_in_memory(server, client)
    assert (select_args == [(server, [b'http/1.1', b'spdy/2'])])
    assert (server.get_alpn_proto_negotiated() == b'spdy/2')
    assert (client.get_alpn_proto_negotiated() == b'spdy/2')