5 use Test::More tests => 14; # last test to print
10 $module = 'Net::Amazon::S3::Policy';
15 my $expiration = '1220292602';
16 my $policy = $module->new({expiration => $expiration});
18 ok($policy, 'new with expiration time');
19 isa_ok($policy, $module);
20 is($policy->expiration(), '2008-09-01T18:10:02.000Z',
26 q( provaxxx starts-with ciao ),
27 q( 0 <= something <= 123312391 ),
29 q( anything2 starts_with ),
30 q( anything2 starts_with blah ),
33 my $conditions = $policy->conditions();
34 ok($conditions, 'conditions exists');
35 is(scalar(@$conditions), 6, 'all conditions added');
39 [qw( eq $prova ciao )],
40 [qw( starts-with $provaxxx ciao )],
41 [qw( something 0 123312391 )],
42 [qw( starts-with $anything ), ''],
43 [qw( starts-with $anything2 ), ''],
44 [qw( starts-with $anything2 blah )],
50 '{"expiration":"2008-09-01T18:10:02.000Z","conditions":[["eq","$prova","ciao"],["starts-with","$provaxxx","ciao"],["something","0","123312391"],["starts-with","$anything",""],["starts-with","$anything2",""],["starts-with","$anything2","blah"]]}';
51 is($policy->stringify(), $expected_json, 'JSON generation');
56 '{"expiration":"2008-09-01T18:10:02.000Z","conditions":[["eq","$prova","ciao"],["starts-with","$provaxxx","ciao"],["something","0","123312391"],["starts-with","$anything",""],["starts-with","$anything2",""],["starts-with","$anything2","blah"],{"what":"this"}]}';
58 my $policy = Net::Amazon::S3::Policy->new(json => $json);
59 ok($policy, 'new with expiration time');
60 isa_ok($policy, $module);
61 is($policy->expiration(), '2008-09-01T18:10:02.000Z',
64 my $conditions = $policy->conditions();
65 ok($conditions, 'conditions exists');
66 is(scalar(@$conditions), 7, 'all conditions present');
70 [qw( eq $prova ciao )],
71 [qw( starts-with $provaxxx ciao )],
72 [qw( something 0 123312391 )],
73 [qw( starts-with $anything ), ''],
74 [qw( starts-with $anything2 ), ''],
75 [qw( starts-with $anything2 blah )],
76 [qw( eq $what this )],