majority of tests now pass -- also fixed not invoking on_finish of auth handler

pull/146/head
Chip Senkbeil 2 years ago
parent 400025855f
commit acc9933867
No known key found for this signature in database
GPG Key ID: 35EF1F8EC72A4131

@ -136,6 +136,7 @@ where
}
Authentication::Finished => {
trace!("Authenticate::Finished");
handler.on_finished().await?;
return Ok(());
}
}

@ -8,24 +8,31 @@ use std::collections::{HashMap, HashSet};
#[serde(rename_all = "snake_case", tag = "type")]
pub enum Authentication {
/// Indicates the beginning of authentication, providing available methods
#[serde(rename = "auth_initialization")]
Initialization(Initialization),
/// Indicates that authentication is starting for the specific `method`
#[serde(rename = "auth_start_method")]
StartMethod(StartMethod),
/// Issues a challenge to be answered
#[serde(rename = "auth_challenge")]
Challenge(Challenge),
/// Requests verification of some text
#[serde(rename = "auth_verification")]
Verification(Verification),
/// Reports some information associated with authentication
#[serde(rename = "auth_info")]
Info(Info),
/// Reports an error occurrred during authentication
#[serde(rename = "auth_error")]
Error(Error),
/// Indicates that the authentication of all methods is finished
#[serde(rename = "auth_finished")]
Finished,
}
@ -68,12 +75,15 @@ pub struct Info {
#[serde(rename_all = "snake_case", tag = "type")]
pub enum AuthenticationResponse {
/// Contains response to initialization, providing details about which methods to use
#[serde(rename = "auth_initialization_response")]
Initialization(InitializationResponse),
/// Contains answers to challenge request
#[serde(rename = "auth_challenge_response")]
Challenge(ChallengeResponse),
/// Contains response to a verification request
#[serde(rename = "auth_verification_response")]
Verification(VerificationResponse),
}

@ -173,6 +173,7 @@ impl AuthHandler for JsonAuthHandler {
}
async fn on_finished(&mut self) -> io::Result<()> {
self.tx.send_blocking(&Authentication::Finished)?;
Ok(())
}
}

@ -287,12 +287,18 @@ pub async fn validate_authentication(repl: &mut Repl) {
.await
.unwrap()
.expect("Missing authentication initialization");
assert_eq!(json, json!({"type": "initialization", "methods": ["none"]}));
assert_eq!(
json,
json!({"type": "auth_initialization", "methods": ["none"]})
);
let json = repl
.write_and_read_json(json!({"type": "initialization", "methods": ["none"]}))
.write_and_read_json(json!({
"type": "auth_initialization_response",
"methods": ["none"]
}))
.await
.unwrap()
.expect("Missing authentication finalization");
assert_eq!(json, json!({"type": "finished"}));
assert_eq!(json, json!({"type": "auth_finished"}));
}

Loading…
Cancel
Save