Describe the connection result in human-readable form.
(desc, result)
| 55 | |
| 56 | |
| 57 | def verbose_inspector(desc, result): |
| 58 | """Describe the connection result in human-readable form.""" |
| 59 | ret = "{0}:".format(desc) |
| 60 | if any(isinstance(x, ServerHelloDone) for x in result): |
| 61 | ch = next((x for x in result if isinstance(x, ClientHello)), None) |
| 62 | sh = next((x for x in result if isinstance(x, ServerHello)), None) |
| 63 | if sh and ch: |
| 64 | if sh.cipher_suite not in ch.cipher_suites: |
| 65 | ret += " FAILURE cipher suite mismatch" |
| 66 | return ret |
| 67 | name = CipherSuite.ietfNames[sh.cipher_suite] \ |
| 68 | if sh.cipher_suite in CipherSuite.ietfNames \ |
| 69 | else hex(sh.cipher_suite) |
| 70 | ret += " ok: {0}, {1}".format(sh.server_version, |
| 71 | name) |
| 72 | return ret |
| 73 | ret += " FAILURE " |
| 74 | errors = [] |
| 75 | for msg in result: |
| 76 | if isinstance(msg, ClientHello): |
| 77 | continue |
| 78 | # check if returned message supports custom formatting |
| 79 | if msg.__class__.__format__ is not object.__format__: |
| 80 | errors += ["{:vxm}".format(msg)] |
| 81 | else: |
| 82 | errors += [repr(msg)] |
| 83 | # skip printing close errors after fatal alerts, they are expected |
| 84 | if isinstance(msg, Alert) and msg.level == AlertLevel.fatal: |
| 85 | break |
| 86 | ret += "\n".join(errors) |
| 87 | return ret |
| 88 | |
| 89 | configs = {} |
| 90 |
no outgoing calls
no test coverage detected