Skip to content

Commit

Permalink
Run clippy and unit tests on push.
Browse files Browse the repository at this point in the history
  • Loading branch information
valderman committed Sep 9, 2024
1 parent e9a1e0a commit da0d440
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Run unit tests
on: [push]
jobs:
unit-tests:
runs-on: self-hosted
steps:
- run: curl https://sh.rustup.rs -sSf | sh -s -- -y
- name: Check out repo
uses: actions/checkout@v4
- run: |
. "$HOME/.cargo/env"
cargo test
dbus-run-session cargo test --features=install,dbus-tests
clippy:
runs-on: self-hosted
steps:
- run: curl https://sh.rustup.rs -sSf | sh -s -- -y
- name: Check out repo
uses: actions/checkout@v4
- run: |
. "$HOME/.cargo/env"
cargo clippy
cargo clippy --features=install,dbus-tests
4 changes: 2 additions & 2 deletions src/commands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ mod tests {
use super::*;

#[test]
fn init_creates_all_necessary_and_files_with_correct_permissions() {
fn init_creates_all_necessary_secrets_and_files_with_correct_permissions() {
let swtpm = SwTpm::new();
let dir = tempdir().unwrap();
let cfg_path = dir.path().join("totpm.conf");
Expand Down Expand Up @@ -298,6 +298,6 @@ mod tests {
}

fn get_user_name() -> String {
std::env::var("USER").unwrap_or("root".to_string())
String::from_utf8(Command::new("whoami").output().unwrap().stdout).unwrap().trim().to_string()
}
}
14 changes: 7 additions & 7 deletions src/presence_verification/fprintd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl <'a> FprintDevice<'a> {
true
}).or(fail("fprintd: unable to listen for signal"))?;

self.proxy.method_call(FPRINTD_DEVICE_IFACE, "VerifyStart", ("any",))
self.proxy.method_call::<(), _, _, _>(FPRINTD_DEVICE_IFACE, "VerifyStart", ("any",))
.or(fail("fprintd: unable to start fingerprint verification"))?;

eprintln!("place your finger on the fingerprint reader");
Expand All @@ -129,15 +129,15 @@ impl <'a> FprintDevice<'a> {
if let Some(status) = *scan_status_clone.lock().unwrap() {
match status {
Status::Match => {
self.proxy.method_call(FPRINTD_DEVICE_IFACE, "VerifyStop", ())
self.proxy.method_call::<(), _, _, _>(FPRINTD_DEVICE_IFACE, "VerifyStop", ())
.or(fail("fprintd: unable to stop fingerprint verification"))?;
return Ok(true)
},
Status::NoMatch => {
eprintln!("fingerprint not recognized, try again");
self.proxy.method_call(FPRINTD_DEVICE_IFACE, "VerifyStop", ())
self.proxy.method_call::<(), _, _, _>(FPRINTD_DEVICE_IFACE, "VerifyStop", ())
.or(fail("fprintd: unable to stop fingerprint verification"))?;
self.proxy.method_call(FPRINTD_DEVICE_IFACE, "VerifyStart", ("any",))
self.proxy.method_call::<(), _, _, _>(FPRINTD_DEVICE_IFACE, "VerifyStart", ("any",))
.or(fail("fprintd: unable to restart fingerprint verification"))?;
},
Status::RetryScan | Status::SwipeTooShort | Status::FingerNotCentered | Status::RemoveAndRetry => {
Expand All @@ -148,15 +148,15 @@ impl <'a> FprintDevice<'a> {
return fail("fprintd: fingerprint reader disconnected")
},
Status::UnknownError => {
self.proxy.method_call(FPRINTD_DEVICE_IFACE, "VerifyStop", ())
self.proxy.method_call::<(), _, _, _>(FPRINTD_DEVICE_IFACE, "VerifyStop", ())
.or(fail("fprintd: unable to stop fingerprint verification"))?;
return fail("fprintd: fingerprint scan failed with unknown error")
},
}

}
}
self.proxy.method_call(FPRINTD_DEVICE_IFACE, "VerifyStop", ())
self.proxy.method_call::<(), _, _, _>(FPRINTD_DEVICE_IFACE, "VerifyStop", ())
.or(fail("fprintd: unable to stop fingerprint verification"))?;
Ok(false)
}
Expand All @@ -175,7 +175,7 @@ impl <'a> FprintDevice<'a> {
device_path,
Duration::from_secs(10),
);
proxy.method_call(FPRINTD_DEVICE_IFACE, "Claim", ("",))
proxy.method_call::<(), _, _, _>(FPRINTD_DEVICE_IFACE, "Claim", ("",))
.or(Err(super::Error::ImplementationSpecificError("fprintd: unable to claim device".to_owned())))?;
Ok(FprintDevice { proxy, connection: conn })
}
Expand Down

0 comments on commit da0d440

Please sign in to comment.