(self)
| 4170 | self.assertIs(stats['client_alpn_protocol'], None) |
| 4171 | |
| 4172 | def test_alpn_protocols(self): |
| 4173 | server_protocols = ['foo', 'bar', 'milkshake'] |
| 4174 | protocol_tests = [ |
| 4175 | (['foo', 'bar'], 'foo'), |
| 4176 | (['bar', 'foo'], 'foo'), |
| 4177 | (['milkshake'], 'milkshake'), |
| 4178 | (['http/3.0', 'http/4.0'], None) |
| 4179 | ] |
| 4180 | for client_protocols, expected in protocol_tests: |
| 4181 | client_context, server_context, hostname = testing_context() |
| 4182 | server_context.set_alpn_protocols(server_protocols) |
| 4183 | client_context.set_alpn_protocols(client_protocols) |
| 4184 | |
| 4185 | try: |
| 4186 | stats = server_params_test(client_context, |
| 4187 | server_context, |
| 4188 | chatty=True, |
| 4189 | connectionchatty=True, |
| 4190 | sni_name=hostname) |
| 4191 | except ssl.SSLError as e: |
| 4192 | stats = e |
| 4193 | |
| 4194 | msg = "failed trying %s (s) and %s (c).\n" \ |
| 4195 | "was expecting %s, but got %%s from the %%s" \ |
| 4196 | % (str(server_protocols), str(client_protocols), |
| 4197 | str(expected)) |
| 4198 | client_result = stats['client_alpn_protocol'] |
| 4199 | self.assertEqual(client_result, expected, |
| 4200 | msg % (client_result, "client")) |
| 4201 | server_result = stats['server_alpn_protocols'][-1] \ |
| 4202 | if len(stats['server_alpn_protocols']) else 'nothing' |
| 4203 | self.assertEqual(server_result, expected, |
| 4204 | msg % (server_result, "server")) |
| 4205 | |
| 4206 | def test_npn_protocols(self): |
| 4207 | assert not ssl.HAS_NPN |
nothing calls this directly
no test coverage detected