Simplify test code a bit, use Request::new() to simplfy constructing requests
This commit is contained in:
@@ -45,7 +45,7 @@ mod tests {
|
||||
const TEST_PATH: &str = "./test_passwords";
|
||||
|
||||
#[test]
|
||||
fn it_communicates_ok() {
|
||||
fn it_handles_a_request() {
|
||||
let repository = PasswordDirectory::new(TEST_PATH);
|
||||
|
||||
let request = Request::new("bp", "some-rad-password", "ignore-this", "also-ignore-this");
|
||||
|
||||
+13
-24
@@ -48,12 +48,8 @@ mod tests {
|
||||
#[test]
|
||||
fn it_checks_good_password() {
|
||||
let repository = PasswordDirectory::new(TEST_PATH);
|
||||
let request = Request {
|
||||
userid: "bp".to_string(),
|
||||
password: "some-rad-password".to_string(),
|
||||
service: "ignore-this".to_string(),
|
||||
realm: "also-ignore-this".to_string(),
|
||||
};
|
||||
|
||||
let request = Request::new("bp", "some-rad-password", "ignore-this", "also-ignore-this");
|
||||
|
||||
assert_eq!(repository.check_auth(&request), true);
|
||||
}
|
||||
@@ -61,12 +57,8 @@ mod tests {
|
||||
#[test]
|
||||
fn it_fails_bad_password() {
|
||||
let repository = PasswordDirectory::new(TEST_PATH);
|
||||
let request = Request {
|
||||
userid: "bp".to_string(),
|
||||
password: "not-correct".to_string(),
|
||||
service: "ignore-this".to_string(),
|
||||
realm: "also-ignore-this".to_string(),
|
||||
};
|
||||
|
||||
let request = Request::new("bp", "not-correct", "ignore-this", "also-ignore-this");
|
||||
|
||||
assert_eq!(repository.check_auth(&request), false);
|
||||
}
|
||||
@@ -74,12 +66,13 @@ mod tests {
|
||||
#[test]
|
||||
fn it_fails_bad_userid() {
|
||||
let repository = PasswordDirectory::new(TEST_PATH);
|
||||
let request = Request {
|
||||
userid: "bp-xxx".to_string(),
|
||||
password: "some-rad-password".to_string(),
|
||||
service: "ignore-this".to_string(),
|
||||
realm: "also-ignore-this".to_string(),
|
||||
};
|
||||
|
||||
let request = Request::new(
|
||||
"bp-xxx",
|
||||
"some-rad-password",
|
||||
"ignore-this",
|
||||
"also-ignore-this",
|
||||
);
|
||||
|
||||
assert_eq!(repository.check_auth(&request), false);
|
||||
}
|
||||
@@ -87,12 +80,8 @@ mod tests {
|
||||
#[test]
|
||||
fn it_ignores_comments() {
|
||||
let repository = PasswordDirectory::new(TEST_PATH);
|
||||
let request = Request {
|
||||
userid: "bp".to_string(),
|
||||
password: "commented-out".to_string(),
|
||||
service: "ignore-this".to_string(),
|
||||
realm: "also-ignore-this".to_string(),
|
||||
};
|
||||
|
||||
let request = Request::new("bp-xxx", "commented-out", "ignore-this", "also-ignore-this");
|
||||
|
||||
assert_eq!(repository.check_auth(&request), false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user