| 1 | use craterust-analyzer cargo sudo-rs 0.2.14 crate/::commonrust-analyzer cargo sudo-rs 0.2.14 common/::SudoPathrust-analyzer cargo sudo-rs 0.2.14 common/path/SudoPath#; |
| 2 | |
| 3 | use superrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/::{SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#, SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#, SudoRunOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoRunOptions#}; |
| 4 | |
| 5 | impl SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction# { |
| 6 | #[must_use] |
| 7 | pub fn is_editrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]is_edit().(&self) -> bool { |
| 8 | matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self, Selfrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]::Editrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#Edit#(..)) |
| 9 | } |
| 10 | |
| 11 | #[must_use] |
| 12 | pub fn is_helprust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]is_help().(&self) -> bool { |
| 13 | matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self, Selfrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]::Helprust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#Help#(..)) |
| 14 | } |
| 15 | |
| 16 | #[must_use] |
| 17 | pub fn is_remove_timestamprust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]is_remove_timestamp().(&self) -> bool { |
| 18 | matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self, Selfrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]::RemoveTimestamprust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#RemoveTimestamp#(..)) |
| 19 | } |
| 20 | |
| 21 | #[must_use] |
| 22 | pub fn is_reset_timestamprust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]is_reset_timestamp().(&self) -> bool { |
| 23 | matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self, Selfrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]::ResetTimestamprust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#ResetTimestamp#(..)) |
| 24 | } |
| 25 | |
| 26 | #[must_use] |
| 27 | pub fn is_listrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]is_list().(&self) -> bool { |
| 28 | matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self, Selfrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]::Listrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#List#(..)) |
| 29 | } |
| 30 | |
| 31 | #[must_use] |
| 32 | pub fn is_versionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]is_version().(&self) -> bool { |
| 33 | matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self, Selfrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]::Versionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#Version#(..)) |
| 34 | } |
| 35 | |
| 36 | #[must_use] |
| 37 | pub fn is_validaterust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]is_validate().(&self) -> bool { |
| 38 | matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self, Selfrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]::Validaterust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#Validate#(..)) |
| 39 | } |
| 40 | |
| 41 | #[allow(clippy::result_large_err)] |
| 42 | pub fn try_into_runrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]try_into_run().(self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<SudoRunOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoRunOptions#, Selfrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]> { |
| 43 | if let Selfrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]::Runrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#Run#(v) = self { |
| 44 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v) |
| 45 | } else { |
| 46 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(self) |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | #[must_use] |
| 51 | pub fn is_runrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]is_run().(&self) -> bool { |
| 52 | matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self, Selfrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]::Runrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#Run#(..)) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | /// Passing '-E' with a variable fails |
| 57 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 58 | fn short_preserve_env_with_var_failsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/short_preserve_env_with_var_fails().() { |
| 59 | let argss = [["sudo", "-E=variable"], ["sudo", "-Evariable"]]; |
| 60 | |
| 61 | for args in argss { |
| 62 | let res = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(args); |
| 63 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(res.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()) |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | /// Passing '--preserve-env' with an argument fills 'preserve_env', 'short_preserve_env' stays 'false' |
| 68 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 69 | fn preserve_env_with_varrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/preserve_env_with_var().() { |
| 70 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "--preserve-env=HOME"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 71 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 72 | [("HOME".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/var().("HOME").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())], |
| 73 | cmd.env_var_listrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#env_var_list..as_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]as_slice().() |
| 74 | ); |
| 75 | } |
| 76 | |
| 77 | /// Passing '--preserve-env' with several arguments fills 'preserve_env', 'short_preserve_env' stays 'false' |
| 78 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 79 | fn preserve_env_with_several_varsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/preserve_env_with_several_vars().() { |
| 80 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "--preserve-env=PATH,HOME"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 81 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 82 | [ |
| 83 | ("PATH".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/var().("PATH").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()), |
| 84 | ("HOME".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/var().("HOME").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()), |
| 85 | ], |
| 86 | cmd.env_var_listrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#env_var_list..as_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]as_slice().() |
| 87 | ); |
| 88 | } |
| 89 | |
| 90 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 91 | fn preserve_env_boolean_and_listrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/preserve_env_boolean_and_list().() { |
| 92 | let argss = [ |
| 93 | ["sudo", "--preserve-env", "--preserve-env=HOME"], |
| 94 | ["sudo", "--preserve-env=HOME", "--preserve-env"], |
| 95 | ]; |
| 96 | |
| 97 | for args in argss { |
| 98 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(args).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 99 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 100 | [("HOME".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/var().("HOME").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())], |
| 101 | cmd.env_var_listrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#env_var_list..as_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]as_slice().() |
| 102 | ); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 107 | fn preserve_env_repeatedrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/preserve_env_repeated().() { |
| 108 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "--preserve-env=PATH", "--preserve-env=HOME"]) |
| 109 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 110 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 111 | ["PATH", "HOME"], |
| 112 | cmd.env_var_listrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#env_var_list. |
| 113 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 114 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|x| x.0) |
| 115 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>() |
| 116 | .as_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]as_slice().() |
| 117 | ); |
| 118 | } |
| 119 | |
| 120 | /// Catch env variable that is given without hyphens in 'VAR=value' form in env_var_list. |
| 121 | /// external_args stay empty. |
| 122 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 123 | fn env_variablerust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/env_variable().() { |
| 124 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "ENV=with_a_value"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 125 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 126 | cmd.env_var_listrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#env_var_list., |
| 127 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("ENV".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), "with_a_value".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())] |
| 128 | ); |
| 129 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.positional_argsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#positional_args..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().()); |
| 130 | } |
| 131 | |
| 132 | /// Catch several env variablse that are given without hyphens in 'VAR=value' form in env_var_list. |
| 133 | /// external_args stay empty. |
| 134 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 135 | fn several_env_variablesrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/several_env_variables().() { |
| 136 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().([ |
| 137 | "sudo", |
| 138 | "ENV=with_a_value", |
| 139 | "another_var=otherval", |
| 140 | "more=this_is_a_val", |
| 141 | ]) |
| 142 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 143 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 144 | cmd.env_var_listrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#env_var_list., |
| 145 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 146 | ("ENV".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), "with_a_value".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()), |
| 147 | ("another_var".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), "otherval".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()), |
| 148 | ("more".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), "this_is_a_val".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()) |
| 149 | ] |
| 150 | ); |
| 151 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.positional_argsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#positional_args..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().()); |
| 152 | } |
| 153 | |
| 154 | /// Mix env variables and trailing arguments that just pass through sudo |
| 155 | /// Divided by hyphens. |
| 156 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 157 | fn mix_env_variables_with_trailing_args_divided_by_hyphensrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/mix_env_variables_with_trailing_args_divided_by_hyphens().() { |
| 158 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "env=var", "--", "external=args", "something"]) |
| 159 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 160 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cmd.env_var_listrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#env_var_list., vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("env".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), "var".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())]); |
| 161 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cmd.positional_argsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#positional_args., vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["external=args", "something"]); |
| 162 | } |
| 163 | |
| 164 | /// Mix env variables and trailing arguments that just pass through sudo |
| 165 | /// Divided by known flag. |
| 166 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 167 | fn mix_env_variables_with_trailing_args_divided_by_known_flagrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/mix_env_variables_with_trailing_args_divided_by_known_flag().() { |
| 168 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "-i", "external=args", "something"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 169 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 170 | cmd.env_var_listrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#env_var_list., |
| 171 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("external".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), "args".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())] |
| 172 | ); |
| 173 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.loginrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#login.); |
| 174 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cmd.positional_argsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#positional_args., vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["something"]); |
| 175 | } |
| 176 | |
| 177 | /// Catch trailing arguments that just pass through sudo |
| 178 | /// but look like a known flag. |
| 179 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 180 | fn trailing_args_followed_by_known_flagrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/trailing_args_followed_by_known_flag().() { |
| 181 | let cmd = |
| 182 | SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "args", "followed_by", "known_flag", "-i"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 183 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().cmd.loginrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#login.); |
| 184 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 185 | cmd.positional_argsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#positional_args., |
| 186 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["args", "followed_by", "known_flag", "-i"] |
| 187 | ); |
| 188 | } |
| 189 | |
| 190 | /// Catch trailing arguments that just pass through sudo |
| 191 | /// but look like a known flag, divided by hyphens. |
| 192 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 193 | fn trailing_args_hyphens_known_flagrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/trailing_args_hyphens_known_flag().() { |
| 194 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().([ |
| 195 | "sudo", |
| 196 | "--", |
| 197 | "trailing", |
| 198 | "args", |
| 199 | "followed_by", |
| 200 | "known_flag", |
| 201 | "-i", |
| 202 | ]) |
| 203 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 204 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().cmd.loginrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#login.); |
| 205 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 206 | cmd.positional_argsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#positional_args., |
| 207 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["trailing", "args", "followed_by", "known_flag", "-i"] |
| 208 | ); |
| 209 | } |
| 210 | |
| 211 | /// Check that the first environment variable declaration before any command is not treated as part |
| 212 | /// of the command. |
| 213 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 214 | fn first_trailing_env_var_is_not_an_external_argrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/first_trailing_env_var_is_not_an_external_arg().() { |
| 215 | let cmd = SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(["sudo", "FOO=1", "command", "BAR=2"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 216 | let opts = if let SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::Runrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#Run#(opts) = cmd { |
| 217 | opts |
| 218 | } else { |
| 219 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!() |
| 220 | }; |
| 221 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opts.env_var_listrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoRunOptions#env_var_list., vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("FOO".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), "1".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()),]); |
| 222 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(opts.positional_argsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoRunOptions#positional_args., ["command", "BAR=2"],); |
| 223 | } |
| 224 | |
| 225 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 226 | fn trailing_env_vars_are_external_argsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/trailing_env_vars_are_external_args().() { |
| 227 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().([ |
| 228 | "sudo", "FOO=1", "-i", "BAR=2", "command", "BAZ=3", "arg", "FOOBAR=4", "command", "arg", |
| 229 | "BARBAZ=5", |
| 230 | ]) |
| 231 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 232 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.loginrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#login.); |
| 233 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 234 | cmd.env_var_listrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#env_var_list., |
| 235 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 236 | ("FOO".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), "1".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()), |
| 237 | ("BAR".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), "2".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()) |
| 238 | ] |
| 239 | ); |
| 240 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 241 | cmd.positional_argsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#positional_args., |
| 242 | [ |
| 243 | "command", "BAZ=3", "arg", "FOOBAR=4", "command", "arg", "BARBAZ=5" |
| 244 | ] |
| 245 | ); |
| 246 | } |
| 247 | |
| 248 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 249 | fn single_env_var_declarationrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/single_env_var_declaration().() { |
| 250 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "FOO=1", "command"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 251 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cmd.env_var_listrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#env_var_list., vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![("FOO".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), "1".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())]); |
| 252 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cmd.positional_argsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#positional_args., ["command"]); |
| 253 | } |
| 254 | |
| 255 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 256 | fn shorthand_with_argumentrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/shorthand_with_argument().() { |
| 257 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "-u", "ferris"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 258 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cmd.userrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#user..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("ferris")); |
| 259 | } |
| 260 | |
| 261 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 262 | fn shorthand_with_direct_argumentrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/shorthand_with_direct_argument().() { |
| 263 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "-uferris"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 264 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cmd.userrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#user..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("ferris")); |
| 265 | } |
| 266 | |
| 267 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 268 | fn shorthand_without_argumentrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/shorthand_without_argument().() { |
| 269 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "-u"]); |
| 270 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()) |
| 271 | } |
| 272 | |
| 273 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 274 | fn non_interactiverust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/non_interactive().() { |
| 275 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "-n"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 276 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.non_interactiverust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#non_interactive.); |
| 277 | |
| 278 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "--non-interactive"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 279 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.non_interactiverust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#non_interactive.); |
| 280 | } |
| 281 | |
| 282 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 283 | fn stdinrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/stdin().() { |
| 284 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "-S"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 285 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.stdinrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#stdin.); |
| 286 | |
| 287 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "--stdin"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 288 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.stdinrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#stdin.); |
| 289 | } |
| 290 | |
| 291 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 292 | fn shellrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/shell().() { |
| 293 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "-s"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 294 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.shellrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#shell.); |
| 295 | |
| 296 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "--shell"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 297 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.shellrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#shell.); |
| 298 | } |
| 299 | |
| 300 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 301 | fn directoryrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/directory().() { |
| 302 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "-D/some/path"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 303 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cmd.chdirrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#chdir., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(SudoPathrust-analyzer cargo sudo-rs 0.2.14 common/path/SudoPath#::fromrust-analyzer cargo sudo-rs 0.2.14 common/path/impl#[SudoPath][`From<&str>`]from().("/some/path"))); |
| 304 | |
| 305 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "--chdir", "/some/path"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 306 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cmd.chdirrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#chdir., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(SudoPathrust-analyzer cargo sudo-rs 0.2.14 common/path/SudoPath#::fromrust-analyzer cargo sudo-rs 0.2.14 common/path/impl#[SudoPath][`From<&str>`]from().("/some/path"))); |
| 307 | |
| 308 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "--chdir=/some/path"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 309 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cmd.chdirrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#chdir., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(SudoPathrust-analyzer cargo sudo-rs 0.2.14 common/path/SudoPath#::fromrust-analyzer cargo sudo-rs 0.2.14 common/path/impl#[SudoPath][`From<&str>`]from().("/some/path"))); |
| 310 | } |
| 311 | |
| 312 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 313 | fn grouprust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/group().() { |
| 314 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "-grustaceans"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 315 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cmd.grouprust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#group..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("rustaceans")); |
| 316 | |
| 317 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "--group", "rustaceans"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 318 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cmd.grouprust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#group..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("rustaceans")); |
| 319 | |
| 320 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "--group=rustaceans"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 321 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cmd.grouprust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#group..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("rustaceans")); |
| 322 | } |
| 323 | |
| 324 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 325 | fn other_userrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/other_user().() { |
| 326 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "-Uferris"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 327 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cmd.other_userrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#other_user..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("ferris")); |
| 328 | |
| 329 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "--other-user", "ferris"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 330 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cmd.other_userrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#other_user..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("ferris")); |
| 331 | |
| 332 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "--other-user=ferris"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 333 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cmd.other_userrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#other_user..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("ferris")); |
| 334 | } |
| 335 | |
| 336 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 337 | fn invalid_optionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/invalid_option().() { |
| 338 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "--wololo"]); |
| 339 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()) |
| 340 | } |
| 341 | |
| 342 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 343 | fn invalid_option_with_argumentrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/invalid_option_with_argument().() { |
| 344 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "--background=yes"]); |
| 345 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()) |
| 346 | } |
| 347 | |
| 348 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 349 | fn no_argument_providedrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/no_argument_provided().() { |
| 350 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "--user"]); |
| 351 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()) |
| 352 | } |
| 353 | |
| 354 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 355 | fn loginrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/login().() { |
| 356 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "-i"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 357 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.loginrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#login.); |
| 358 | |
| 359 | let cmd = SudoOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoOptions]try_parse_from().(["sudo", "--login"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 360 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.loginrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoOptions#login.); |
| 361 | } |
| 362 | |
| 363 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 364 | fn editrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/edit().() { |
| 365 | let cmd = SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(["sudo", "-e", "filepath"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 366 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.is_editrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]is_edit().()); |
| 367 | |
| 368 | let cmd = SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(["sudo", "--edit", "filepath"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 369 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.is_editrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]is_edit().()); |
| 370 | |
| 371 | let cmd = SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(["sudoedit", "filepath"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 372 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.is_editrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]is_edit().()); |
| 373 | |
| 374 | let res = SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(["sudo", "--edit"]); |
| 375 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(res.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 376 | |
| 377 | let res = SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(["sudoedit", "--edit", "filepath"]); |
| 378 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(res.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 379 | } |
| 380 | |
| 381 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 382 | fn helprust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/help().() { |
| 383 | let cmd = SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(["sudo", "-h"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 384 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.is_helprust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]is_help().()); |
| 385 | |
| 386 | let cmd = SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(["sudo", "-zh"]); |
| 387 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 388 | |
| 389 | let cmd = SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(["sudo", "--help"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 390 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.is_helprust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]is_help().()); |
| 391 | } |
| 392 | |
| 393 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 394 | fn conflicting_argumentsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/conflicting_arguments().() { |
| 395 | let cmd = SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(["sudo", "-K", "-k"]); |
| 396 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 397 | |
| 398 | let cmd = SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(["sudo", "--remove-timestamp", "--reset-timestamp"]); |
| 399 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 400 | |
| 401 | let cmd = SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(["sudo", "-K"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 402 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.is_remove_timestamprust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]is_remove_timestamp().()); |
| 403 | |
| 404 | let cmd = SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(["sudo", "-k"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 405 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.is_reset_timestamprust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]is_reset_timestamp().()); |
| 406 | } |
| 407 | |
| 408 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 409 | fn listrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/list().() { |
| 410 | let valid: &[&[_]] = &[ |
| 411 | &["sudo", "--list"], |
| 412 | &["sudo", "-l"], |
| 413 | &["sudo", "-l", "true"], |
| 414 | &["sudo", "-l", "-U", "ferris"], |
| 415 | &["sudo", "-l", "-U", "ferris", "true"], |
| 416 | &["sudo", "-l", "-u", "ferris", "true"], |
| 417 | &["sudo", "-l", "-u", "ferris", "-U", "root", "true"], |
| 418 | ]; |
| 419 | |
| 420 | for args in valid { |
| 421 | let cmd = SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(args.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().copiedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#copied().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 422 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.is_listrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]is_list().()); |
| 423 | } |
| 424 | |
| 425 | let invalid: &[&[_]] = &[ |
| 426 | &["sudo", "-l", "-u", "ferris"], |
| 427 | &["sudo", "-l", "-u", "ferris", "-U", "root"], |
| 428 | ]; |
| 429 | |
| 430 | for args in invalid { |
| 431 | let res = SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(args.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().copiedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#copied().()); |
| 432 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(res.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()) |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 437 | fn validaterust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/validate().() { |
| 438 | let cmd = SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(["sudo", "-v"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 439 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.is_validaterust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]is_validate().()); |
| 440 | |
| 441 | let cmd = SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(["sudo", "--validate"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 442 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.is_validaterust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]is_validate().()); |
| 443 | } |
| 444 | |
| 445 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 446 | fn versionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/version().() { |
| 447 | let cmd = SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(["sudo", "-V"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 448 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.is_versionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]is_version().()); |
| 449 | |
| 450 | let cmd = SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(["sudo", "--version"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 451 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cmd.is_versionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]is_version().()); |
| 452 | } |
| 453 | |
| 454 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 455 | fn run_reset_timestamp_commandrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/run_reset_timestamp_command().() { |
| 456 | let action = SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(["sudo", "-k", "true"]) |
| 457 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 458 | .try_into_runrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]try_into_run().() |
| 459 | .okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().() |
| 460 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 461 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(["true"], action.positional_argsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoRunOptions#positional_args..as_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]as_slice().()); |
| 462 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(action.reset_timestamprust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoRunOptions#reset_timestamp.); |
| 463 | } |
| 464 | |
| 465 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 466 | fn run_reset_timestamp_loginrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/run_reset_timestamp_login().() { |
| 467 | let action = SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(["sudo", "-k", "-i"]) |
| 468 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 469 | .try_into_runrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]try_into_run().() |
| 470 | .okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().() |
| 471 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 472 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(action.positional_argsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoRunOptions#positional_args..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().()); |
| 473 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(action.reset_timestamprust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoRunOptions#reset_timestamp.); |
| 474 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(action.loginrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoRunOptions#login.); |
| 475 | } |
| 476 | |
| 477 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 478 | fn run_reset_timestamp_shellrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/run_reset_timestamp_shell().() { |
| 479 | let action = SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(["sudo", "-k", "-s"]) |
| 480 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 481 | .try_into_runrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]try_into_run().() |
| 482 | .okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().() |
| 483 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 484 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(action.positional_argsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoRunOptions#positional_args..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().()); |
| 485 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(action.reset_timestamprust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoRunOptions#reset_timestamp.); |
| 486 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(action.shellrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoRunOptions#shell.); |
| 487 | } |
| 488 | |
| 489 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 490 | fn run_no_commandrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/run_no_command().() { |
| 491 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(["sudo", "-u", "root"]).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 492 | } |
| 493 | |
| 494 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 495 | fn run_loginrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/run_login().() { |
| 496 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(["sudo", "-i"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().is_runrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]is_run().()); |
| 497 | } |
| 498 | |
| 499 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 500 | fn run_shellrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/run_shell().() { |
| 501 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(["sudo", "-s"]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().is_runrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]is_run().()); |
| 502 | } |