File: s3-request-bucket-create.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 (144 lines) | stat: -rw-r--r-- 5,212 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!perl

use strict;
use warnings;

use FindBin;
use lib $FindBin::Bin;

BEGIN { require 'test-helper-s3-request.pl' }

plan tests => 11;

sub h ($) {
	+{ 'Content-Length' => ignore, 'Content-Type' => ignore, %{ $_[0] } };
}

behaves_like_net_amazon_s3_request 'create bucket' => (
	request_class   => 'Net::Amazon::S3::Operation::Bucket::Create::Request',
	with_bucket     => 'some-bucket',

	expect_request_method   => 'PUT',
	expect_request_uri      => 'https://some-bucket.s3.amazonaws.com/',
	expect_request_headers  => h { },
	expect_request_content  => '',
);

behaves_like_net_amazon_s3_request 'create bucket with deprecated acl_short' => (
	request_class   => 'Net::Amazon::S3::Operation::Bucket::Create::Request',
	with_bucket     => 'some-bucket',
	with_acl_short  => 'private',

	expect_request_method   => 'PUT',
	expect_request_uri      => 'https://some-bucket.s3.amazonaws.com/',
	expect_request_headers  => h { 'x-amz-acl' => 'private' },
	expect_request_content  => '',
);

behaves_like_net_amazon_s3_request 'create bucket with canned acl' => (
	request_class   => 'Net::Amazon::S3::Operation::Bucket::Create::Request',
	with_bucket     => 'some-bucket',
	with_acl        => Net::Amazon::S3::ACL::Canned->PRIVATE,

	expect_request_method   => 'PUT',
	expect_request_uri      => 'https://some-bucket.s3.amazonaws.com/',
	expect_request_headers  => h { 'x-amz-acl' => 'private' },
	expect_request_content  => '',
);

behaves_like_net_amazon_s3_request 'create bucket with canned acl coercion' => (
	request_class   => 'Net::Amazon::S3::Operation::Bucket::Create::Request',
	with_bucket     => 'some-bucket',
	with_acl        => 'private',

	expect_request_method   => 'PUT',
	expect_request_uri      => 'https://some-bucket.s3.amazonaws.com/',
	expect_request_headers  => h { 'x-amz-acl' => 'private' },
	expect_request_content  => '',
);

behaves_like_net_amazon_s3_request 'create bucket with exact acl' => (
	request_class   => 'Net::Amazon::S3::Operation::Bucket::Create::Request',
	with_bucket     => 'some-bucket',
	with_acl        => Net::Amazon::S3::ACL::Set->new
		->grant_read (id => '123', id => '234')
		->grant_write (id => '345')
		,

	expect_request_method   => 'PUT',
	expect_request_uri      => 'https://some-bucket.s3.amazonaws.com/',
	expect_request_headers  => h {
		'x-amz-grant-read'  => 'id="123", id="234"',
		'x-amz-grant-write' => 'id="345"',
	},
	expect_request_content  => '',
);

behaves_like_net_amazon_s3_request 'create bucket in region' => (
	request_class   => 'Net::Amazon::S3::Operation::Bucket::Create::Request',
	with_bucket     => 'some-bucket',
	with_location_constraint => 'ca-central-1',

	expect_request_method   => 'PUT',
	expect_request_uri      => 'https://some-bucket.s3.amazonaws.com/',
	expect_request_headers  => h { },
	expect_request_content  => fixture ('request::bucket_create_ca_central_1')->{content},
);

behaves_like_net_amazon_s3_request 'create bucket in region with deprecated acl_short' => (
	request_class   => 'Net::Amazon::S3::Operation::Bucket::Create::Request',
	with_bucket     => 'some-bucket',
	with_acl_short  => 'private',
	with_location_constraint => 'ca-central-1',

	expect_request_method   => 'PUT',
	expect_request_uri      => 'https://some-bucket.s3.amazonaws.com/',
	expect_request_headers  => h { 'x-amz-acl' => 'private' },
	expect_request_content  => fixture ('request::bucket_create_ca_central_1')->{content},
);

behaves_like_net_amazon_s3_request 'create bucket in region with canned acl' => (
	request_class   => 'Net::Amazon::S3::Operation::Bucket::Create::Request',
	with_bucket     => 'some-bucket',
	with_acl        => Net::Amazon::S3::ACL::Canned->PRIVATE,
	with_location_constraint => 'ca-central-1',

	expect_request_method   => 'PUT',
	expect_request_uri      => 'https://some-bucket.s3.amazonaws.com/',
	expect_request_headers  => h { 'x-amz-acl' => 'private' },
	expect_request_content  => fixture ('request::bucket_create_ca_central_1')->{content},
);

behaves_like_net_amazon_s3_request 'create bucket in region with canned acl coercion' => (
	request_class   => 'Net::Amazon::S3::Operation::Bucket::Create::Request',
	with_bucket     => 'some-bucket',
	with_acl_short  => 'private',
	with_location_constraint => 'ca-central-1',

	expect_request_method   => 'PUT',
	expect_request_uri      => 'https://some-bucket.s3.amazonaws.com/',
	expect_request_headers  => h { 'x-amz-acl' => 'private' },
	expect_request_content  => fixture ('request::bucket_create_ca_central_1')->{content},
);

behaves_like_net_amazon_s3_request 'create bucket in region with exact acl' => (
	request_class   => 'Net::Amazon::S3::Operation::Bucket::Create::Request',
	with_bucket     => 'some-bucket',
	with_acl        => Net::Amazon::S3::ACL::Set->new
		->grant_read (id => '123', id => '234')
		->grant_write (id => '345')
		,
	with_location_constraint => 'ca-central-1',

	expect_request_method   => 'PUT',
	expect_request_uri      => 'https://some-bucket.s3.amazonaws.com/',
	expect_request_headers  => h {
		'x-amz-grant-read'  => 'id="123", id="234"',
		'x-amz-grant-write' => 'id="345"',
	},
	expect_request_content  => fixture ('request::bucket_create_ca_central_1')->{content},
);

had_no_warnings;

done_testing;