Refactor noise _error_on_incorrect_preamble to improve coverage (#683)
This commit is contained in:
parent
39aba56958
commit
b31472c569
|
@ -253,16 +253,15 @@ class APINoiseFrameHelper(APIFrameHelper):
|
||||||
def _error_on_incorrect_preamble(self, msg: bytes) -> None:
|
def _error_on_incorrect_preamble(self, msg: bytes) -> None:
|
||||||
"""Handle an incorrect preamble."""
|
"""Handle an incorrect preamble."""
|
||||||
explanation = msg[1:].decode()
|
explanation = msg[1:].decode()
|
||||||
if explanation == "Handshake MAC failure":
|
if explanation != "Handshake MAC failure":
|
||||||
self._handle_error_and_close(
|
exc = HandshakeAPIError(
|
||||||
InvalidEncryptionKeyAPIError(
|
f"{self._log_name}: Handshake failure: {explanation}"
|
||||||
f"{self._log_name}: Invalid encryption key", self._server_name
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
return
|
else:
|
||||||
self._handle_error_and_close(
|
exc = InvalidEncryptionKeyAPIError(
|
||||||
HandshakeAPIError(f"{self._log_name}: Handshake failure: {explanation}")
|
f"{self._log_name}: Invalid encryption key", self._server_name
|
||||||
)
|
)
|
||||||
|
self._handle_error_and_close(exc)
|
||||||
|
|
||||||
def _handle_handshake(self, msg: bytes) -> None:
|
def _handle_handshake(self, msg: bytes) -> None:
|
||||||
if msg[0] != 0:
|
if msg[0] != 0:
|
||||||
|
|
Loading…
Reference in New Issue