Skip to content

Commit

Permalink
workspace clippy config
Browse files Browse the repository at this point in the history
  • Loading branch information
wandapeter committed Jan 14, 2024
1 parent a0febfc commit 2e82c4d
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 26 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ cargo test --lib
#### Integration testing
Edit the values in the `.env` file to a user on your system. The test will build the library and use the systems pam service to test authentication. The test will run with evelated privileges. Run the integration tests:
```console
cargo integration-test
cargo test-integration
```
### Linting
Fix:
Expand Down
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ anyhow = "1.0.75"
cli-xtask = { version = "0.8.0", features = ["main", "lib-crate"] }
xshell = "0.2.5"


[workspace.lints.clippy]
pedantic = { level = "warn" }

[package]
name = "pam-authramp"
Expand Down Expand Up @@ -68,4 +69,7 @@ priority = "optional"
assets = [
["target/release/libpam_authramp.so", "usr/lib64/security/", "755"],
["examples/system-auth/authramp.conf", "/etc/security/authramp.conf", "644"],
]
]

[lints]
workspace = true
28 changes: 14 additions & 14 deletions crates/xtask-test-integration/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,19 @@ fn main() -> anyhow::Result<()> {
let sh = Shell::new()?;

cmd!(sh, "cargo build").run()?;
cmd!(
sh,
"sudo cp target/debug/libpam_authramp.so /lib64/security"
)
.run()?;
set_and_remove_sudo_runner(|| {
let _ = cmd!(
sh,
"cargo test --test '*' -- --test-threads=1 --show-output"
)
.run();
let _ = cmd!(sh, "sudo rm -f /lib64/security/libpam_authramp.so").run();
let _ = cmd!(sh, "sudo rm -rf /var/run/authramp").run();
});
cmd!(
sh,
"sudo cp target/debug/libpam_authramp.so /lib64/security"
)
.run()?;
set_and_remove_sudo_runner(|| {
let _ = cmd!(
sh,
"cargo test --test '*' -- --test-threads=1 --show-output"
)
.run();
let _ = cmd!(sh, "sudo rm -f /lib64/security/libpam_authramp.so").run();
let _ = cmd!(sh, "sudo rm -rf /var/run/authramp").run();
});
Ok(())
}
6 changes: 3 additions & 3 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ impl Settings {
#[cfg(test)]
mod tests {
extern crate tempdir;


use self::tempdir::TempDir;
use super::*;
use std::ffi::CStr;
use self::tempdir::TempDir;
use users::User;

#[test]
Expand Down Expand Up @@ -321,7 +321,7 @@ mod tests {
// Validate the result
assert!(result.is_ok());
let settings = result.unwrap();
println!("{:?}", settings);
// println!("{:?}", settings);
assert_eq!(settings.action, Some(Actions::PREAUTH));
assert_eq!(settings.tally_dir, PathBuf::from(DEFAULT_TALLY_DIR));
assert_eq!(settings.free_tries, 6);
Expand Down
4 changes: 2 additions & 2 deletions src/tally.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ impl Tally {
mod tests {
extern crate tempdir;

use self::tempdir::TempDir;
use super::*;
use std::fs;
use self::tempdir::TempDir;
use users::User;

#[test]
Expand Down Expand Up @@ -367,7 +367,7 @@ mod tests {

// Check if the TOML file has been created with default values
let toml_content = fs::read_to_string(tally_file_path).unwrap();
println!("{}", &toml_content);
// println!("{}", &toml_content);
assert!(toml_content.contains("[Fails]"));
assert!(toml_content.contains("count = 0"));
assert!(!toml_content.contains("unlock_instant = "));
Expand Down
4 changes: 2 additions & 2 deletions src/utils/syslog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ extern crate sysinfo;
extern crate syslog;

use self::log::LevelFilter;
use pam::module::PamHandle;
use pam::{constants::PamResultCode, items::Service};
use self::sysinfo::{Pid, System};
use self::syslog::{BasicLogger, Facility, Formatter3164};
use pam::module::PamHandle;
use pam::{constants::PamResultCode, items::Service};

use crate::settings::Settings;

Expand Down
4 changes: 2 additions & 2 deletions tests/test-pam-auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ mod test_pam_auth {
ramp_multiplier = 50\n",
custom_tally_dir.path().display()
);
println!("{}", &config_content);
// println!("{}", &config_content);
let config_path = "/etc/security/authramp.conf";
fs::write(config_path, config_content).expect("Unable to write to authramp.conf");

Expand All @@ -227,7 +227,7 @@ mod test_pam_auth {

// Check if the tally file is created in the custom tally_dir path
let tally_file_path = custom_tally_dir.path().join(user_name);
println!("{:?}", &tally_file_path);
// println!("{:?}", &tally_file_path);
assert!(
Path::exists(&tally_file_path),
"Tally file not created in custom tally_dir"
Expand Down

0 comments on commit 2e82c4d

Please # to comment.