Skip to content

Commit

Permalink
add test for AWS::S3::Signer, sporadically failing
Browse files Browse the repository at this point in the history
this reveals (suspected) hash or load order bugs as, even though we
pass a method and content to the constructor, when we call the
content_type attribute sometimes it is defined and sometimes it is
not. run the test multiple times and you will see this behaviour:

	/Volumes/code_partition/AWS-S3 > prove -Ilib t/030_signer.t
	t/030_signer.t .. ok
	All tests successful.
	Files=1, Tests=7,  0 wallclock secs ( 0.02 usr  0.00 sys +  0.30 cusr  0.02 csys =  0.34 CPU)
	Result: PASS

	[leejohnson@lees-macbook-air J1 C2783 10:49:52 * lee/up_test_coverage]
	/Volumes/code_partition/AWS-S3 > prove -Ilib t/030_signer.t
	t/030_signer.t .. 1/?
	#   Failed test 'content_type'
	#   at t/030_signer.t line 32.
	#          got: ''
	#     expected: 'text/plain'
	# Looks like you failed 1 test of 7.
	t/030_signer.t .. Dubious, test returned 1 (wstat 256, 0x100)
	Failed 1/7 subtests

	Test Summary Report
	-------------------
	t/030_signer.t (Wstat: 256 Tests: 7 Failed: 1)
	  Failed test:  4
	  Non-zero exit status: 1
	Files=1, Tests=7,  0 wallclock secs ( 0.02 usr  0.01 sys +  0.37 cusr  0.02 csys =  0.42 CPU)
	Result: FAIL

sometimes the test will pass but raise an uninitialized variable
warning, sometimes that will be absent. so there are clear hash or
load ordering bugs here (tested with perl 5.18)
  • Loading branch information
leejo committed Jul 24, 2014
1 parent 63410a3 commit 96b6b1b
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions t/030_signer.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!perl

use strict;
use warnings;

use Test::More 'no_plan';
use FindBin qw/ $Bin /;

use Carp 'confess';
$SIG{__DIE__} = \&confess;

use_ok('AWS::S3');

my $s3 = AWS::S3->new(
access_key_id => $ENV{AWS_ACCESS_KEY_ID} // 'foo',
secret_access_key => $ENV{AWS_SECRET_ACCESS_KEY} // 'bar',
endpoint => $ENV{AWS_ENDPOINT} // 'baz',
);

use_ok('AWS::S3::Signer');

isa_ok(
my $signer = AWS::S3::Signer->new(
method => 'HEAD',
s3 => $s3,
uri => "http://baz/boz",
content => \'hello world',
),
'AWS::S3::Signer'
);

is( $signer->content_type,'text/plain','content_type' );
is( $signer->method,'HEAD','method' );
is( ${ $signer->content },'hello world','content' );

like( $signer->auth_header,qr/AWS foo:.{28}/,'auth_header' );

0 comments on commit 96b6b1b

Please sign in to comment.