Launch a server, connect a client to it and try various reads and writes.
(client_context, server_context, indata=b"FOO\n",
chatty=True, connectionchatty=False, sni_name=None,
session=None)
| 2962 | self.server.close() |
| 2963 | |
| 2964 | def server_params_test(client_context, server_context, indata=b"FOO\n", |
| 2965 | chatty=True, connectionchatty=False, sni_name=None, |
| 2966 | session=None): |
| 2967 | """ |
| 2968 | Launch a server, connect a client to it and try various reads |
| 2969 | and writes. |
| 2970 | """ |
| 2971 | stats = {} |
| 2972 | server = ThreadedEchoServer(context=server_context, |
| 2973 | chatty=chatty, |
| 2974 | connectionchatty=False) |
| 2975 | with server: |
| 2976 | with client_context.wrap_socket(socket.socket(), |
| 2977 | server_hostname=sni_name, session=session) as s: |
| 2978 | s.connect((HOST, server.port)) |
| 2979 | for arg in [indata, bytearray(indata), memoryview(indata)]: |
| 2980 | if connectionchatty: |
| 2981 | if support.verbose: |
| 2982 | sys.stdout.write( |
| 2983 | " client: sending %r...\n" % indata) |
| 2984 | s.write(arg) |
| 2985 | outdata = s.read() |
| 2986 | if connectionchatty: |
| 2987 | if support.verbose: |
| 2988 | sys.stdout.write(" client: read %r\n" % outdata) |
| 2989 | if outdata != indata.lower(): |
| 2990 | raise AssertionError( |
| 2991 | "bad data <<%r>> (%d) received; expected <<%r>> (%d)\n" |
| 2992 | % (outdata[:20], len(outdata), |
| 2993 | indata[:20].lower(), len(indata))) |
| 2994 | s.write(b"over\n") |
| 2995 | if connectionchatty: |
| 2996 | if support.verbose: |
| 2997 | sys.stdout.write(" client: closing connection.\n") |
| 2998 | stats.update({ |
| 2999 | 'compression': s.compression(), |
| 3000 | 'cipher': s.cipher(), |
| 3001 | 'peercert': s.getpeercert(), |
| 3002 | 'client_alpn_protocol': s.selected_alpn_protocol(), |
| 3003 | 'version': s.version(), |
| 3004 | 'session_reused': s.session_reused, |
| 3005 | 'session': s.session, |
| 3006 | }) |
| 3007 | if CAN_GET_SELECTED_OPENSSL_GROUP: |
| 3008 | stats.update({'group': s.group()}) |
| 3009 | if CAN_GET_SELECTED_OPENSSL_SIGALG: |
| 3010 | stats.update({'client_sigalg': s.client_sigalg()}) |
| 3011 | stats.update({'server_sigalg': s.server_sigalg()}) |
| 3012 | s.close() |
| 3013 | stats['server_alpn_protocols'] = server.selected_alpn_protocols |
| 3014 | stats['server_shared_ciphers'] = server.shared_ciphers |
| 3015 | return stats |
| 3016 | |
| 3017 | def try_protocol_combo(server_protocol, client_protocol, expect_success, |
| 3018 | certsreqs=None, server_options=0, client_options=0): |
no test coverage detected
searching dependent graphs…