1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
use Test::Command tests => (3 * 8);
sub test_fc {
my (%conf) = @_;
$ENV{'SSH_ORIGINAL_COMMAND'} = $conf{'in'};
my $ret = $conf{'ret'} // 0;
my $out = ($conf{'out'} ? $conf{'out'} . "\n" : q{});
my $err = ($conf{'err'} ? $conf{'err'} . "\n" : q{});
my $cmd = Test::Command->new(cmd => 'bin/ssh-forcecommand t/config');
$cmd->stdout_is_eq($out);
$cmd->stderr_is_eq($err);
if ($ret == 0) {
$cmd->exit_is_num(0);
}
else {
$cmd->exit_isnt_num(0);
}
}
test_fc(
in => undef,
ret => 1,
err => 'No command',
);
test_fc(
in => 'invalid',
ret => 1,
err => 'Unknown command: invalid',
);
test_fc(
in => 'simple',
out => 'foo',
);
test_fc(
in => 'other',
out => 'bar',
);
test_fc(
in => 'nospace',
out => 'nospace!',
);
test_fc(
in => 'much space',
out => 'dude, lots of space',
);
test_fc(
in => 'spaceout',
out => 'space is beautiful',
);
test_fc(
in => 'equal',
out => 'foo = bar a=b',
);
|