wala-rust

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | README | LICENSE

commit 7b9c7b0d40f511ca9286f87ed2a8b86878fa145c
parent d4ec353a8f75f9710b92dfb40e3b05ec3f0888d5
Author: lash <dev@holbrook.no>
Date:   Fri, 24 Jun 2022 09:10:15 +0000

Rehabilitate mock test!

Diffstat:
Msrc/auth/mock.rs | 12++++++++----
Msrc/main.rs | 4++--
2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/auth/mock.rs b/src/auth/mock.rs @@ -1,3 +1,6 @@ +use std::io::{ + Read, +}; use crate::auth::{ AuthSpec, AuthError, @@ -5,7 +8,7 @@ use crate::auth::{ }; -pub fn auth_check(auth: &AuthSpec) -> Result<AuthResult, AuthError> { +pub fn auth_check(auth: &AuthSpec, data: impl Read, data_length: usize) -> Result<AuthResult, AuthError> { if auth.method != "mock" { return Err(AuthError{}); } @@ -25,11 +28,12 @@ mod tests { use super::auth_check; use super::{AuthSpec, AuthResult}; use std::str::FromStr; + use std::io::empty; #[test] fn test_mock_auth_check() { let mut auth_spec = AuthSpec::from_str("foo:bar:baz").unwrap(); - match auth_check(&auth_spec) { + match auth_check(&auth_spec, empty(), 0) { Ok(v) => { panic!("expected invalid auth"); }, @@ -38,7 +42,7 @@ mod tests { } auth_spec = AuthSpec::from_str("mock:bar:baz").unwrap(); - match auth_check(&auth_spec) { + match auth_check(&auth_spec, empty(), 0) { Ok(v) => { panic!("expected invalid auth"); }, @@ -47,7 +51,7 @@ mod tests { } auth_spec = AuthSpec::from_str("mock:bar:bar").unwrap(); - match auth_check(&auth_spec) { + match auth_check(&auth_spec, empty(), 0) { Ok(v) => { }, Err(e) => { diff --git a/src/main.rs b/src/main.rs @@ -116,7 +116,7 @@ fn exec_response(req: Request, r: RequestResult) { } -fn exec_auth(auth_spec: AuthSpec, data: impl Read, data_length: usize) -> Option<AuthResult> { +fn exec_auth(auth_spec: AuthSpec, data: &File, data_length: usize) -> Option<AuthResult> { #[cfg(feature = "dev")] match mock_auth_check(&auth_spec, data, data_length) { Ok(v) => { @@ -139,7 +139,7 @@ fn exec_auth(auth_spec: AuthSpec, data: impl Read, data_length: usize) -> Option } -fn process_auth(auth_spec: AuthSpec, data: impl Read, data_length: usize) -> Option<AuthResult> { +fn process_auth(auth_spec: AuthSpec, data: &File, data_length: usize) -> Option<AuthResult> { if !auth_spec.valid() { let r = AuthResult{ identity: vec!(),