azure-signature 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d7a1b158412c4274214bec5787766675894710b2
4
- data.tar.gz: be496da96d1f71a5f51d458c2a17dff98f0cba2d
3
+ metadata.gz: c2b9821d2e2078112680c0017088a156da5f9b18
4
+ data.tar.gz: 940872135f5844cba32a6ab29762395b0dd1b0d5
5
5
  SHA512:
6
- metadata.gz: 755801a587abb2d6e700da4efd375da537944aced3638102aeae7c495aa6592a1650ea920a4ce859a0d3bcad2ae05fef6b173c4a42837dbe6cd4917bc5cb4886
7
- data.tar.gz: d7bd143b29cdaafa758475a7576c990826049efdcf451ebe24d7692dad7a0adadc31001ff009fdd04e6d02b1a56e78254b9ef2e07c39f5e8604ce8a50b528bc7
6
+ metadata.gz: e918d84bf6ba3a5e327fcca481a2000071272a00a045aa9a5442356e6ec5f064ecc500d8865bbbf2f0f6fd98fc82a3066d463b17c202108fcc444fd266c62cf0
7
+ data.tar.gz: cde329223ea83f02979003857394f4d4bd9f7ef8cdde566ceea95fd05937d5a43fd5efe2d0d432a6d0c0ba236cd4401317fa3cea2f3a4902f116ccea3aff9141
data/CHANGES CHANGED
@@ -1,4 +1,7 @@
1
- = 0.2.1 - 13-June-2016
1
+ = 0.2.2 - 17-Jun-2016
2
+ * The resource argument to the constructor is now automatically escaped.
3
+
4
+ = 0.2.1 - 13-Jun-2016
2
5
  * The signature methods now accept standard header strings as key arguments
3
6
  as well as symbols, e.g. 'auth-type' vs :auth_type.
4
7
  * Replaced URI with Addressable::URI since it's more robust.
data/README CHANGED
@@ -25,10 +25,6 @@
25
25
  I borrowed the code to canonicalize resources and headers from the
26
26
  azure-sdk-for-ruby project.
27
27
 
28
- = Copyright
29
- Copyright (c) 2015-2016, Daniel J. Berger.
30
- All rights reserved.
31
-
32
28
  = License
33
29
  Apache 2.0
34
30
  http://www.apache.org/licenses/LICENSE-2.0
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'azure-signature'
5
- gem.version = '0.2.1'
5
+ gem.version = '0.2.2'
6
6
  gem.author = 'Daniel J. Berger'
7
7
  gem.license = 'Apache 2.0'
8
8
  gem.email = 'djberg96@gmail.com'
@@ -9,7 +9,7 @@ module Azure
9
9
  # The Signature class encapsulates an canonicalized resource string.
10
10
  class Signature
11
11
  # The version of the azure-signature library.
12
- VERSION = '0.2.1'
12
+ VERSION = '0.2.2'
13
13
 
14
14
  # The resource (URL) passed to the constructor.
15
15
  attr_reader :resource
@@ -35,9 +35,11 @@ module Azure
35
35
  # as an argument and a storage account key. The +resource+ will typically
36
36
  # be an Azure storage account endpoint.
37
37
  #
38
+ # Note that the +resource+ is automatically escaped.
39
+ #
38
40
  def initialize(resource, key)
39
- @resource = resource
40
- @uri = Addressable::URI.parse(resource)
41
+ @resource = Addressable::URI.escape(resource)
42
+ @uri = Addressable::URI.parse(@resource)
41
43
  @account_name = @uri.host.split(".").first.split("-").first
42
44
  @key = Base64.strict_decode64(key)
43
45
  @canonical_resource = canonicalize_resource(@uri)
@@ -9,7 +9,7 @@ class TC_Azure_Signature < Test::Unit::TestCase
9
9
  end
10
10
 
11
11
  test "version constant is set to expected value" do
12
- assert_equal("0.2.1", Azure::Signature::VERSION)
12
+ assert_equal("0.2.2", Azure::Signature::VERSION)
13
13
  end
14
14
 
15
15
  test "key method basic functionality" do
@@ -77,6 +77,14 @@ class TC_Azure_Signature < Test::Unit::TestCase
77
77
  assert_equal(expected, @sig.canonical_resource)
78
78
  end
79
79
 
80
+ test "constructor automatically escapes resource argument" do
81
+ @url = "https://myaccount-secondary.blob.core.windows.net/mycontainer/myblob-{12345}"
82
+ @sig = Azure::Signature.new(@url, @key)
83
+ expected = "/myaccount/mycontainer/myblob-%7B12345%7D"
84
+ assert_equal("/myaccount/mycontainer/myblob-%7B12345%7D", @sig.canonical_resource)
85
+ assert_equal("https://myaccount-secondary.blob.core.windows.net/mycontainer/myblob-%7B12345%7D", @sig.resource)
86
+ end
87
+
80
88
  test "constructor requires two arguments" do
81
89
  assert_raise(ArgumentError){ Azure::Signature.new }
82
90
  assert_raise(ArgumentError){ Azure::Signature.new('http://foo/bar') }
@@ -95,13 +103,6 @@ class TC_Azure_Signature < Test::Unit::TestCase
95
103
  assert_alias_method(@sig, :blob_signature, :queue_signature)
96
104
  end
97
105
 
98
- test "signature with strings or symbols is identical" do
99
- date = '2016-01-01'
100
- sig_symbol = @sig.signature(:table, :auth_string => true, :date => date, :verb => 'PUT')
101
- sig_string = @sig.signature(:table, 'Auth-String' => true, 'Date' => date, 'Verb' => 'PUT')
102
- assert_equal(sig_symbol, sig_string)
103
- end
104
-
105
106
  def teardown
106
107
  @key = nil
107
108
  @url = nil
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: azure-signature
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-13 00:00:00.000000000 Z
11
+ date: 2016-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable