Skip to content

Commit

Permalink
Test for client-only ALPN.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasa committed Apr 11, 2015
1 parent 9fd1d07 commit c13ba46
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions OpenSSL/test/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1747,6 +1747,41 @@ def select(conn, options):
self.assertEqual([(client, [b'http/1.1', b'spdy/2'])], select_args)


def test_alpn_no_server(self):
"""
Tests that when clients and servers cannot agree on what protocol to
use next because the server doesn't offer ALPN.
"""
select_args = []
def select(conn, options):
select_args.append((conn, options))
return b''

client_context = Context(TLSv1_METHOD)
client_context.set_alpn_protos([b'http/1.1', b'spdy/2'])

server_context = Context(TLSv1_METHOD)

# Necessary to actually accept the connection
server_context.use_privatekey(
load_privatekey(FILETYPE_PEM, server_key_pem))
server_context.use_certificate(
load_certificate(FILETYPE_PEM, server_cert_pem))

# Do a little connection to trigger the logic
server = Connection(server_context, None)
server.set_accept_state()

client = Connection(client_context, None)
client.set_connect_state()

# Do the dance.
self._interactInMemory(server, client)

self.assertEqual([(client, [b'http/1.1', b'spdy/2'])], select_args)
self.assertEqual(client.get_alpn_proto_negotiated(), b'')



class SessionTests(TestCase):
"""
Expand Down

0 comments on commit c13ba46

Please sign in to comment.