Skip to content

Commit ca66ab5

Browse files
committed
Add spec for stricter exec_cmd checks
1 parent 712daa4 commit ca66ab5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

spec/gitlab_shell_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,15 @@
236236
Kernel.should_receive(:exec).with(kind_of(Hash), 1, 2, unsetenv_others: true).once
237237
shell.send :exec_cmd, 1, 2
238238
end
239+
240+
it "refuses to execute a lone non-array argument" do
241+
expect { shell.send :exec_cmd, 1 }.to raise_error(GitlabShell::DisallowedCommandError)
242+
end
243+
244+
it "allows one argument if it is an array" do
245+
Kernel.should_receive(:exec).with(kind_of(Hash), [1, 2], unsetenv_others: true).once
246+
shell.send :exec_cmd, [1, 2]
247+
end
239248
end
240249

241250
describe :api do

0 commit comments

Comments
 (0)