Skip to content

Commit 0f85c27

Browse files
committed
cargo fmt
1 parent 3587734 commit 0f85c27

File tree

2 files changed

+44
-18
lines changed

2 files changed

+44
-18
lines changed

src/sr/main.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,7 @@ fn main_inner() -> SrResult<()> {
313313

314314
debug!("Best exec settings: {:?}", execcfg);
315315

316-
check_auth(
317-
&execcfg.auth,
318-
&execcfg.timeout,
319-
&user,
320-
&args,
321-
)?;
316+
check_auth(&execcfg.auth, &execcfg.timeout, &user, &args)?;
322317

323318
if !execcfg.score.fully_matching() {
324319
println!("You are not allowed to execute this command, this incident will be reported.");

src/sr/pam/mod.rs

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ use nonstick::{
88
};
99
use pcre2::bytes::RegexBuilder;
1010

11-
use crate::{
12-
error::{SrError, SrResult}, Cli,
13-
};
1411
#[cfg(feature = "timeout")]
1512
use crate::timeout;
13+
use crate::{
14+
error::{SrError, SrResult},
15+
Cli,
16+
};
1617
use rar_common::{
1718
database::options::{SAuthentication, STimeout},
1819
Cred,
@@ -123,8 +124,7 @@ impl ConversationAdapter for SrConversationHandler<'_> {
123124

124125
pub(super) fn check_auth(
125126
authentication: &SAuthentication,
126-
#[cfg_attr(not(feature = "timeout"), allow(unused_variables))]
127-
timeout: &STimeout,
127+
#[cfg_attr(not(feature = "timeout"), allow(unused_variables))] timeout: &STimeout,
128128
user: &Cred,
129129
cli: &Cli,
130130
) -> SrResult<()> {
@@ -197,7 +197,9 @@ mod tests {
197197

198198
#[test]
199199
fn test_sr_conversation_handler_new() {
200-
let handler = SrConversationHandler::builder().prompt("Test prompt: ").build();
200+
let handler = SrConversationHandler::builder()
201+
.prompt("Test prompt: ")
202+
.build();
201203
assert_eq!(handler.prompt, "Test prompt: ");
202204
assert!(handler.username.is_none());
203205
assert!(!handler.use_stdin);
@@ -263,7 +265,12 @@ mod tests {
263265
let user = create_test_user();
264266

265267
// When authentication is skipped, it should always succeed
266-
let result = check_auth(&authentication, &timeout, &user, &Cli::builder().prompt("Password: ").build());
268+
let result = check_auth(
269+
&authentication,
270+
&timeout,
271+
&user,
272+
&Cli::builder().prompt("Password: ").build(),
273+
);
267274
assert!(result.is_ok());
268275
}
269276

@@ -277,7 +284,12 @@ mod tests {
277284
let timeout = create_test_timeout();
278285
let user = create_test_user();
279286

280-
let _ = check_auth(&authentication, &timeout, &user, &Cli::builder().prompt("Password: ").build());
287+
let _ = check_auth(
288+
&authentication,
289+
&timeout,
290+
&user,
291+
&Cli::builder().prompt("Password: ").build(),
292+
);
281293
}
282294

283295
#[test]
@@ -297,7 +309,9 @@ mod tests {
297309
#[test]
298310
fn test_password_prompt_replacement() {
299311
let custom_prompt = "Enter your secret: ";
300-
let handler = SrConversationHandler::builder().prompt(custom_prompt).build();
312+
let handler = SrConversationHandler::builder()
313+
.prompt(custom_prompt)
314+
.build();
301315

302316
assert_eq!(handler.prompt, custom_prompt);
303317

@@ -325,7 +339,12 @@ mod tests {
325339

326340
#[test]
327341
fn test_conversation_handler_fields() {
328-
let handler = SrConversationHandler::builder().prompt("Custom: ").use_stdin(true).no_interact(true).username("alice").build();
342+
let handler = SrConversationHandler::builder()
343+
.prompt("Custom: ")
344+
.use_stdin(true)
345+
.no_interact(true)
346+
.username("alice")
347+
.build();
329348

330349
assert!(handler.use_stdin);
331350
assert!(handler.no_interact);
@@ -353,7 +372,19 @@ mod tests {
353372
let auth = SAuthentication::Skip;
354373

355374
// Test different timeout types don't cause errors
356-
assert!(check_auth(&auth, &timeout_ppid, &user, &Cli::builder().prompt("Password: ").build()).is_ok());
357-
assert!(check_auth(&auth, &timeout_tty, &user, &Cli::builder().prompt("Password: ").build()).is_ok());
375+
assert!(check_auth(
376+
&auth,
377+
&timeout_ppid,
378+
&user,
379+
&Cli::builder().prompt("Password: ").build()
380+
)
381+
.is_ok());
382+
assert!(check_auth(
383+
&auth,
384+
&timeout_tty,
385+
&user,
386+
&Cli::builder().prompt("Password: ").build()
387+
)
388+
.is_ok());
358389
}
359390
}

0 commit comments

Comments
 (0)