File: request.t

package info (click to toggle)
libnet-amazon-s3-perl 0.991-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,620 kB
  • sloc: perl: 9,906; makefile: 20
file content (85 lines) | stat: -rw-r--r-- 1,808 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85

use strict;
use warnings;

use Test::More tests => 16;
use Test::Warnings qw[ :no_end_test had_no_warnings ];

use Moose::Meta::Class;

use Net::Amazon::S3;

use Shared::Examples::Net::Amazon::S3::Request (
	qw[ expect_request_class ],
	qw[ expect_request_instance ],
);

my $request_class;

sub request_class {
	($request_class) = @_;

	expect_request_class $request_class;
}

sub request_path {
	my ($title, %params) = @_;

	my $request = expect_request_instance
		request_class => $request_class,
		(with_bucket => $params{with_bucket}) x exists $params{with_bucket},
		(with_key => $params{with_key}) x exists $params{with_key},
		;

	my $request_path = $request->_build_signed_request (
		method => 'GET',
		path => $request->_request_path,
	)->path;

	is
		$request_path,
		$params{expect},
		$title,
		;
}

request_class 'Net::Amazon::S3::Request::Service';

request_path 'service request should return empty path',
	expect      => '',
	;

request_class 'Net::Amazon::S3::Request::Bucket';

request_path 'bucket request',
	with_bucket => 'some-bucket',
	expect      => 'some-bucket/',
	;

request_class 'Net::Amazon::S3::Request::Object';

request_path 'object request with empty key',
	with_bucket => 'some-bucket',
	with_key    => '',
	expect      => 'some-bucket/',
	;

request_path 'object request should recognize leading slash',
	with_bucket => 'some-bucket',
	with_key    => '/some/key',
	expect      => 'some-bucket/some/key',
	;

request_path 'object request should sanitize key with slash sequences',
	with_bucket => 'some-bucket',
	with_key    => '//some///key',
	expect      =>'some-bucket/some/key',
	;

request_path 'object request should uri-escape key',
	with_bucket => 'some-bucket',
	with_key    => 'some/ %/key',
	expect      => 'some-bucket/some/%20%25/key',
	;

had_no_warnings;