A significant clean-up of the server authentication phase, with a basic test.

The prior implementation involved some (moderately awkward) layered
`match` expressions; this version skips those in favor of `?`. The cost
is a little less detail about (for example) when serialization errors
happen. On the bright side, it gains us some huge improvements in code
clarity. We might be able to get back the tracing later, with other
library support.

In addition, we know have a couple tests: one to make sure we choose the
authentication method appropriately, and a very basic handshake test for
when we're not actually negotiation a username and password.
This commit is contained in:
2021-10-09 18:32:23 -07:00
parent 3364031c18
commit fbd98a5f9b
7 changed files with 331 additions and 106 deletions

View File

@@ -14,6 +14,14 @@ pub struct ServerAuthResponse {
}
impl ServerAuthResponse {
pub fn success() -> ServerAuthResponse {
ServerAuthResponse { success: true }
}
pub fn failure() -> ServerAuthResponse {
ServerAuthResponse { success: false }
}
pub async fn read<R: AsyncRead + Send + Unpin>(
r: &mut R,
) -> Result<Self, DeserializationError> {