File: 006Broken.t

package info (click to toggle)
libnet-ssh-authorizedkeysfile-perl 0.18-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 228 kB
  • sloc: perl: 596; makefile: 2
file content (59 lines) | stat: -rw-r--r-- 1,837 bytes parent folder | download | duplicates (3)
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
######################################################################
# Test suite for Net::SSH::AuthorizedKeysFile
# by Mike Schilli <m@perlmeister.com>
######################################################################

use warnings;
use strict;
use File::Temp qw(tempfile);

use Log::Log4perl qw(:easy);
#Log::Log4perl->easy_init($DEBUG);

use Test::More tests => 10;
BEGIN { use_ok('Net::SSH::AuthorizedKeysFile') };

my $tdir = "t";
$tdir = "../t" unless -d $tdir;
my $cdir = "$tdir/canned";

use Net::SSH::AuthorizedKeysFile;

my $ak = Net::SSH::AuthorizedKeysFile->new(
    file => "$cdir/ak-broken.txt",
);
my $rc = $ak->read();
is($rc, 1, "read ok on broken authorized_keys (no strict)");

$ak = Net::SSH::AuthorizedKeysFile->new(
    file   => "$cdir/ak-broken.txt",
    abort_on_error => 1,
);
$rc = $ak->read();
is($rc, undef, "read fail on broken authorized_keys (strict)");
is($ak->error(), "Line 1: [ene mene meck] rejected by all parsers",
                 "error message");

$ak = Net::SSH::AuthorizedKeysFile->new(file => "$cdir/ak.txt");
$rc = $ak->read();

is($rc, 1, "read ok on ok authorized_keys");

$ak = Net::SSH::AuthorizedKeysFile->new(file => "$cdir/ak-broken.txt",
                                        strict => 1,
                                        abort_on_error => 1);
$rc = $ak->read();

is($rc, undef, "read fail on broken authorized_keys");
is($ak->error(), "Line 1: [ene mene meck] rejected by all parsers",
                 "error message");

$ak = Net::SSH::AuthorizedKey->parse( 
    'from="bing.bang.boom",no-pty,,, 1024 35 372');

my $options = $ak->options();

is($options->{from}, "bing.bang.boom", "options with trailing commas");
is($options->{"no-pty"}, 1, "options with trailing commas");
is(join("-", sort keys %$options), "from-no-pty", 
    "options with trailing commas");