Skip to content

Commit da0d440

Browse files
committed
Run clippy and unit tests on push.
1 parent e9a1e0a commit da0d440

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

.github/workflows/unit-tests.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Run unit tests
2+
on: [push]
3+
jobs:
4+
unit-tests:
5+
runs-on: self-hosted
6+
steps:
7+
- run: curl https://sh.rustup.rs -sSf | sh -s -- -y
8+
- name: Check out repo
9+
uses: actions/checkout@v4
10+
- run: |
11+
. "$HOME/.cargo/env"
12+
cargo test
13+
dbus-run-session cargo test --features=install,dbus-tests
14+
clippy:
15+
runs-on: self-hosted
16+
steps:
17+
- run: curl https://sh.rustup.rs -sSf | sh -s -- -y
18+
- name: Check out repo
19+
uses: actions/checkout@v4
20+
- run: |
21+
. "$HOME/.cargo/env"
22+
cargo clippy
23+
cargo clippy --features=install,dbus-tests

src/commands/init.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ mod tests {
177177
use super::*;
178178

179179
#[test]
180-
fn init_creates_all_necessary_and_files_with_correct_permissions() {
180+
fn init_creates_all_necessary_secrets_and_files_with_correct_permissions() {
181181
let swtpm = SwTpm::new();
182182
let dir = tempdir().unwrap();
183183
let cfg_path = dir.path().join("totpm.conf");
@@ -298,6 +298,6 @@ mod tests {
298298
}
299299

300300
fn get_user_name() -> String {
301-
std::env::var("USER").unwrap_or("root".to_string())
301+
String::from_utf8(Command::new("whoami").output().unwrap().stdout).unwrap().trim().to_string()
302302
}
303303
}

src/presence_verification/fprintd.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl <'a> FprintDevice<'a> {
114114
true
115115
}).or(fail("fprintd: unable to listen for signal"))?;
116116

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

120120
eprintln!("place your finger on the fingerprint reader");
@@ -129,15 +129,15 @@ impl <'a> FprintDevice<'a> {
129129
if let Some(status) = *scan_status_clone.lock().unwrap() {
130130
match status {
131131
Status::Match => {
132-
self.proxy.method_call(FPRINTD_DEVICE_IFACE, "VerifyStop", ())
132+
self.proxy.method_call::<(), _, _, _>(FPRINTD_DEVICE_IFACE, "VerifyStop", ())
133133
.or(fail("fprintd: unable to stop fingerprint verification"))?;
134134
return Ok(true)
135135
},
136136
Status::NoMatch => {
137137
eprintln!("fingerprint not recognized, try again");
138-
self.proxy.method_call(FPRINTD_DEVICE_IFACE, "VerifyStop", ())
138+
self.proxy.method_call::<(), _, _, _>(FPRINTD_DEVICE_IFACE, "VerifyStop", ())
139139
.or(fail("fprintd: unable to stop fingerprint verification"))?;
140-
self.proxy.method_call(FPRINTD_DEVICE_IFACE, "VerifyStart", ("any",))
140+
self.proxy.method_call::<(), _, _, _>(FPRINTD_DEVICE_IFACE, "VerifyStart", ("any",))
141141
.or(fail("fprintd: unable to restart fingerprint verification"))?;
142142
},
143143
Status::RetryScan | Status::SwipeTooShort | Status::FingerNotCentered | Status::RemoveAndRetry => {
@@ -148,15 +148,15 @@ impl <'a> FprintDevice<'a> {
148148
return fail("fprintd: fingerprint reader disconnected")
149149
},
150150
Status::UnknownError => {
151-
self.proxy.method_call(FPRINTD_DEVICE_IFACE, "VerifyStop", ())
151+
self.proxy.method_call::<(), _, _, _>(FPRINTD_DEVICE_IFACE, "VerifyStop", ())
152152
.or(fail("fprintd: unable to stop fingerprint verification"))?;
153153
return fail("fprintd: fingerprint scan failed with unknown error")
154154
},
155155
}
156156

157157
}
158158
}
159-
self.proxy.method_call(FPRINTD_DEVICE_IFACE, "VerifyStop", ())
159+
self.proxy.method_call::<(), _, _, _>(FPRINTD_DEVICE_IFACE, "VerifyStop", ())
160160
.or(fail("fprintd: unable to stop fingerprint verification"))?;
161161
Ok(false)
162162
}
@@ -175,7 +175,7 @@ impl <'a> FprintDevice<'a> {
175175
device_path,
176176
Duration::from_secs(10),
177177
);
178-
proxy.method_call(FPRINTD_DEVICE_IFACE, "Claim", ("",))
178+
proxy.method_call::<(), _, _, _>(FPRINTD_DEVICE_IFACE, "Claim", ("",))
179179
.or(Err(super::Error::ImplementationSpecificError("fprintd: unable to claim device".to_owned())))?;
180180
Ok(FprintDevice { proxy, connection: conn })
181181
}

0 commit comments

Comments
 (0)