Skip to content

Commit 7ac0718

Browse files
committed
fix broken integration test
see the comment in the test; it now tests what it purports to test for
1 parent 82b496e commit 7ac0718

File tree

1 file changed

+12
-10
lines changed
  • test-framework/sudo-compliance-tests/src/visudo/sudoers

1 file changed

+12
-10
lines changed

test-framework/sudo-compliance-tests/src/visudo/sudoers/editor.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,17 @@ fn editors_must_be_specified_by_absolute_path() {
9595

9696
#[test]
9797
fn on_invalid_editor_does_not_falls_back_to_configured_default_value() {
98-
let env = Env("Defaults editor=true")
98+
let expected = "configured editor was called";
99+
//NOTE: ogsudo DOES fallback to the default editor if a syntax error is
100+
//made here, e.g. "Defaults editor=true" will simply not set the "editor" value.
101+
//This is surprising.
102+
let env = Env("Defaults editor=/bin/no-editor")
99103
.file(
100104
DEFAULT_EDITOR,
101-
TextFile(
105+
TextFile(format!(
102106
"#!/bin/sh
103-
rm -f {LOGS_PATH}",
104-
)
107+
echo '{expected}' >> {LOGS_PATH}"
108+
))
105109
.chmod(CHMOD_EXEC),
106110
)
107111
.build();
@@ -111,11 +115,9 @@ rm -f {LOGS_PATH}",
111115
.output(&env)
112116
.assert_success();
113117

114-
Command::new("visudo").output(&env).assert_success();
118+
Command::new("visudo").output(&env).assert_exit_code(1);
115119

116-
Command::new("sh")
117-
.arg("-c")
118-
.arg(format!("test -f {LOGS_PATH}"))
119-
.output(&env)
120-
.assert_success();
120+
let actual = Command::new("cat").arg(LOGS_PATH).output(&env).stdout();
121+
122+
assert_ne!(expected, actual);
121123
}

0 commit comments

Comments
 (0)