fog-internet-archive 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +53 -0
- data/.travis.yml +16 -0
- data/Gemfile +3 -0
- data/README.md +6 -0
- data/Rakefile +19 -0
- data/fog-internet-archive.gemspec +32 -0
- data/lib/fog/bin/internet_archive.rb +32 -0
- data/lib/fog/internet_archive.rb +1 -0
- data/lib/fog/internet_archive/core.rb +291 -0
- data/lib/fog/internet_archive/models/storage/directories.rb +39 -0
- data/lib/fog/internet_archive/models/storage/directory.rb +105 -0
- data/lib/fog/internet_archive/models/storage/file.rb +254 -0
- data/lib/fog/internet_archive/models/storage/files.rb +119 -0
- data/lib/fog/internet_archive/models/storage/ia_attributes.rb +36 -0
- data/lib/fog/internet_archive/parsers/storage/access_control_list.rb +42 -0
- data/lib/fog/internet_archive/parsers/storage/complete_multipart_upload.rb +20 -0
- data/lib/fog/internet_archive/parsers/storage/copy_object.rb +18 -0
- data/lib/fog/internet_archive/parsers/storage/cors_configuration.rb +38 -0
- data/lib/fog/internet_archive/parsers/storage/delete_multiple_objects.rb +45 -0
- data/lib/fog/internet_archive/parsers/storage/get_bucket.rb +58 -0
- data/lib/fog/internet_archive/parsers/storage/get_bucket_lifecycle.rb +64 -0
- data/lib/fog/internet_archive/parsers/storage/get_bucket_location.rb +16 -0
- data/lib/fog/internet_archive/parsers/storage/get_bucket_logging.rb +36 -0
- data/lib/fog/internet_archive/parsers/storage/get_bucket_website.rb +22 -0
- data/lib/fog/internet_archive/parsers/storage/get_request_payment.rb +16 -0
- data/lib/fog/internet_archive/parsers/storage/get_service.rb +28 -0
- data/lib/fog/internet_archive/parsers/storage/initiate_multipart_upload.rb +20 -0
- data/lib/fog/internet_archive/parsers/storage/list_multipart_uploads.rb +52 -0
- data/lib/fog/internet_archive/parsers/storage/list_parts.rb +36 -0
- data/lib/fog/internet_archive/requests/storage/abort_multipart_upload.rb +27 -0
- data/lib/fog/internet_archive/requests/storage/acl_utils.rb +60 -0
- data/lib/fog/internet_archive/requests/storage/complete_multipart_upload.rb +46 -0
- data/lib/fog/internet_archive/requests/storage/copy_object.rb +77 -0
- data/lib/fog/internet_archive/requests/storage/cors_utils.rb +39 -0
- data/lib/fog/internet_archive/requests/storage/delete_bucket.rb +42 -0
- data/lib/fog/internet_archive/requests/storage/delete_bucket_cors.rb +26 -0
- data/lib/fog/internet_archive/requests/storage/delete_bucket_lifecycle.rb +26 -0
- data/lib/fog/internet_archive/requests/storage/delete_bucket_policy.rb +26 -0
- data/lib/fog/internet_archive/requests/storage/delete_bucket_website.rb +26 -0
- data/lib/fog/internet_archive/requests/storage/delete_multiple_objects.rb +88 -0
- data/lib/fog/internet_archive/requests/storage/delete_object.rb +46 -0
- data/lib/fog/internet_archive/requests/storage/get_bucket.rb +108 -0
- data/lib/fog/internet_archive/requests/storage/get_bucket_acl.rb +65 -0
- data/lib/fog/internet_archive/requests/storage/get_bucket_cors.rb +61 -0
- data/lib/fog/internet_archive/requests/storage/get_bucket_lifecycle.rb +35 -0
- data/lib/fog/internet_archive/requests/storage/get_bucket_location.rb +54 -0
- data/lib/fog/internet_archive/requests/storage/get_bucket_logging.rb +45 -0
- data/lib/fog/internet_archive/requests/storage/get_bucket_policy.rb +31 -0
- data/lib/fog/internet_archive/requests/storage/get_bucket_website.rb +38 -0
- data/lib/fog/internet_archive/requests/storage/get_object.rb +163 -0
- data/lib/fog/internet_archive/requests/storage/get_object_acl.rb +72 -0
- data/lib/fog/internet_archive/requests/storage/get_object_http_url.rb +48 -0
- data/lib/fog/internet_archive/requests/storage/get_object_https_url.rb +30 -0
- data/lib/fog/internet_archive/requests/storage/get_object_torrent.rb +45 -0
- data/lib/fog/internet_archive/requests/storage/get_object_url.rb +49 -0
- data/lib/fog/internet_archive/requests/storage/get_request_payment.rb +45 -0
- data/lib/fog/internet_archive/requests/storage/get_service.rb +50 -0
- data/lib/fog/internet_archive/requests/storage/head_object.rb +57 -0
- data/lib/fog/internet_archive/requests/storage/initiate_multipart_upload.rb +42 -0
- data/lib/fog/internet_archive/requests/storage/list_multipart_uploads.rb +52 -0
- data/lib/fog/internet_archive/requests/storage/list_parts.rb +53 -0
- data/lib/fog/internet_archive/requests/storage/post_object_hidden_fields.rb +36 -0
- data/lib/fog/internet_archive/requests/storage/put_bucket.rb +70 -0
- data/lib/fog/internet_archive/requests/storage/put_bucket_acl.rb +69 -0
- data/lib/fog/internet_archive/requests/storage/put_bucket_cors.rb +47 -0
- data/lib/fog/internet_archive/requests/storage/put_bucket_lifecycle.rb +76 -0
- data/lib/fog/internet_archive/requests/storage/put_bucket_logging.rb +79 -0
- data/lib/fog/internet_archive/requests/storage/put_bucket_policy.rb +25 -0
- data/lib/fog/internet_archive/requests/storage/put_bucket_website.rb +59 -0
- data/lib/fog/internet_archive/requests/storage/put_object.rb +94 -0
- data/lib/fog/internet_archive/requests/storage/put_object_acl.rb +73 -0
- data/lib/fog/internet_archive/requests/storage/put_object_url.rb +43 -0
- data/lib/fog/internet_archive/requests/storage/put_request_payment.rb +45 -0
- data/lib/fog/internet_archive/requests/storage/sync_clock.rb +24 -0
- data/lib/fog/internet_archive/requests/storage/upload_part.rb +39 -0
- data/lib/fog/internet_archive/signaturev4.rb +71 -0
- data/lib/fog/internet_archive/storage.rb +381 -0
- data/lib/fog/internet_archive/version.rb +5 -0
- data/tasks/bundler.rake +3 -0
- data/tasks/console.rake +17 -0
- data/tasks/lint.rake +3 -0
- data/tasks/test.rake +7 -0
- data/tests/helper.rb +36 -0
- data/tests/helpers/collection_helper.rb +88 -0
- data/tests/helpers/formats_helper.rb +98 -0
- data/tests/helpers/formats_helper_tests.rb +106 -0
- data/tests/helpers/mock_helper.rb +13 -0
- data/tests/helpers/model_helper.rb +29 -0
- data/tests/helpers/responds_to_helper.rb +11 -0
- data/tests/helpers/schema_validator_tests.rb +101 -0
- data/tests/helpers/succeeds_helper.rb +9 -0
- data/tests/internet_archive/models/storage/directory_tests.rb +42 -0
- data/tests/internet_archive/models/storage/file_tests.rb +61 -0
- data/tests/internet_archive/models/storage/files_tests.rb +60 -0
- data/tests/internet_archive/models/storage/url_tests.rb +28 -0
- data/tests/internet_archive/requests/storage/acl_utils_tests.rb +209 -0
- data/tests/internet_archive/requests/storage/bucket_tests.rb +324 -0
- data/tests/internet_archive/requests/storage/cors_utils_tests.rb +108 -0
- data/tests/internet_archive/requests/storage/multipart_upload_tests.rb +132 -0
- data/tests/internet_archive/requests/storage/object_tests.rb +166 -0
- data/tests/internet_archive/signaturev4_tests.rb +41 -0
- data/tests/internet_archive/signed_params_tests.rb +5 -0
- data/tests/lorem.txt +1 -0
- metadata +322 -0
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'fog/internet_archive/requests/storage/cors_utils'
|
2
|
+
|
3
|
+
Shindo.tests('Fog::Storage::InternetArchive | CORS utils', ["internetarchive"]) do
|
4
|
+
tests(".hash_to_cors") do
|
5
|
+
tests(".hash_to_cors({}) at xpath //CORSConfiguration").returns("", "has an empty CORSConfiguration") do
|
6
|
+
xml = Fog::Storage::InternetArchive.hash_to_cors({})
|
7
|
+
Nokogiri::XML(xml).xpath("//CORSConfiguration").first.content.chomp
|
8
|
+
end
|
9
|
+
|
10
|
+
tests(".hash_to_cors({}) at xpath //CORSConfiguration/CORSRule").returns(nil, "has no CORSRules") do
|
11
|
+
xml = Fog::Storage::InternetArchive.hash_to_cors({})
|
12
|
+
Nokogiri::XML(xml).xpath("//CORSConfiguration/CORSRule").first
|
13
|
+
end
|
14
|
+
|
15
|
+
cors = {
|
16
|
+
'CORSConfiguration' => [
|
17
|
+
{
|
18
|
+
'AllowedOrigin' => ['origin_123', 'origin_456'],
|
19
|
+
'AllowedMethod' => ['GET', 'POST'],
|
20
|
+
'AllowedHeader' => ['Accept', 'Content-Type'],
|
21
|
+
'ID' => 'blah-888',
|
22
|
+
'MaxAgeSeconds' => 2500,
|
23
|
+
'ExposeHeader' => ['x-some-header', 'x-other-header']
|
24
|
+
}
|
25
|
+
]
|
26
|
+
}
|
27
|
+
|
28
|
+
tests(".hash_to_cors(#{cors.inspect}) at xpath //CORSConfiguration/CORSRule/AllowedOrigin").returns("origin_123", "returns the CORSRule AllowedOrigin") do
|
29
|
+
xml = Fog::Storage::InternetArchive.hash_to_cors(cors)
|
30
|
+
Nokogiri::XML(xml).xpath("//CORSConfiguration/CORSRule/AllowedOrigin")[0].content
|
31
|
+
end
|
32
|
+
|
33
|
+
tests(".hash_to_cors(#{cors.inspect}) at xpath //CORSConfiguration/CORSRule/AllowedOrigin").returns("origin_456", "returns the CORSRule AllowedOrigin") do
|
34
|
+
xml = Fog::Storage::InternetArchive.hash_to_cors(cors)
|
35
|
+
Nokogiri::XML(xml).xpath("//CORSConfiguration/CORSRule/AllowedOrigin")[1].content
|
36
|
+
end
|
37
|
+
|
38
|
+
tests(".hash_to_cors(#{cors.inspect}) at xpath //CORSConfiguration/CORSRule/AllowedMethod").returns("GET", "returns the CORSRule AllowedMethod") do
|
39
|
+
xml = Fog::Storage::InternetArchive.hash_to_cors(cors)
|
40
|
+
Nokogiri::XML(xml).xpath("//CORSConfiguration/CORSRule/AllowedMethod")[0].content
|
41
|
+
end
|
42
|
+
|
43
|
+
tests(".hash_to_cors(#{cors.inspect}) at xpath //CORSConfiguration/CORSRule/AllowedMethod").returns("POST", "returns the CORSRule AllowedMethod") do
|
44
|
+
xml = Fog::Storage::InternetArchive.hash_to_cors(cors)
|
45
|
+
Nokogiri::XML(xml).xpath("//CORSConfiguration/CORSRule/AllowedMethod")[1].content
|
46
|
+
end
|
47
|
+
|
48
|
+
tests(".hash_to_cors(#{cors.inspect}) at xpath //CORSConfiguration/CORSRule/AllowedHeader").returns("Accept", "returns the CORSRule AllowedHeader") do
|
49
|
+
xml = Fog::Storage::InternetArchive.hash_to_cors(cors)
|
50
|
+
Nokogiri::XML(xml).xpath("//CORSConfiguration/CORSRule/AllowedHeader")[0].content
|
51
|
+
end
|
52
|
+
|
53
|
+
tests(".hash_to_cors(#{cors.inspect}) at xpath //CORSConfiguration/CORSRule/AllowedHeader").returns("Content-Type", "returns the CORSRule AllowedHeader") do
|
54
|
+
xml = Fog::Storage::InternetArchive.hash_to_cors(cors)
|
55
|
+
Nokogiri::XML(xml).xpath("//CORSConfiguration/CORSRule/AllowedHeader")[1].content
|
56
|
+
end
|
57
|
+
|
58
|
+
tests(".hash_to_cors(#{cors.inspect}) at xpath //CORSConfiguration/CORSRule/ID").returns("blah-888", "returns the CORSRule ID") do
|
59
|
+
xml = Fog::Storage::InternetArchive.hash_to_cors(cors)
|
60
|
+
Nokogiri::XML(xml).xpath("//CORSConfiguration/CORSRule/ID")[0].content
|
61
|
+
end
|
62
|
+
|
63
|
+
tests(".hash_to_cors(#{cors.inspect}) at xpath //CORSConfiguration/CORSRule/MaxAgeSeconds").returns("2500", "returns the CORSRule MaxAgeSeconds") do
|
64
|
+
xml = Fog::Storage::InternetArchive.hash_to_cors(cors)
|
65
|
+
Nokogiri::XML(xml).xpath("//CORSConfiguration/CORSRule/MaxAgeSeconds")[0].content
|
66
|
+
end
|
67
|
+
|
68
|
+
tests(".hash_to_cors(#{cors.inspect}) at xpath //CORSConfiguration/CORSRule/ExposeHeader").returns("x-some-header", "returns the CORSRule ExposeHeader") do
|
69
|
+
xml = Fog::Storage::InternetArchive.hash_to_cors(cors)
|
70
|
+
Nokogiri::XML(xml).xpath("//CORSConfiguration/CORSRule/ExposeHeader")[0].content
|
71
|
+
end
|
72
|
+
|
73
|
+
tests(".hash_to_cors(#{cors.inspect}) at xpath //CORSConfiguration/CORSRule/ExposeHeader").returns("x-other-header", "returns the CORSRule ExposeHeader") do
|
74
|
+
xml = Fog::Storage::InternetArchive.hash_to_cors(cors)
|
75
|
+
Nokogiri::XML(xml).xpath("//CORSConfiguration/CORSRule/ExposeHeader")[1].content
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
tests(".cors_to_hash") do
|
80
|
+
cors_xml = <<-XML
|
81
|
+
<CORSConfiguration>
|
82
|
+
<CORSRule>
|
83
|
+
<AllowedOrigin>http://www.example.com</AllowedOrigin>
|
84
|
+
<AllowedOrigin>http://www.example2.com</AllowedOrigin>
|
85
|
+
<AllowedHeader>Content-Length</AllowedHeader>
|
86
|
+
<AllowedHeader>X-Foobar</AllowedHeader>
|
87
|
+
<AllowedMethod>PUT</AllowedMethod>
|
88
|
+
<AllowedMethod>GET</AllowedMethod>
|
89
|
+
<MaxAgeSeconds>3000</MaxAgeSeconds>
|
90
|
+
<ExposeHeader>x-amz-server-side-encryption</ExposeHeader>
|
91
|
+
<ExposeHeader>x-amz-balls</ExposeHeader>
|
92
|
+
</CORSRule>
|
93
|
+
</CORSConfiguration>
|
94
|
+
XML
|
95
|
+
|
96
|
+
tests(".cors_to_hash(#{cors_xml.inspect})").returns({
|
97
|
+
"CORSConfiguration" => [{
|
98
|
+
"AllowedOrigin" => ["http://www.example.com", "http://www.example2.com"],
|
99
|
+
"AllowedHeader" => ["Content-Length", "X-Foobar"],
|
100
|
+
"AllowedMethod" => ["PUT", "GET"],
|
101
|
+
"MaxAgeSeconds" => 3000,
|
102
|
+
"ExposeHeader" => ["x-amz-server-side-encryption", "x-amz-balls"]
|
103
|
+
}]
|
104
|
+
}, 'returns hash of CORS XML') do
|
105
|
+
Fog::Storage::InternetArchive.cors_to_hash(cors_xml)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
Shindo.tests('Fog::Storage[:internetarchive] | multipart upload requests', ["internetarchive"]) do
|
2
|
+
|
3
|
+
@directory = Fog::Storage[:internetarchive].directories.create(:key => "fogmultipartuploadtests-#{rand(65536)}")
|
4
|
+
|
5
|
+
tests('success') do
|
6
|
+
|
7
|
+
@initiate_multipart_upload_format = {
|
8
|
+
'Bucket' => String,
|
9
|
+
'Key' => String,
|
10
|
+
'UploadId' => String
|
11
|
+
}
|
12
|
+
|
13
|
+
tests("#initiate_multipart_upload('#{@directory.identity}')", 'fog_multipart_upload').formats(@initiate_multipart_upload_format) do
|
14
|
+
pending if Fog.mocking?
|
15
|
+
data = Fog::Storage[:internetarchive].initiate_multipart_upload(@directory.identity, 'fog_multipart_upload').body
|
16
|
+
@upload_id = data['UploadId']
|
17
|
+
data
|
18
|
+
end
|
19
|
+
|
20
|
+
@list_multipart_uploads_format = {
|
21
|
+
'Bucket' => String,
|
22
|
+
'IsTruncated' => Fog::Boolean,
|
23
|
+
'MaxUploads' => Integer,
|
24
|
+
'KeyMarker' => NilClass,
|
25
|
+
'NextKeyMarker' => String,
|
26
|
+
'NextUploadIdMarker' => Fog::Nullable::String,
|
27
|
+
'Upload' => [{
|
28
|
+
'Initiated' => Time,
|
29
|
+
'Initiator' => {
|
30
|
+
'DisplayName' => String,
|
31
|
+
'ID' => String
|
32
|
+
},
|
33
|
+
'Key' => String,
|
34
|
+
'Owner' => {
|
35
|
+
'DisplayName' => String,
|
36
|
+
'ID' => String
|
37
|
+
},
|
38
|
+
'StorageClass' => String,
|
39
|
+
'UploadId' => String
|
40
|
+
}],
|
41
|
+
'UploadIdMarker' => NilClass,
|
42
|
+
}
|
43
|
+
|
44
|
+
tests("#list_multipart_uploads('#{@directory.identity})").formats(@list_multipart_uploads_format) do
|
45
|
+
pending if Fog.mocking?
|
46
|
+
Fog::Storage[:internetarchive].list_multipart_uploads(@directory.identity).body
|
47
|
+
end
|
48
|
+
|
49
|
+
@parts = []
|
50
|
+
|
51
|
+
tests("#upload_part('#{@directory.identity}', 'fog_multipart_upload', '#{@upload_id}', 1, ('x' * 6 * 1024 * 1024))").succeeds do
|
52
|
+
pending if Fog.mocking?
|
53
|
+
data = Fog::Storage[:internetarchive].upload_part(@directory.identity, 'fog_multipart_upload', @upload_id, 1, ('x' * 6 * 1024 * 1024))
|
54
|
+
@parts << data.headers['ETag']
|
55
|
+
end
|
56
|
+
|
57
|
+
@list_parts_format = {
|
58
|
+
'Bucket' => String,
|
59
|
+
'Initiator' => {
|
60
|
+
'DisplayName' => String,
|
61
|
+
'ID' => String
|
62
|
+
},
|
63
|
+
'IsTruncated' => Fog::Boolean,
|
64
|
+
'Key' => String,
|
65
|
+
'MaxParts' => Integer,
|
66
|
+
'NextPartNumberMarker' => String,
|
67
|
+
'Part' => [{
|
68
|
+
'ETag' => String,
|
69
|
+
'LastModified' => Time,
|
70
|
+
'PartNumber' => Integer,
|
71
|
+
'Size' => Integer
|
72
|
+
}],
|
73
|
+
'PartNumberMarker' => String,
|
74
|
+
'StorageClass' => String,
|
75
|
+
'UploadId' => String
|
76
|
+
}
|
77
|
+
|
78
|
+
tests("#list_parts('#{@directory.identity}', 'fog_multipart_upload', '#{@upload_id}')").formats(@list_parts_format) do
|
79
|
+
pending if Fog.mocking?
|
80
|
+
Fog::Storage[:internetarchive].list_parts(@directory.identity, 'fog_multipart_upload', @upload_id).body
|
81
|
+
end
|
82
|
+
|
83
|
+
if !Fog.mocking?
|
84
|
+
@parts << Fog::Storage[:internetarchive].upload_part(@directory.identity, 'fog_multipart_upload', @upload_id, 2, ('x' * 4 * 1024 * 1024)).headers['ETag']
|
85
|
+
end
|
86
|
+
|
87
|
+
@complete_multipart_upload_format = {
|
88
|
+
'Bucket' => String,
|
89
|
+
'ETag' => String,
|
90
|
+
'Key' => String,
|
91
|
+
'Location' => String
|
92
|
+
}
|
93
|
+
|
94
|
+
tests("#complete_multipart_upload('#{@directory.identity}', 'fog_multipart_upload', '#{@upload_id}', #{@parts.inspect})").formats(@complete_multipart_upload_format) do
|
95
|
+
pending if Fog.mocking?
|
96
|
+
Fog::Storage[:internetarchive].complete_multipart_upload(@directory.identity, 'fog_multipart_upload', @upload_id, @parts).body
|
97
|
+
end
|
98
|
+
|
99
|
+
tests("#get_object('#{@directory.identity}', 'fog_multipart_upload').body").succeeds do
|
100
|
+
pending if Fog.mocking?
|
101
|
+
Fog::Storage[:internetarchive].get_object(@directory.identity, 'fog_multipart_upload').body == ('x' * 10 * 1024 * 1024)
|
102
|
+
end
|
103
|
+
|
104
|
+
if !Fog.mocking?
|
105
|
+
@directory.files.new(:key => 'fog_multipart_upload').destroy
|
106
|
+
end
|
107
|
+
|
108
|
+
if !Fog.mocking?
|
109
|
+
@upload_id = Fog::Storage[:internetarchive].initiate_multipart_upload(@directory.identity, 'fog_multipart_abort').body['UploadId']
|
110
|
+
end
|
111
|
+
|
112
|
+
tests("#abort_multipart_upload('#{@directory.identity}', 'fog_multipart_abort', '#{@upload_id}')").succeeds do
|
113
|
+
pending if Fog.mocking?
|
114
|
+
Fog::Storage[:internetarchive].abort_multipart_upload(@directory.identity, 'fog_multipart_abort', @upload_id)
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
tests('failure') do
|
120
|
+
|
121
|
+
tests("initiate_multipart_upload")
|
122
|
+
tests("list_multipart_uploads")
|
123
|
+
tests("upload_part")
|
124
|
+
tests("list_parts")
|
125
|
+
tests("complete_multipart_upload")
|
126
|
+
tests("abort_multipart_upload")
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
@directory.destroy
|
131
|
+
|
132
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
Shindo.tests('InternetArchive::Storage | object requests', ['internetarchive']) do
|
2
|
+
@directory = Fog::Storage[:internetarchive].directories.create(:key => 'fogobjecttests-' + Time.now.to_i.to_s(32))
|
3
|
+
@ia_owner = Fog::Storage[:internetarchive].get_bucket_acl(@directory.key).body['Owner']
|
4
|
+
|
5
|
+
tests('success') do
|
6
|
+
|
7
|
+
@multiple_delete_format = {
|
8
|
+
'DeleteResult' => [{
|
9
|
+
'Deleted' => {
|
10
|
+
'Key' => String
|
11
|
+
}
|
12
|
+
}]
|
13
|
+
}
|
14
|
+
|
15
|
+
tests("#put_object('#{@directory.identity}', 'fog_object', lorem_file)").succeeds do
|
16
|
+
Fog::Storage[:internetarchive].put_object(@directory.identity, 'fog_object', lorem_file)
|
17
|
+
end
|
18
|
+
|
19
|
+
tests("#copy_object('#{@directory.identity}', 'fog_object', '#{@directory.identity}', 'fog_other_object')").succeeds do
|
20
|
+
Fog::Storage[:internetarchive].copy_object(@directory.identity, 'fog_object', @directory.identity, 'fog_other_object')
|
21
|
+
end
|
22
|
+
|
23
|
+
@directory.files.get('fog_other_object').destroy
|
24
|
+
|
25
|
+
tests("#get_object('#{@directory.identity}', 'fog_object')").returns(lorem_file.read) do
|
26
|
+
Fog::Storage[:internetarchive].get_object(@directory.identity, 'fog_object').body
|
27
|
+
end
|
28
|
+
|
29
|
+
tests("#get_object('#{@directory.identity}', 'fog_object', &block)").returns(lorem_file.read) do
|
30
|
+
data = ''
|
31
|
+
Fog::Storage[:internetarchive].get_object(@directory.identity, 'fog_object') do |chunk, remaining_bytes, total_bytes|
|
32
|
+
data << chunk
|
33
|
+
end
|
34
|
+
data
|
35
|
+
end
|
36
|
+
|
37
|
+
tests("#get_object('#{@directory.identity}', 'fog_object', {'Range' => 'bytes=0-20'})").returns(lorem_file.read[0..20]) do
|
38
|
+
Fog::Storage[:internetarchive].get_object(@directory.identity, 'fog_object', {'Range' => 'bytes=0-20'}).body
|
39
|
+
end
|
40
|
+
|
41
|
+
tests("#get_object('#{@directory.identity}', 'fog_object', {'Range' => 'bytes=0-0'})").returns(lorem_file.read[0..0]) do
|
42
|
+
Fog::Storage[:internetarchive].get_object(@directory.identity, 'fog_object', {'Range' => 'bytes=0-0'}).body
|
43
|
+
end
|
44
|
+
|
45
|
+
tests("#head_object('#{@directory.identity}', 'fog_object')").succeeds do
|
46
|
+
Fog::Storage[:internetarchive].head_object(@directory.identity, 'fog_object')
|
47
|
+
end
|
48
|
+
|
49
|
+
tests("#put_object_acl('#{@directory.identity}', 'fog_object', 'private')").succeeds do
|
50
|
+
Fog::Storage[:internetarchive].put_object_acl(@directory.identity, 'fog_object', 'private')
|
51
|
+
end
|
52
|
+
|
53
|
+
acl = {
|
54
|
+
'Owner' => @ia_owner,
|
55
|
+
'AccessControlList' => [
|
56
|
+
{
|
57
|
+
'Grantee' => @ia_owner,
|
58
|
+
'Permission' => "FULL_CONTROL"
|
59
|
+
}
|
60
|
+
]}
|
61
|
+
tests("#put_object_acl('#{@directory.identity}', 'fog_object', hash with id)").returns(acl) do
|
62
|
+
Fog::Storage[:internetarchive].put_object_acl(@directory.identity, 'fog_object', acl)
|
63
|
+
Fog::Storage[:internetarchive].get_object_acl(@directory.identity, 'fog_object').body
|
64
|
+
end
|
65
|
+
|
66
|
+
tests("#put_object_acl('#{@directory.identity}', 'fog_object', hash with email)").returns({
|
67
|
+
'Owner' => @ia_owner,
|
68
|
+
'AccessControlList' => [
|
69
|
+
{
|
70
|
+
'Grantee' => { 'ID' => 'f62f0218873cfa5d56ae9429ae75a592fec4fd22a5f24a20b1038a7db9a8f150', 'DisplayName' => 'mtd' },
|
71
|
+
'Permission' => "FULL_CONTROL"
|
72
|
+
}
|
73
|
+
]}) do
|
74
|
+
pending if Fog.mocking?
|
75
|
+
Fog::Storage[:internetarchive].put_object_acl(@directory.identity, 'fog_object', {
|
76
|
+
'Owner' => @ia_owner,
|
77
|
+
'AccessControlList' => [
|
78
|
+
{
|
79
|
+
'Grantee' => { 'EmailAddress' => 'mtd@amazon.com' },
|
80
|
+
'Permission' => "FULL_CONTROL"
|
81
|
+
}
|
82
|
+
]})
|
83
|
+
Fog::Storage[:internetarchive].get_object_acl(@directory.identity, 'fog_object').body
|
84
|
+
end
|
85
|
+
|
86
|
+
acl = {
|
87
|
+
'Owner' => @ia_owner,
|
88
|
+
'AccessControlList' => [
|
89
|
+
{
|
90
|
+
'Grantee' => { 'URI' => 'http://acs.amazonaws.com/groups/global/AllUsers' },
|
91
|
+
'Permission' => "FULL_CONTROL"
|
92
|
+
}
|
93
|
+
]}
|
94
|
+
tests("#put_object_acl('#{@directory.identity}', 'fog_object', hash with uri)").returns(acl) do
|
95
|
+
Fog::Storage[:internetarchive].put_object_acl(@directory.identity, 'fog_object', acl)
|
96
|
+
Fog::Storage[:internetarchive].get_object_acl(@directory.identity, 'fog_object').body
|
97
|
+
end
|
98
|
+
|
99
|
+
tests("#delete_object('#{@directory.identity}', 'fog_object')").succeeds do
|
100
|
+
Fog::Storage[:internetarchive].delete_object(@directory.identity, 'fog_object')
|
101
|
+
end
|
102
|
+
|
103
|
+
tests("#get_object_http_url('#{@directory.identity}', 'fog_object', expiration timestamp)").returns(true) do
|
104
|
+
object_url = Fog::Storage[:internetarchive].get_object_http_url(@directory.identity, 'fog_object', (Time.now + 60))
|
105
|
+
puts "get_object_http_url object_url: #{object_url}"
|
106
|
+
(object_url =~ /http:\/\/#{Regexp.quote(@directory.identity)}\.s3\.us\.archive\.org\/fog_object/) != nil
|
107
|
+
end
|
108
|
+
|
109
|
+
tests("delete_multiple_objects('#{@directory.identity}', ['fog_object', 'fog_other_object'])").formats(@multiple_delete_format) do
|
110
|
+
Fog::Storage[:internetarchive].delete_multiple_objects(@directory.identity, ['fog_object', 'fog_other_object']).body
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
tests('failure') do
|
116
|
+
|
117
|
+
tests("#put_object('fognonbucket', 'fog_non_object', lorem_file)").raises(Excon::Errors::NotFound) do
|
118
|
+
Fog::Storage[:internetarchive].put_object('fognonbucket', 'fog_non_object', lorem_file)
|
119
|
+
end
|
120
|
+
|
121
|
+
tests("#copy_object('fognonbucket', 'fog_object', '#{@directory.identity}', 'fog_other_object')").raises(Excon::Errors::NotFound) do
|
122
|
+
Fog::Storage[:internetarchive].copy_object('fognonbucket', 'fog_object', @directory.identity, 'fog_other_object')
|
123
|
+
end
|
124
|
+
|
125
|
+
tests("#copy_object('#{@directory.identity}', 'fog_non_object', '#{@directory.identity}', 'fog_other_object')").raises(Excon::Errors::NotFound) do
|
126
|
+
Fog::Storage[:internetarchive].copy_object(@directory.identity, 'fog_non_object', @directory.identity, 'fog_other_object')
|
127
|
+
end
|
128
|
+
|
129
|
+
tests("#copy_object('#{@directory.identity}', 'fog_object', 'fognonbucket', 'fog_other_object')").raises(Excon::Errors::NotFound) do
|
130
|
+
Fog::Storage[:internetarchive].copy_object(@directory.identity, 'fog_object', 'fognonbucket', 'fog_other_object')
|
131
|
+
end
|
132
|
+
|
133
|
+
tests("#get_object('fognonbucket', 'fog_non_object')").raises(Excon::Errors::NotFound) do
|
134
|
+
Fog::Storage[:internetarchive].get_object('fognonbucket', 'fog_non_object')
|
135
|
+
end
|
136
|
+
|
137
|
+
tests("#get_object('#{@directory.identity}', 'fog_non_object')").raises(Excon::Errors::NotFound) do
|
138
|
+
Fog::Storage[:internetarchive].get_object(@directory.identity, 'fog_non_object')
|
139
|
+
end
|
140
|
+
|
141
|
+
tests("#head_object('fognonbucket', 'fog_non_object')").raises(Excon::Errors::NotFound) do
|
142
|
+
Fog::Storage[:internetarchive].head_object('fognonbucket', 'fog_non_object')
|
143
|
+
end
|
144
|
+
|
145
|
+
tests("#head_object('#{@directory.identity}', 'fog_non_object')").raises(Excon::Errors::NotFound) do
|
146
|
+
Fog::Storage[:internetarchive].head_object(@directory.identity, 'fog_non_object')
|
147
|
+
end
|
148
|
+
|
149
|
+
tests("#delete_object('fognonbucket', 'fog_non_object')").raises(Excon::Errors::NotFound) do
|
150
|
+
Fog::Storage[:internetarchive].delete_object('fognonbucket', 'fog_non_object')
|
151
|
+
end
|
152
|
+
|
153
|
+
tests("#delete_multiple_objects('fognonbucket', ['fog_non_object'])").raises(Excon::Errors::NotFound) do
|
154
|
+
pending if Fog.mocking?
|
155
|
+
Fog::Storage[:internetarchive].delete_multiple_objects('fognonbucket', ['fog_non_object'])
|
156
|
+
end
|
157
|
+
|
158
|
+
tests("#put_object_acl('#{@directory.identity}', 'fog_object', 'invalid')").raises(Excon::Errors::BadRequest) do
|
159
|
+
Fog::Storage[:internetarchive].put_object_acl('#{@directory.identity}', 'fog_object', 'invalid')
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
163
|
+
|
164
|
+
@directory.destroy
|
165
|
+
|
166
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
Shindo.tests('InternetArchive | signaturev4', ['internetarchive']) do
|
4
|
+
|
5
|
+
# These testcases are from http://docs.amazonwebservices.com/general/latest/gr/signature-v4-test-suite.html
|
6
|
+
@signer = Fog::InternetArchive::SignatureV4.new('AKIDEXAMPLE', 'wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY', 'us-east-1','host')
|
7
|
+
|
8
|
+
Fog::Time.now = ::Time.utc(2011,9,9,23,36,0)
|
9
|
+
|
10
|
+
tests('get-vanilla') do
|
11
|
+
returns(@signer.sign({:headers => {'Host' => 'host.foo.com', 'Date' => 'Mon, 09 Sep 2011 23:36:00 GMT'}, :method => :get, :path => '/'}, Fog::Time.now)) do
|
12
|
+
'AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=b27ccfbfa7df52a200ff74193ca6e32d4b48b8856fab7ebf1c595d0670a7e470'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
tests('get-vanilla-query-order-key with symbol keys') do
|
17
|
+
returns(@signer.sign({:query => {:'a' => 'foo', :'b' => 'foo'}, :headers => {:'Host' => 'host.foo.com', 'Date' => 'Mon, 09 Sep 2011 23:36:00 GMT'}, :method => :get, :path => '/'}, Fog::Time.now)) do
|
18
|
+
'AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=0dc122f3b28b831ab48ba65cb47300de53fbe91b577fe113edac383730254a3b'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
tests('get-vanilla-query-order-key') do
|
23
|
+
returns(@signer.sign({:query => {'a' => 'foo', 'b' => 'foo'}, :headers => {'Host' => 'host.foo.com', 'Date' => 'Mon, 09 Sep 2011 23:36:00 GMT'}, :method => :get, :path => '/'}, Fog::Time.now)) do
|
24
|
+
'AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=0dc122f3b28b831ab48ba65cb47300de53fbe91b577fe113edac383730254a3b'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
tests('get-unreserved') do
|
29
|
+
returns(@signer.sign({:headers => {'Host' => 'host.foo.com', 'Date' => 'Mon, 09 Sep 2011 23:36:00 GMT'}, :method => :get, :path => '/-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'}, Fog::Time.now)) do
|
30
|
+
'AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=date;host, Signature=830cc36d03f0f84e6ee4953fbe701c1c8b71a0372c63af9255aa364dd183281e'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
tests('post-x-www-form-urlencoded-parameter') do
|
35
|
+
returns(@signer.sign({:headers => {'Content-type' => 'application/x-www-form-urlencoded; charset=utf8', 'Host' => 'host.foo.com', 'Date' => 'Mon, 09 Sep 2011 23:36:00 GMT'}, :method => :post, :path => '/',
|
36
|
+
:body => 'foo=bar'}, Fog::Time.now)) do
|
37
|
+
'AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/host/aws4_request, SignedHeaders=content-type;date;host, Signature=b105eb10c6d318d2294de9d49dd8b031b55e3c3fe139f2e637da70511e9e7b71'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
Fog::Time.now = ::Time.now
|
41
|
+
end
|