]> Dogcows Code - chaz/groupsecret/blob - t/02-file.t
skip tests which call out to ssh-keygen for now
[chaz/groupsecret] / t / 02-file.t
1 #!/usr/bin/env perl
2
3 use warnings;
4 use strict;
5
6 use FindBin qw($Bin);
7
8 use Test::More tests => 7;
9
10 use App::GroupSecret::File;
11
12 my $nonexistent = App::GroupSecret::File->new("$Bin/keyfiles/nonexistent.yml");
13
14 is_deeply $nonexistent->info, {
15 version => 1,
16 keys => {},
17 secret => undef,
18 }, 'newly initialized file is empty';
19
20 my $empty = App::GroupSecret::File->new("$Bin/keyfiles/empty.yml");
21
22 is_deeply $empty->info, {
23 version => 1,
24 keys => {},
25 secret => undef,
26 }, 'empty file info matches';
27
28 is $empty->secret, undef, 'empty secret is undef';
29 is $empty->version, 1, 'empty version is one';
30
31 SKIP: {
32 skip 'requires ssh-keygen', 2;
33
34 my $key1 = $empty->add_key("$Bin/keys/foo_rsa.pub");
35 is_deeply $key1, {
36 comment => 'foo',
37 filename => 'foo_rsa.pub',
38 secret_passphrase => undef,
39 type => 'rsa',
40 }, 'add_key in scalar context works';
41
42 $empty->delete_key('89b3fb766cf9568ea81adfba1cba7d05');
43 is_deeply $empty->keys, {}, 'file is empty again after delete_key';
44 };
45
46 my $basic = App::GroupSecret::File->new("$Bin/keyfiles/basic.yml");
47
48 is_deeply $basic->keys, {
49 '89b3fb766cf9568ea81adfba1cba7d05' => {
50 comment => 'foo',
51 filename => 'foo_rsa.pub',
52 secret_passphrase => undef,
53 type => 'rsa',
54 },
55 }, 'keys accessor works';
56
This page took 0.034356 seconds and 4 git commands to generate.