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 +4 -4
- data/CHANGES +4 -1
- data/README +0 -4
- data/azure-signature.gemspec +1 -1
- data/lib/azure/signature.rb +5 -3
- data/test/test_signature.rb +9 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2b9821d2e2078112680c0017088a156da5f9b18
|
4
|
+
data.tar.gz: 940872135f5844cba32a6ab29762395b0dd1b0d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e918d84bf6ba3a5e327fcca481a2000071272a00a045aa9a5442356e6ec5f064ecc500d8865bbbf2f0f6fd98fc82a3066d463b17c202108fcc444fd266c62cf0
|
7
|
+
data.tar.gz: cde329223ea83f02979003857394f4d4bd9f7ef8cdde566ceea95fd05937d5a43fd5efe2d0d432a6d0c0ba236cd4401317fa3cea2f3a4902f116ccea3aff9141
|
data/CHANGES
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
= 0.2.
|
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
|
data/azure-signature.gemspec
CHANGED
data/lib/azure/signature.rb
CHANGED
@@ -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.
|
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)
|
data/test/test_signature.rb
CHANGED
@@ -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.
|
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.
|
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-
|
11
|
+
date: 2016-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|