gitlab-fog-azure-rm 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/fog/azurerm/models/storage/file.rb +9 -1
- data/lib/fog/azurerm/models/storage/files.rb +4 -4
- data/lib/fog/azurerm/requests/storage/get_blob_http_url.rb +3 -2
- data/lib/fog/azurerm/requests/storage/get_blob_https_url.rb +3 -2
- data/lib/fog/azurerm/requests/storage/get_object_url.rb +4 -4
- data/lib/fog/azurerm/version.rb +1 -1
- data/test/models/storage/test_file.rb +13 -1
- data/test/requests/storage/test_get_blob_http_url.rb +21 -0
- data/test/requests/storage/test_get_blob_https_url.rb +23 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cc556f2028cd1a063691e4556dc1421014476690f700eb31fea81bcac574b41
|
4
|
+
data.tar.gz: e6e7d3c355e63cf6a0501d2bc85cbfd994ae54349c950657f6619244fecc9d02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1ffb76c0ba61d39f675c90612afdf3ae06f0b0835c8f6162a874b73a637e58e4c2c07c0b193ede34ef84601c040920e7a93c2ade997abcdd3c39a64f45d9ff9
|
7
|
+
data.tar.gz: bae99d6843a450a5072a9a8e5a2e94de43a6849565fa38c2b288d3c14fbeb70066be960b08c0172a5a9eb61314119d1e78dfb890f90fa4b4af7f7784b028fcdd
|
data/CHANGELOG.md
CHANGED
@@ -240,11 +240,19 @@ module Fog
|
|
240
240
|
#
|
241
241
|
def url(expires, options = {})
|
242
242
|
requires :key
|
243
|
-
collection.get_url(key, expires, options)
|
243
|
+
collection.get_url(key, expires, normalize_options(options))
|
244
244
|
end
|
245
245
|
|
246
246
|
private
|
247
247
|
|
248
|
+
def normalize_options(options)
|
249
|
+
# AWS S3 and Google Cloud Storage pass response-content-disposition
|
250
|
+
# as a query string, while Azure needs the content_disposition parameter
|
251
|
+
# to generate a SAS token.
|
252
|
+
options[:content_disposition] ||= options.dig(:query, 'response-content-disposition')
|
253
|
+
options
|
254
|
+
end
|
255
|
+
|
248
256
|
# Upload blob
|
249
257
|
def save_blob(options)
|
250
258
|
if options[:blob_type].nil? || options[:blob_type] == 'BlockBlob'
|
@@ -123,10 +123,10 @@ module Fog
|
|
123
123
|
#
|
124
124
|
# @return [String] A http URL.
|
125
125
|
#
|
126
|
-
def get_http_url(key, expires,
|
126
|
+
def get_http_url(key, expires, options = {})
|
127
127
|
requires :directory
|
128
128
|
|
129
|
-
service.get_blob_http_url(directory.key, key, expires)
|
129
|
+
service.get_blob_http_url(directory.key, key, expires, options)
|
130
130
|
end
|
131
131
|
|
132
132
|
# Get the https URL of the file(blob) with the given name.
|
@@ -139,10 +139,10 @@ module Fog
|
|
139
139
|
#
|
140
140
|
# @return [String] A https URL.
|
141
141
|
#
|
142
|
-
def get_https_url(key, expires,
|
142
|
+
def get_https_url(key, expires, options = {})
|
143
143
|
requires :directory
|
144
144
|
|
145
|
-
service.get_blob_https_url(directory.key, key, expires)
|
145
|
+
service.get_blob_https_url(directory.key, key, expires, options)
|
146
146
|
end
|
147
147
|
|
148
148
|
# Get the file(blob) without content with the given name.
|
@@ -13,14 +13,15 @@ module Fog
|
|
13
13
|
#
|
14
14
|
# @see https://msdn.microsoft.com/en-us/library/azure/mt584140.aspx
|
15
15
|
#
|
16
|
-
def get_blob_http_url(container_name, blob_name, expires)
|
16
|
+
def get_blob_http_url(container_name, blob_name, expires, options = {})
|
17
17
|
relative_path = "#{container_name}/#{blob_name}"
|
18
18
|
relative_path = remove_trailing_periods_from_path_segments(relative_path)
|
19
19
|
params = {
|
20
20
|
service: 'b',
|
21
21
|
resource: 'b',
|
22
22
|
permissions: 'r',
|
23
|
-
expiry: expires.utc.iso8601
|
23
|
+
expiry: expires.utc.iso8601,
|
24
|
+
content_disposition: options[:content_disposition]
|
24
25
|
}
|
25
26
|
token = @signature_client.generate_service_sas_token(relative_path, params)
|
26
27
|
uri = @blob_client.generate_uri(relative_path, {}, { encode: true })
|
@@ -13,7 +13,7 @@ module Fog
|
|
13
13
|
#
|
14
14
|
# @see https://msdn.microsoft.com/en-us/library/azure/mt584140.aspx
|
15
15
|
#
|
16
|
-
def get_blob_https_url(container_name, blob_name, expires)
|
16
|
+
def get_blob_https_url(container_name, blob_name, expires, options = {})
|
17
17
|
relative_path = "#{container_name}/#{blob_name}"
|
18
18
|
relative_path = remove_trailing_periods_from_path_segments(relative_path)
|
19
19
|
params = {
|
@@ -21,7 +21,8 @@ module Fog
|
|
21
21
|
resource: 'b',
|
22
22
|
permissions: 'r',
|
23
23
|
expiry: expires.utc.iso8601,
|
24
|
-
protocol: 'https'
|
24
|
+
protocol: 'https',
|
25
|
+
content_disposition: options[:content_disposition]
|
25
26
|
}
|
26
27
|
token = @signature_client.generate_service_sas_token(relative_path, params)
|
27
28
|
uri = @blob_client.generate_uri(relative_path, {}, { encode: true })
|
@@ -5,15 +5,15 @@ module Fog
|
|
5
5
|
class Real
|
6
6
|
# Get a public blob url from Azure blob storage
|
7
7
|
# This is to make this library compatible with CarrierWave.
|
8
|
-
def get_object_url(container_name, blob_name, expires)
|
9
|
-
get_blob_https_url(container_name, blob_name, expires)
|
8
|
+
def get_object_url(container_name, blob_name, expires, options = {})
|
9
|
+
get_blob_https_url(container_name, blob_name, expires, options)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
# This class provides the mock implementation for unit tests.
|
14
14
|
class Mock
|
15
|
-
def get_object_url(container_name, blob_name, expires)
|
16
|
-
get_blob_https_url(container_name, blob_name, expires)
|
15
|
+
def get_object_url(container_name, blob_name, expires, options = {})
|
16
|
+
get_blob_https_url(container_name, blob_name, expires, options)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/lib/fog/azurerm/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.expand_path '../../test_helper', __dir__
|
2
2
|
|
3
3
|
# Test class for Storage Container Model
|
4
|
-
class TestFile < Minitest::Test
|
4
|
+
class TestFile < Minitest::Test # rubocop:disable Metrics/ClassLength
|
5
5
|
def setup
|
6
6
|
@service = Fog::Storage::AzureRM.new(storage_account_credentials)
|
7
7
|
@directory = directory(@service)
|
@@ -283,6 +283,18 @@ class TestFile < Minitest::Test
|
|
283
283
|
end
|
284
284
|
end
|
285
285
|
|
286
|
+
def test_url_method_with_content_disposition
|
287
|
+
@file.collection.stub :get_url, @blob_https_url, { content_disposition: 'attachment' } do
|
288
|
+
assert @file.url(Time.now + 3600, content_disposition: 'attachment'), @blob_https_url
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
def test_url_method_with_response_content_disposition
|
293
|
+
@file.collection.stub :get_url, @blob_https_url, { content_disposition: 'attachment' } do
|
294
|
+
assert @file.url(Time.now + 3600, { query: { 'response-content-disposition' => 'attachment' } }), @blob_https_url
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
286
298
|
def test_url_method_without_key_exception
|
287
299
|
assert_raises(ArgumentError) do
|
288
300
|
@file.attributes.delete(:key)
|
@@ -24,6 +24,27 @@ class TestGetBlobHttpUrl < Minitest::Test
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
def test_get_blob_http_url_with_content_disposition
|
28
|
+
mock_generate_uri = Minitest::Mock.new
|
29
|
+
mock_generate_service_token = Minitest::Mock.new
|
30
|
+
url_params = { content_disposition: 'attachment' }
|
31
|
+
|
32
|
+
mock_generate_uri.expect(:call, @url, ['test_container/test_blob', {}, { encode: true }])
|
33
|
+
mock_generate_service_token.expect(:call, @token) do |_relative_path, params|
|
34
|
+
params[:service] == 'b' &&
|
35
|
+
params[:resource] == 'b' &&
|
36
|
+
params[:permissions] == 'r' &&
|
37
|
+
params[:protocol].nil? &&
|
38
|
+
params[:content_disposition] == url_params[:content_disposition]
|
39
|
+
end
|
40
|
+
|
41
|
+
@blob_client.stub :generate_uri, mock_generate_uri do
|
42
|
+
@signature_client.stub :generate_service_sas_token, mock_generate_service_token do
|
43
|
+
assert_equal "#{@url}?#{@token}", @service.get_blob_http_url('test_container', 'test_blob', Time.now.utc + 3600, url_params)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
27
48
|
def test_get_url_remove_trailing_periods_from_path_segments
|
28
49
|
mock_generate_uri = Minitest::Mock.new
|
29
50
|
mock_generate_service_token = Minitest::Mock.new
|
@@ -31,6 +31,29 @@ class TestGetBlobHttpsUrl < Minitest::Test
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
def test_get_blob_https_url_with_content_disposition
|
35
|
+
mock_generate_uri = Minitest::Mock.new
|
36
|
+
mock_generate_service_token = Minitest::Mock.new
|
37
|
+
url_params = { content_disposition: 'attachment' }
|
38
|
+
|
39
|
+
2.times do
|
40
|
+
mock_generate_uri.expect(:call, @url, ['test_container/test_blob', {}, { encode: true }])
|
41
|
+
mock_generate_service_token.expect(:call, @token) do |_relative_path, params|
|
42
|
+
params[:service] == 'b' &&
|
43
|
+
params[:resource] == 'b' &&
|
44
|
+
params[:permissions] == 'r' &&
|
45
|
+
params[:content_disposition] == url_params[:content_disposition]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
@blob_client.stub :generate_uri, mock_generate_uri do
|
50
|
+
@signature_client.stub :generate_service_sas_token, mock_generate_service_token do
|
51
|
+
assert_equal "#{@url}?#{@token}", @service.get_blob_https_url('test_container', 'test_blob', Time.now.utc + 3600, url_params)
|
52
|
+
assert_equal "#{@url}?#{@token}", @service.get_object_url('test_container', 'test_blob', Time.now.utc + 3600, url_params)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
34
57
|
def test_get_url_remove_trailing_periods_from_path_segments
|
35
58
|
mock_generate_uri = Minitest::Mock.new
|
36
59
|
mock_generate_service_token = Minitest::Mock.new
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-fog-azure-rm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shaffan Chaudhry
|
@@ -15,10 +15,10 @@ authors:
|
|
15
15
|
- Azeem Sajid
|
16
16
|
- Maham Nazir
|
17
17
|
- Abbas Sheikh
|
18
|
-
autorequire:
|
18
|
+
autorequire:
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
|
-
date: 2021-
|
21
|
+
date: 2021-09-20 00:00:00.000000000 Z
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
24
24
|
name: codeclimate-test-reporter
|
@@ -176,7 +176,7 @@ dependencies:
|
|
176
176
|
version: 0.12.0
|
177
177
|
description: This is a stripped-down fork of fog-azure-rm that enables Azure Blob
|
178
178
|
Storage to be used with CarrierWave and Fog.
|
179
|
-
email:
|
179
|
+
email:
|
180
180
|
executables: []
|
181
181
|
extensions: []
|
182
182
|
extra_rdoc_files:
|
@@ -338,8 +338,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
338
338
|
- !ruby/object:Gem::Version
|
339
339
|
version: '0'
|
340
340
|
requirements: []
|
341
|
-
rubygems_version: 3.1.
|
342
|
-
signing_key:
|
341
|
+
rubygems_version: 3.1.6
|
342
|
+
signing_key:
|
343
343
|
specification_version: 4
|
344
344
|
summary: Module for the 'fog' gem to support Azure Blob Storage with CarrierWave and
|
345
345
|
Fog.
|