()
| 98 | |
| 99 | #[test] |
| 100 | fn test_drop_privileges_no_clawshell_user() { |
| 101 | // On non-root CI environments without a clawshell user, |
| 102 | // drop_privileges should return Ok (since getuid is not root). |
| 103 | if getuid().is_root() { |
| 104 | // When running as root without the user, it should error |
| 105 | if User::from_name("clawshell").ok().flatten().is_none() { |
| 106 | let result = drop_privileges(); |
| 107 | assert!( |
| 108 | result.is_err(), |
| 109 | "Should fail when clawshell user doesn't exist" |
| 110 | ); |
| 111 | assert!( |
| 112 | result.unwrap_err().to_string().contains("not found"), |
| 113 | "Error should mention user not found" |
| 114 | ); |
| 115 | } |
| 116 | } else { |
| 117 | // Not root — should be a no-op success |
| 118 | let result = drop_privileges(); |
| 119 | assert!(result.is_ok(), "Should succeed as no-op when not root"); |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | #[test] |
| 124 | fn test_drop_privileges_as_root() { |
nothing calls this directly
no test coverage detected