signet 0.11.0 → 0.14.1

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +51 -15
  3. data/Gemfile +5 -4
  4. data/README.md +4 -6
  5. data/Rakefile +107 -37
  6. data/lib/signet.rb +17 -14
  7. data/lib/signet/errors.rb +4 -4
  8. data/lib/signet/oauth_1.rb +129 -154
  9. data/lib/signet/oauth_1/client.rb +309 -343
  10. data/lib/signet/oauth_1/credential.rb +40 -37
  11. data/lib/signet/oauth_1/server.rb +197 -203
  12. data/lib/signet/oauth_1/signature_methods/hmac_sha1.rb +11 -10
  13. data/lib/signet/oauth_1/signature_methods/plaintext.rb +8 -7
  14. data/lib/signet/oauth_1/signature_methods/rsa_sha1.rb +11 -11
  15. data/lib/signet/oauth_2.rb +41 -43
  16. data/lib/signet/oauth_2/client.rb +328 -313
  17. data/lib/signet/version.rb +2 -73
  18. data/signet.gemspec +37 -39
  19. data/spec/signet/oauth_1/client_spec.rb +313 -315
  20. data/spec/signet/oauth_1/credential_spec.rb +64 -56
  21. data/spec/signet/oauth_1/server_spec.rb +362 -362
  22. data/spec/signet/oauth_1/signature_methods/hmac_sha1_spec.rb +26 -26
  23. data/spec/signet/oauth_1/signature_methods/plaintext_spec.rb +28 -28
  24. data/spec/signet/oauth_1/signature_methods/rsa_sha1_spec.rb +34 -35
  25. data/spec/signet/oauth_1_spec.rb +553 -524
  26. data/spec/signet/oauth_2/client_spec.rb +652 -576
  27. data/spec/signet/oauth_2_spec.rb +88 -89
  28. data/spec/signet_spec.rb +41 -41
  29. data/spec/spec_helper.rb +7 -7
  30. data/spec/spec_helper_spec.rb +8 -8
  31. metadata +64 -52
  32. data/tasks/clobber.rake +0 -2
  33. data/tasks/gem.rake +0 -34
  34. data/tasks/git.rake +0 -40
  35. data/tasks/metrics.rake +0 -41
  36. data/tasks/spec.rake +0 -34
  37. data/tasks/wiki.rake +0 -38
  38. data/tasks/yard.rake +0 -21
@@ -11,51 +11,51 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
- require 'spec_helper'
15
- require 'signet'
16
- require 'signet/oauth_1'
17
- require 'signet/oauth_1/signature_methods/hmac_sha1'
14
+ require "spec_helper"
15
+ require "signet"
16
+ require "signet/oauth_1"
17
+ require "signet/oauth_1/signature_methods/hmac_sha1"
18
18
 
19
19
  describe Signet::OAuth1::HMACSHA1 do
20
- it 'should correctly generate a signature' do
20
+ it "should correctly generate a signature" do
21
21
  method = "GET"
22
22
  uri = "http://photos.example.net/photos"
23
23
  parameters = {
24
- "oauth_consumer_key" => "dpf43f3p2l4k3l03",
25
- "oauth_token" => "nnch734d00sl2jdk",
24
+ "oauth_consumer_key" => "dpf43f3p2l4k3l03",
25
+ "oauth_token" => "nnch734d00sl2jdk",
26
26
  "oauth_signature_method" => "HMAC-SHA1",
27
- "oauth_timestamp" => "1191242096",
28
- "oauth_nonce" => "kllo9940pd9333jh",
29
- "oauth_version" => "1.0",
30
- "file" => "vacation.jpg",
31
- "size" => "original"
27
+ "oauth_timestamp" => "1191242096",
28
+ "oauth_nonce" => "kllo9940pd9333jh",
29
+ "oauth_version" => "1.0",
30
+ "file" => "vacation.jpg",
31
+ "size" => "original"
32
32
  }
33
33
  client_credential_secret = "kd94hf93k423kf44"
34
34
  token_credential_secret = "pfkkdhi9sl3r4s00"
35
- base_string = Signet::OAuth1.generate_base_string(method, uri, parameters)
35
+ base_string = Signet::OAuth1.generate_base_string method, uri, parameters
36
36
  expect(Signet::OAuth1::HMACSHA1.generate_signature(
37
- base_string, client_credential_secret, token_credential_secret
38
- )).to eq "tR3+Ty81lMeYAr/Fid0kMTYa/WM="
37
+ base_string, client_credential_secret, token_credential_secret
38
+ )).to eq "tR3+Ty81lMeYAr/Fid0kMTYa/WM="
39
39
  end
40
40
 
41
- it 'should correctly generate a signature' do
41
+ it "should correctly generate a signature" do
42
42
  method = "GET"
43
43
  uri = "http://photos.example.net/photos"
44
44
  parameters = {
45
- "oauth_consumer_key" => "www.example.com",
46
- "oauth_token" => "4/QL2GT6b5uznYem1ZGH6v+-9mMvRL",
45
+ "oauth_consumer_key" => "www.example.com",
46
+ "oauth_token" => "4/QL2GT6b5uznYem1ZGH6v+-9mMvRL",
47
47
  "oauth_signature_method" => "HMAC-SHA1",
48
- "oauth_timestamp" => "1191242096",
49
- "oauth_nonce" => "kllo9940pd9333jh",
50
- "oauth_version" => "1.0",
51
- "file" => "vacation.jpg",
52
- "size" => "original"
48
+ "oauth_timestamp" => "1191242096",
49
+ "oauth_nonce" => "kllo9940pd9333jh",
50
+ "oauth_version" => "1.0",
51
+ "file" => "vacation.jpg",
52
+ "size" => "original"
53
53
  }
54
54
  client_credential_secret = "Kv+o2XXL/9RxkQW3lO3QTVlH"
55
55
  token_credential_secret = "QllSuL9eQ5FXFO1Z/HcgL4ON"
56
- base_string = Signet::OAuth1.generate_base_string(method, uri, parameters)
56
+ base_string = Signet::OAuth1.generate_base_string method, uri, parameters
57
57
  expect(Signet::OAuth1::HMACSHA1.generate_signature(
58
- base_string, client_credential_secret, token_credential_secret
59
- )).to eq "G/nkdbmbpEA+6RD1Sc5uIefhFfQ="
58
+ base_string, client_credential_secret, token_credential_secret
59
+ )).to eq "G/nkdbmbpEA+6RD1Sc5uIefhFfQ="
60
60
  end
61
61
  end
@@ -11,51 +11,51 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
- require 'spec_helper'
15
- require 'signet'
16
- require 'signet/oauth_1'
17
- require 'signet/oauth_1/signature_methods/plaintext'
14
+ require "spec_helper"
15
+ require "signet"
16
+ require "signet/oauth_1"
17
+ require "signet/oauth_1/signature_methods/plaintext"
18
18
 
19
19
  describe Signet::OAuth1::PLAINTEXT do
20
- it 'should correctly generate a signature' do
20
+ it "should correctly generate a signature" do
21
21
  method = "GET"
22
22
  uri = "http://photos.example.net/photos"
23
23
  parameters = {
24
- "oauth_consumer_key" => "dpf43f3p2l4k3l03",
25
- "oauth_token" => "nnch734d00sl2jdk",
26
- "oauth_signature_method" => "HMAC-SHA1",
27
- "oauth_timestamp" => "1191242096",
28
- "oauth_nonce" => "kllo9940pd9333jh",
29
- "oauth_version" => "1.0",
30
- "file" => "vacation.jpg",
31
- "size" => "original"
24
+ "oauth_consumer_key" => "dpf43f3p2l4k3l03",
25
+ "oauth_token" => "nnch734d00sl2jdk",
26
+ "oauth_signature_method" => "HMAC-SHA1",
27
+ "oauth_timestamp" => "1191242096",
28
+ "oauth_nonce" => "kllo9940pd9333jh",
29
+ "oauth_version" => "1.0",
30
+ "file" => "vacation.jpg",
31
+ "size" => "original"
32
32
  }
33
33
  client_credential_secret = "kd94hf93k423kf44"
34
34
  token_credential_secret = "pfkkdhi9sl3r4s00"
35
- base_string = Signet::OAuth1.generate_base_string(method, uri, parameters)
35
+ base_string = Signet::OAuth1.generate_base_string method, uri, parameters
36
36
  expect(Signet::OAuth1::PLAINTEXT.generate_signature(
37
- base_string, client_credential_secret, token_credential_secret
38
- )).to eq "kd94hf93k423kf44%26pfkkdhi9sl3r4s00"
37
+ base_string, client_credential_secret, token_credential_secret
38
+ )).to eq "kd94hf93k423kf44%26pfkkdhi9sl3r4s00"
39
39
  end
40
40
 
41
- it 'should correctly generate a signature' do
41
+ it "should correctly generate a signature" do
42
42
  method = "GET"
43
43
  uri = "http://photos.example.net/photos"
44
44
  parameters = {
45
- "oauth_consumer_key" => "www.example.com",
46
- "oauth_token" => "4/QL2GT6b5uznYem1ZGH6v+-9mMvRL",
47
- "oauth_signature_method" => "HMAC-SHA1",
48
- "oauth_timestamp" => "1191242096",
49
- "oauth_nonce" => "kllo9940pd9333jh",
50
- "oauth_version" => "1.0",
51
- "file" => "vacation.jpg",
52
- "size" => "original"
45
+ "oauth_consumer_key" => "www.example.com",
46
+ "oauth_token" => "4/QL2GT6b5uznYem1ZGH6v+-9mMvRL",
47
+ "oauth_signature_method" => "HMAC-SHA1",
48
+ "oauth_timestamp" => "1191242096",
49
+ "oauth_nonce" => "kllo9940pd9333jh",
50
+ "oauth_version" => "1.0",
51
+ "file" => "vacation.jpg",
52
+ "size" => "original"
53
53
  }
54
54
  client_credential_secret = "Kv+o2XXL/9RxkQW3lO3QTVlH"
55
55
  token_credential_secret = "QllSuL9eQ5FXFO1Z/HcgL4ON"
56
- base_string = Signet::OAuth1.generate_base_string(method, uri, parameters)
56
+ base_string = Signet::OAuth1.generate_base_string method, uri, parameters
57
57
  expect(Signet::OAuth1::PLAINTEXT.generate_signature(
58
- base_string, client_credential_secret, token_credential_secret
59
- )).to eq "Kv%252Bo2XXL%252F9RxkQW3lO3QTVlH%26QllSuL9eQ5FXFO1Z%252FHcgL4ON"
58
+ base_string, client_credential_secret, token_credential_secret
59
+ )).to eq "Kv%252Bo2XXL%252F9RxkQW3lO3QTVlH%26QllSuL9eQ5FXFO1Z%252FHcgL4ON"
60
60
  end
61
61
  end
@@ -11,21 +11,21 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
- require 'spec_helper'
15
- require 'signet'
16
- require 'signet/oauth_1'
17
- require 'signet/oauth_1/signature_methods/rsa_sha1'
14
+ require "spec_helper"
15
+ require "signet"
16
+ require "signet/oauth_1"
17
+ require "signet/oauth_1/signature_methods/rsa_sha1"
18
18
 
19
19
  describe Signet::OAuth1::RSASHA1 do
20
- it 'should correctly generate a signature' do
20
+ it "should correctly generate a signature" do
21
21
  method = "GET"
22
22
  uri = "http://term.ie/oauth/example/request_token.php"
23
23
  parameters = {
24
- "oauth_consumer_key" => "key",
25
- "oauth_signature_method" => "RSA-SHA1",
26
- "oauth_timestamp" => "1377815426",
27
- "oauth_nonce" => "c3839c47cb204a20e042b11a5cc9f971",
28
- "oauth_version" => "1.0"
24
+ "oauth_consumer_key" => "key",
25
+ "oauth_signature_method" => "RSA-SHA1",
26
+ "oauth_timestamp" => "1377815426",
27
+ "oauth_nonce" => "c3839c47cb204a20e042b11a5cc9f971",
28
+ "oauth_version" => "1.0"
29
29
  }
30
30
  client_credential_secret = "-----BEGIN PRIVATE KEY-----
31
31
  MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALRiMLAh9iimur8V
@@ -44,26 +44,26 @@ AO/0isr/3aa6O6NLQxISLKcPDk2NOccAfS/xOtfOz4sJYM3+Bs4Io9+dZGSDCA54
44
44
  Lw03eHTNQghS0A==
45
45
  -----END PRIVATE KEY-----"
46
46
  token_credential_secret = "pfkkdhi9sl3r4s00"
47
- base_string = Signet::OAuth1.generate_base_string(method, uri, parameters)
47
+ base_string = Signet::OAuth1.generate_base_string method, uri, parameters
48
48
 
49
49
  expect(Signet::OAuth1::RSASHA1.generate_signature(
50
- base_string, client_credential_secret, token_credential_secret
51
- )).to eq "P72T4RS8dVBneQPJSY71D3iLEjge2tiivxEasPVoaoDldDgPdwpQfhS1q0th19jB3B3+9P6tBWjpWaVPxrNZe3ssBCiwS/EmXZ/6VCJGU3YoDHMtz+0jCd36NjHj5I6TpLVQ8/rtfy6+EzpdUMz7ydnhKXYqJFPOWnNv8HM1W7I="
50
+ base_string, client_credential_secret, token_credential_secret
51
+ )).to eq "P72T4RS8dVBneQPJSY71D3iLEjge2tiivxEasPVoaoDldDgPdwpQfhS1q0th19jB3B3+9P6tBWjpWaVPxrNZe3ssBCiwS/EmXZ/6VCJGU3YoDHMtz+0jCd36NjHj5I6TpLVQ8/rtfy6+EzpdUMz7ydnhKXYqJFPOWnNv8HM1W7I="
52
52
  end
53
53
  end
54
54
 
55
55
  describe Signet::OAuth1::RSASHA1 do
56
- it 'should correctly generate a signature' do
56
+ it "should correctly generate a signature" do
57
57
  method = "GET"
58
58
  uri = "http://photos.example.net/photos"
59
59
  parameters = {
60
- "oauth_consumer_key" => "dpf43f3p2l4k3l03",
61
- "oauth_signature_method" => "RSA-SHA1",
62
- "oauth_timestamp" => "1196666512",
63
- "oauth_nonce" => "13917289812797014437",
64
- "oauth_version" => "1.0",
65
- "file" => "vacaction.jpg",
66
- "size" => "original"
60
+ "oauth_consumer_key" => "dpf43f3p2l4k3l03",
61
+ "oauth_signature_method" => "RSA-SHA1",
62
+ "oauth_timestamp" => "1196666512",
63
+ "oauth_nonce" => "13917289812797014437",
64
+ "oauth_version" => "1.0",
65
+ "file" => "vacaction.jpg",
66
+ "size" => "original"
67
67
  }
68
68
  client_credential_secret = "-----BEGIN PRIVATE KEY-----
69
69
  MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALRiMLAh9iimur8V
@@ -82,24 +82,24 @@ AO/0isr/3aa6O6NLQxISLKcPDk2NOccAfS/xOtfOz4sJYM3+Bs4Io9+dZGSDCA54
82
82
  Lw03eHTNQghS0A==
83
83
  -----END PRIVATE KEY-----"
84
84
  token_credential_secret = "pfkkdhi9sl3r4s00"
85
- base_string = Signet::OAuth1.generate_base_string(method, uri, parameters)
85
+ base_string = Signet::OAuth1.generate_base_string method, uri, parameters
86
86
 
87
87
  expect(Signet::OAuth1::RSASHA1.generate_signature(
88
- base_string, client_credential_secret, token_credential_secret
89
- )).to eq "jvTp/wX1TYtByB1m+Pbyo0lnCOLIsyGCH7wke8AUs3BpnwZJtAuEJkvQL2/9n4s5wUmUl4aCI4BwpraNx4RtEXMe5qg5T1LVTGliMRpKasKsW//e+RinhejgCuzoH26dyF8iY2ZZ/5D1ilgeijhV/vBka5twt399mXwaYdCwFYE="
88
+ base_string, client_credential_secret, token_credential_secret
89
+ )).to eq "jvTp/wX1TYtByB1m+Pbyo0lnCOLIsyGCH7wke8AUs3BpnwZJtAuEJkvQL2/9n4s5wUmUl4aCI4BwpraNx4RtEXMe5qg5T1LVTGliMRpKasKsW//e+RinhejgCuzoH26dyF8iY2ZZ/5D1ilgeijhV/vBka5twt399mXwaYdCwFYE="
90
90
  end
91
91
 
92
92
 
93
- it 'should correctly generate a signature' do
93
+ it "should correctly generate a signature" do
94
94
  method = "GET"
95
95
  uri = "http://term.ie/oauth/example/access_token.php"
96
96
  parameters = {
97
- "oauth_consumer_key" => "key",
98
- "oauth_token" => "requestkey",
99
- "oauth_signature_method" => "RSA-SHA1",
100
- "oauth_timestamp" => "1377815426",
101
- "oauth_nonce" => "8ae9ac8192dd3cd7372e0324bf879602",
102
- "oauth_version" => "1.0",
97
+ "oauth_consumer_key" => "key",
98
+ "oauth_token" => "requestkey",
99
+ "oauth_signature_method" => "RSA-SHA1",
100
+ "oauth_timestamp" => "1377815426",
101
+ "oauth_nonce" => "8ae9ac8192dd3cd7372e0324bf879602",
102
+ "oauth_version" => "1.0"
103
103
  }
104
104
  client_credential_secret = "-----BEGIN PRIVATE KEY-----
105
105
  MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALRiMLAh9iimur8V
@@ -118,10 +118,9 @@ AO/0isr/3aa6O6NLQxISLKcPDk2NOccAfS/xOtfOz4sJYM3+Bs4Io9+dZGSDCA54
118
118
  Lw03eHTNQghS0A==
119
119
  -----END PRIVATE KEY-----"
120
120
  token_credential_secret = "QllSuL9eQ5FXFO1Z/HcgL4ON"
121
- base_string = Signet::OAuth1.generate_base_string(method, uri, parameters)
121
+ base_string = Signet::OAuth1.generate_base_string method, uri, parameters
122
122
  expect(Signet::OAuth1::RSASHA1.generate_signature(
123
- base_string, client_credential_secret, token_credential_secret
124
- )).to eq "Q1O7Ovi0jdacl/OTJoH3MAyOO/9H/tTXmoJzP/YqiKEJ+/wfShXo1RXX0xmlcjDR1XYxB1RMgHkFWQYYwz1qGCUhkXlH1c/to2qxPksptfPHRe7PJTxRClrdqLFOlhN7w2kO7tHVCeEp8IJIKON9q7cdXroTP7ctPPS+Q883SS0="
123
+ base_string, client_credential_secret, token_credential_secret
124
+ )).to eq "Q1O7Ovi0jdacl/OTJoH3MAyOO/9H/tTXmoJzP/YqiKEJ+/wfShXo1RXX0xmlcjDR1XYxB1RMgHkFWQYYwz1qGCUhkXlH1c/to2qxPksptfPHRe7PJTxRClrdqLFOlhN7w2kO7tHVCeEp8IJIKON9q7cdXroTP7ctPPS+Q883SS0="
125
125
  end
126
-
127
126
  end
@@ -11,64 +11,67 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
- require 'spec_helper'
15
- require 'signet/oauth_1'
16
- require 'signet/oauth_1/client'
17
- require 'signet/oauth_1/credential'
14
+ require "spec_helper"
15
+ require "signet/oauth_1"
16
+ require "signet/oauth_1/client"
17
+ require "signet/oauth_1/credential"
18
18
 
19
19
  describe Signet::OAuth1 do
20
- it 'should correctly normalize parameters' do
20
+ it "should correctly normalize parameters" do
21
21
  parameters = [
22
- ["a", "1"],
22
+ %w[a 1],
23
23
  ["c", "hi there"],
24
- ["f", "25"],
25
- ["f", "50"],
26
- ["f", "a"],
27
- ["z", "p"],
28
- ["z", "t"]
24
+ %w[f 25],
25
+ %w[f 50],
26
+ %w[f a],
27
+ %w[z p],
28
+ %w[z t]
29
29
  ]
30
30
  expect(Signet::OAuth1.normalize_parameters(parameters)).to eq(
31
- 'a=1&c=hi%20there&f=25&f=50&f=a&z=p&z=t')
31
+ "a=1&c=hi%20there&f=25&f=50&f=a&z=p&z=t"
32
+ )
32
33
  end
33
34
 
34
- it 'should correctly normalize parameters' do
35
+ it "should correctly normalize parameters" do
35
36
  parameters = [
36
37
  ["b5", "=%3D"],
37
- ["a3", "a"],
38
+ %w[a3 a],
38
39
  ["c@", ""],
39
40
  ["a2", "r b"],
40
- ["oauth_consumer_key", "9djdj82h48djs9d2"],
41
- ["oauth_token", "kkk9d7dh3k39sjv7"],
41
+ %w[oauth_consumer_key 9djdj82h48djs9d2],
42
+ %w[oauth_token kkk9d7dh3k39sjv7],
42
43
  ["oauth_signature_method", "HMAC-SHA1"],
43
- ["oauth_timestamp", "137131201"],
44
- ["oauth_nonce", "7d8f3e4a"],
44
+ %w[oauth_timestamp 137131201],
45
+ %w[oauth_nonce 7d8f3e4a],
45
46
  ["c2", ""],
46
47
  ["a3", "2 q"]
47
48
  ]
48
49
  expect(Signet::OAuth1.normalize_parameters(parameters)).to eq(
49
- 'a2=r%20b&a3=2%20q&a3=a&b5=%3D%253D&c%40=&c2=&oauth_consumer_key=9dj' +
50
- 'dj82h48djs9d2&oauth_nonce=7d8f3e4a&oauth_signature_method=HMAC-SHA1' +
51
- '&oauth_timestamp=137131201&oauth_token=kkk9d7dh3k39sjv7')
50
+ "a2=r%20b&a3=2%20q&a3=a&b5=%3D%253D&c%40=&c2=&oauth_consumer_key=9dj" \
51
+ "dj82h48djs9d2&oauth_nonce=7d8f3e4a&oauth_signature_method=HMAC-SHA1" \
52
+ "&oauth_timestamp=137131201&oauth_token=kkk9d7dh3k39sjv7"
53
+ )
52
54
  end
53
55
 
54
56
  it 'should exclude the "oauth_signature" parameter when normalizing' do
55
57
  parameters = [
56
- ["a", "1"],
57
- ["b", "2"],
58
- ["c", "3"],
59
- ["oauth_signature", "dpf43f3p2l4k3l03"]
58
+ %w[a 1],
59
+ %w[b 2],
60
+ %w[c 3],
61
+ %w[oauth_signature dpf43f3p2l4k3l03]
60
62
  ]
61
63
  expect(Signet::OAuth1.normalize_parameters(parameters)).to eq(
62
- "a=1&b=2&c=3")
64
+ "a=1&b=2&c=3"
65
+ )
63
66
  end
64
67
 
65
- it 'should raise an error if normalizing parameters with bogus values' do
68
+ it "should raise an error if normalizing parameters with bogus values" do
66
69
  expect(lambda do
67
- Signet::OAuth1.normalize_parameters(42)
70
+ Signet::OAuth1.normalize_parameters 42
68
71
  end).to raise_error(TypeError)
69
72
  end
70
73
 
71
- it 'should raise an error if generating a base string with bogus values' do
74
+ it "should raise an error if generating a base string with bogus values" do
72
75
  expect(lambda do
73
76
  Signet::OAuth1.generate_base_string(
74
77
  "GET", "http://photos.example.net/photos", 42
@@ -76,25 +79,25 @@ describe Signet::OAuth1 do
76
79
  end).to raise_error(TypeError)
77
80
  end
78
81
 
79
- it 'should correctly generate a base string' do
82
+ it "should correctly generate a base string" do
80
83
  method = "GET"
81
84
  uri = "http://photos.example.net/photos"
82
85
  parameters = {
83
- "oauth_consumer_key" => "dpf43f3p2l4k3l03",
84
- "oauth_token" => "nnch734d00sl2jdk",
86
+ "oauth_consumer_key" => "dpf43f3p2l4k3l03",
87
+ "oauth_token" => "nnch734d00sl2jdk",
85
88
  "oauth_signature_method" => "HMAC-SHA1",
86
- "oauth_timestamp" => "1191242096",
87
- "oauth_nonce" => "kllo9940pd9333jh",
88
- "oauth_version" => "1.0",
89
- "file" => "vacation.jpg",
90
- "size" => "original"
89
+ "oauth_timestamp" => "1191242096",
90
+ "oauth_nonce" => "kllo9940pd9333jh",
91
+ "oauth_version" => "1.0",
92
+ "file" => "vacation.jpg",
93
+ "size" => "original"
91
94
  }
92
95
  expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
93
- "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" +
94
- "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" +
95
- "oauth_nonce%3Dkllo9940pd9333jh%26" +
96
- "oauth_signature_method%3DHMAC-SHA1%26" +
97
- "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" +
96
+ "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" \
97
+ "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" \
98
+ "oauth_nonce%3Dkllo9940pd9333jh%26" \
99
+ "oauth_signature_method%3DHMAC-SHA1%26" \
100
+ "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" \
98
101
  "oauth_version%3D1.0%26size%3Doriginal"
99
102
  )
100
103
  end
@@ -103,22 +106,22 @@ describe Signet::OAuth1 do
103
106
  method = "GET"
104
107
  uri = "http://photos.example.net/https%3A%2F%2Fwww.example.com"
105
108
  parameters = {
106
- "oauth_consumer_key" => "dpf43f3p2l4k3l03",
107
- "oauth_token" => "nnch734d00sl2jdk",
109
+ "oauth_consumer_key" => "dpf43f3p2l4k3l03",
110
+ "oauth_token" => "nnch734d00sl2jdk",
108
111
  "oauth_signature_method" => "HMAC-SHA1",
109
- "oauth_timestamp" => "1191242096",
110
- "oauth_nonce" => "kllo9940pd9333jh",
111
- "oauth_version" => "1.0",
112
- "file" => "vacation.jpg",
113
- "size" => "original"
112
+ "oauth_timestamp" => "1191242096",
113
+ "oauth_nonce" => "kllo9940pd9333jh",
114
+ "oauth_version" => "1.0",
115
+ "file" => "vacation.jpg",
116
+ "size" => "original"
114
117
  }
115
118
  expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
116
- "GET&http%3A%2F%2Fphotos.example.net%2F" +
117
- "https%253A%252F%252Fwww.example.com&file%3Dvacation.jpg%26" +
118
- "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" +
119
- "oauth_nonce%3Dkllo9940pd9333jh%26" +
120
- "oauth_signature_method%3DHMAC-SHA1%26" +
121
- "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" +
119
+ "GET&http%3A%2F%2Fphotos.example.net%2F" \
120
+ "https%253A%252F%252Fwww.example.com&file%3Dvacation.jpg%26" \
121
+ "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" \
122
+ "oauth_nonce%3Dkllo9940pd9333jh%26" \
123
+ "oauth_signature_method%3DHMAC-SHA1%26" \
124
+ "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" \
122
125
  "oauth_version%3D1.0%26size%3Doriginal"
123
126
  )
124
127
  end
@@ -127,327 +130,353 @@ describe Signet::OAuth1 do
127
130
  method = "GET"
128
131
  uri = "http://example.com/r%20v/X?id=123"
129
132
  parameters = {
130
- "oauth_consumer_key" => "dpf43f3p2l4k3l03",
131
- "oauth_token" => "nnch734d00sl2jdk",
133
+ "oauth_consumer_key" => "dpf43f3p2l4k3l03",
134
+ "oauth_token" => "nnch734d00sl2jdk",
132
135
  "oauth_signature_method" => "HMAC-SHA1",
133
- "oauth_timestamp" => "1191242096",
134
- "oauth_nonce" => "kllo9940pd9333jh",
135
- "oauth_version" => "1.0"
136
+ "oauth_timestamp" => "1191242096",
137
+ "oauth_nonce" => "kllo9940pd9333jh",
138
+ "oauth_version" => "1.0"
136
139
  }
137
140
  expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
138
- "GET&http%3A%2F%2Fexample.com%2Fr%2520v%2FX&" +
139
- "id%3D123%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" +
140
- "oauth_nonce%3Dkllo9940pd9333jh%26" +
141
- "oauth_signature_method%3DHMAC-SHA1%26" +
142
- "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" +
141
+ "GET&http%3A%2F%2Fexample.com%2Fr%2520v%2FX&" \
142
+ "id%3D123%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" \
143
+ "oauth_nonce%3Dkllo9940pd9333jh%26" \
144
+ "oauth_signature_method%3DHMAC-SHA1%26" \
145
+ "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" \
143
146
  "oauth_version%3D1.0"
144
147
  )
145
148
  end
146
149
 
147
- it 'should correctly generate a base string when port 8080 is specified' do
150
+ it "should correctly generate a base string when port 8080 is specified" do
148
151
  method = "GET"
149
152
  uri = "http://www.example.net:8080/?q=1"
150
153
  parameters = {
151
- "oauth_consumer_key" => "dpf43f3p2l4k3l03",
152
- "oauth_token" => "nnch734d00sl2jdk",
154
+ "oauth_consumer_key" => "dpf43f3p2l4k3l03",
155
+ "oauth_token" => "nnch734d00sl2jdk",
153
156
  "oauth_signature_method" => "HMAC-SHA1",
154
- "oauth_timestamp" => "1191242096",
155
- "oauth_nonce" => "kllo9940pd9333jh",
156
- "oauth_version" => "1.0"
157
+ "oauth_timestamp" => "1191242096",
158
+ "oauth_nonce" => "kllo9940pd9333jh",
159
+ "oauth_version" => "1.0"
157
160
  }
158
161
  expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
159
- "GET&http%3A%2F%2Fwww.example.net%3A8080%2F&" +
160
- "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" +
161
- "oauth_nonce%3Dkllo9940pd9333jh%26" +
162
- "oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26" +
162
+ "GET&http%3A%2F%2Fwww.example.net%3A8080%2F&" \
163
+ "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" \
164
+ "oauth_nonce%3Dkllo9940pd9333jh%26" \
165
+ "oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26" \
163
166
  "oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26q%3D1"
164
167
  )
165
168
  end
166
169
 
167
- it 'should correctly generate a base string when port 80 is specified' do
170
+ it "should correctly generate a base string when port 80 is specified" do
168
171
  method = "GET"
169
172
  uri = "http://photos.example.net:80/photos"
170
173
  parameters = {
171
- "oauth_consumer_key" => "dpf43f3p2l4k3l03",
172
- "oauth_token" => "nnch734d00sl2jdk",
174
+ "oauth_consumer_key" => "dpf43f3p2l4k3l03",
175
+ "oauth_token" => "nnch734d00sl2jdk",
173
176
  "oauth_signature_method" => "HMAC-SHA1",
174
- "oauth_timestamp" => "1191242096",
175
- "oauth_nonce" => "kllo9940pd9333jh",
176
- "oauth_version" => "1.0",
177
- "file" => "vacation.jpg",
178
- "size" => "original"
177
+ "oauth_timestamp" => "1191242096",
178
+ "oauth_nonce" => "kllo9940pd9333jh",
179
+ "oauth_version" => "1.0",
180
+ "file" => "vacation.jpg",
181
+ "size" => "original"
179
182
  }
180
183
  expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
181
- "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" +
182
- "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" +
183
- "oauth_nonce%3Dkllo9940pd9333jh%26" +
184
- "oauth_signature_method%3DHMAC-SHA1%26" +
185
- "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" +
184
+ "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" \
185
+ "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" \
186
+ "oauth_nonce%3Dkllo9940pd9333jh%26" \
187
+ "oauth_signature_method%3DHMAC-SHA1%26" \
188
+ "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" \
186
189
  "oauth_version%3D1.0%26size%3Doriginal"
187
190
  )
188
191
  end
189
192
 
190
- it 'should correctly generate a base string when port 443 is specified' do
193
+ it "should correctly generate a base string when port 443 is specified" do
191
194
  method = "GET"
192
195
  uri = "https://photos.example.net:443/photos"
193
196
  parameters = {
194
- "oauth_consumer_key" => "dpf43f3p2l4k3l03",
195
- "oauth_token" => "nnch734d00sl2jdk",
197
+ "oauth_consumer_key" => "dpf43f3p2l4k3l03",
198
+ "oauth_token" => "nnch734d00sl2jdk",
196
199
  "oauth_signature_method" => "HMAC-SHA1",
197
- "oauth_timestamp" => "1191242096",
198
- "oauth_nonce" => "kllo9940pd9333jh",
199
- "oauth_version" => "1.0",
200
- "file" => "vacation.jpg",
201
- "size" => "original"
200
+ "oauth_timestamp" => "1191242096",
201
+ "oauth_nonce" => "kllo9940pd9333jh",
202
+ "oauth_version" => "1.0",
203
+ "file" => "vacation.jpg",
204
+ "size" => "original"
202
205
  }
203
206
  expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
204
- "GET&https%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" +
205
- "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" +
206
- "oauth_nonce%3Dkllo9940pd9333jh%26" +
207
- "oauth_signature_method%3DHMAC-SHA1%26" +
208
- "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" +
207
+ "GET&https%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" \
208
+ "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" \
209
+ "oauth_nonce%3Dkllo9940pd9333jh%26" \
210
+ "oauth_signature_method%3DHMAC-SHA1%26" \
211
+ "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" \
209
212
  "oauth_version%3D1.0%26size%3Doriginal"
210
213
  )
211
214
  end
212
215
 
213
- it 'should correctly generate a base signature with uppercase scheme' do
214
- method = 'GET'
216
+ it "should correctly generate a base signature with uppercase scheme" do
217
+ method = "GET"
215
218
  uri =
216
219
  "HTTP://photos.example.net/photos?file=vacation.jpg"
217
220
  parameters = {
218
- "oauth_consumer_key" => "dpf43f3p2l4k3l03",
219
- "oauth_token" => "nnch734d00sl2jdk",
221
+ "oauth_consumer_key" => "dpf43f3p2l4k3l03",
222
+ "oauth_token" => "nnch734d00sl2jdk",
220
223
  "oauth_signature_method" => "HMAC-SHA1",
221
- "oauth_timestamp" => "1191242096",
222
- "oauth_nonce" => "kllo9940pd9333jh",
223
- "oauth_version" => "1.0",
224
- "size" => "original"
224
+ "oauth_timestamp" => "1191242096",
225
+ "oauth_nonce" => "kllo9940pd9333jh",
226
+ "oauth_version" => "1.0",
227
+ "size" => "original"
225
228
  }
226
229
  expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
227
- "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" +
228
- "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" +
229
- "oauth_nonce%3Dkllo9940pd9333jh%26" +
230
- "oauth_signature_method%3DHMAC-SHA1%26" +
231
- "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" +
230
+ "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" \
231
+ "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" \
232
+ "oauth_nonce%3Dkllo9940pd9333jh%26" \
233
+ "oauth_signature_method%3DHMAC-SHA1%26" \
234
+ "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" \
232
235
  "oauth_version%3D1.0%26size%3Doriginal"
233
236
  )
234
237
  end
235
238
 
236
- it 'should correctly generate a base signature with mixedcase authority' do
237
- method = 'GET'
239
+ it "should correctly generate a base signature with mixedcase authority" do
240
+ method = "GET"
238
241
  uri =
239
242
  "http://photos.eXaMpLe.NET/photos?file=vacation.jpg"
240
243
  parameters = {
241
- "oauth_consumer_key" => "dpf43f3p2l4k3l03",
242
- "oauth_token" => "nnch734d00sl2jdk",
244
+ "oauth_consumer_key" => "dpf43f3p2l4k3l03",
245
+ "oauth_token" => "nnch734d00sl2jdk",
243
246
  "oauth_signature_method" => "HMAC-SHA1",
244
- "oauth_timestamp" => "1191242096",
245
- "oauth_nonce" => "kllo9940pd9333jh",
246
- "oauth_version" => "1.0",
247
- "size" => "original"
247
+ "oauth_timestamp" => "1191242096",
248
+ "oauth_nonce" => "kllo9940pd9333jh",
249
+ "oauth_version" => "1.0",
250
+ "size" => "original"
248
251
  }
249
252
  expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
250
- "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" +
251
- "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" +
252
- "oauth_nonce%3Dkllo9940pd9333jh%26" +
253
- "oauth_signature_method%3DHMAC-SHA1%26" +
254
- "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" +
253
+ "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" \
254
+ "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" \
255
+ "oauth_nonce%3Dkllo9940pd9333jh%26" \
256
+ "oauth_signature_method%3DHMAC-SHA1%26" \
257
+ "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" \
255
258
  "oauth_version%3D1.0%26size%3Doriginal"
256
259
  )
257
260
  end
258
261
 
259
- it 'should correctly generate a base signature with a method symbol' do
262
+ it "should correctly generate a base signature with a method symbol" do
260
263
  method = :get
261
264
  uri =
262
265
  "http://photos.example.net/photos?file=vacation.jpg"
263
266
  parameters = {
264
- "oauth_consumer_key" => "dpf43f3p2l4k3l03",
265
- "oauth_token" => "nnch734d00sl2jdk",
267
+ "oauth_consumer_key" => "dpf43f3p2l4k3l03",
268
+ "oauth_token" => "nnch734d00sl2jdk",
266
269
  "oauth_signature_method" => "HMAC-SHA1",
267
- "oauth_timestamp" => "1191242096",
268
- "oauth_nonce" => "kllo9940pd9333jh",
269
- "oauth_version" => "1.0",
270
- "size" => "original"
270
+ "oauth_timestamp" => "1191242096",
271
+ "oauth_nonce" => "kllo9940pd9333jh",
272
+ "oauth_version" => "1.0",
273
+ "size" => "original"
271
274
  }
272
275
  expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
273
- "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" +
274
- "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" +
275
- "oauth_nonce%3Dkllo9940pd9333jh%26" +
276
- "oauth_signature_method%3DHMAC-SHA1%26" +
277
- "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" +
276
+ "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" \
277
+ "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" \
278
+ "oauth_nonce%3Dkllo9940pd9333jh%26" \
279
+ "oauth_signature_method%3DHMAC-SHA1%26" \
280
+ "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" \
278
281
  "oauth_version%3D1.0%26size%3Doriginal"
279
282
  )
280
283
  end
281
284
 
282
- it 'should correctly generate an authorization header' do
285
+ it "should correctly generate a base signature with duplicated query params" do
286
+ method = "GET"
287
+ uri = "http://photos.example.net/photos?foo=bar&foo=baz&foo=qux"
288
+ parameters = {
289
+ "oauth_consumer_key" => "dpf43f3p2l4k3l03",
290
+ "oauth_token" => "nnch734d00sl2jdk",
291
+ "oauth_signature_method" => "HMAC-SHA1",
292
+ "oauth_timestamp" => "1191242096",
293
+ "oauth_nonce" => "kllo9940pd9333jh",
294
+ "oauth_version" => "1.0",
295
+ "file" => "vacation.jpg",
296
+ "size" => "original"
297
+ }
298
+ expect(Signet::OAuth1.generate_base_string(method, uri, parameters)).to eq(
299
+ "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26" \
300
+ "foo%3Dbar%26" \
301
+ "foo%3Dbaz%26" \
302
+ "foo%3Dqux%26" \
303
+ "oauth_consumer_key%3Ddpf43f3p2l4k3l03%26" \
304
+ "oauth_nonce%3Dkllo9940pd9333jh%26" \
305
+ "oauth_signature_method%3DHMAC-SHA1%26" \
306
+ "oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26" \
307
+ "oauth_version%3D1.0%26size%3Doriginal"
308
+ )
309
+ end
310
+
311
+ it "should correctly generate an authorization header" do
283
312
  parameters = [
284
- ["oauth_consumer_key", "0685bd9184jfhq22"],
285
- ["oauth_token", "ad180jjd733klru7"],
313
+ %w[oauth_consumer_key 0685bd9184jfhq22],
314
+ %w[oauth_token ad180jjd733klru7],
286
315
  ["oauth_signature_method", "HMAC-SHA1"],
287
316
  ["oauth_signature", "wOJIO9A2W5mFwDgiDvZbTSMK/PY="],
288
- ["oauth_timestamp", "137131200"],
289
- ["oauth_nonce", "4572616e48616d6d65724c61686176"],
317
+ %w[oauth_timestamp 137131200],
318
+ %w[oauth_nonce 4572616e48616d6d65724c61686176],
290
319
  ["oauth_version", "1.0"]
291
320
  ]
292
321
  expect(Signet::OAuth1.generate_authorization_header(
293
- parameters, "http://sp.example.com/"
294
- )).to eq (
295
- 'OAuth realm="http://sp.example.com/", ' +
296
- 'oauth_consumer_key="0685bd9184jfhq22", ' +
297
- 'oauth_token="ad180jjd733klru7", ' +
298
- 'oauth_signature_method="HMAC-SHA1", ' +
299
- 'oauth_signature="wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D", ' +
300
- 'oauth_timestamp="137131200", ' +
301
- 'oauth_nonce="4572616e48616d6d65724c61686176", ' +
302
- 'oauth_version="1.0"'
303
- )
304
- end
305
-
306
- it 'should raise an error if generating an authorization header ' +
307
- 'with bogus values' do
322
+ parameters, "http://sp.example.com/"
323
+ )).to eq(
324
+ 'OAuth realm="http://sp.example.com/", ' \
325
+ 'oauth_consumer_key="0685bd9184jfhq22", ' \
326
+ 'oauth_token="ad180jjd733klru7", ' \
327
+ 'oauth_signature_method="HMAC-SHA1", ' \
328
+ 'oauth_signature="wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D", ' \
329
+ 'oauth_timestamp="137131200", ' \
330
+ 'oauth_nonce="4572616e48616d6d65724c61686176", ' \
331
+ 'oauth_version="1.0"'
332
+ )
333
+ end
334
+
335
+ it "should raise an error if generating an authorization header " \
336
+ "with bogus values" do
308
337
  expect(lambda do
309
- Signet::OAuth1.generate_authorization_header(42)
338
+ Signet::OAuth1.generate_authorization_header 42
310
339
  end).to raise_error(TypeError)
311
340
  end
312
341
 
313
- it 'should raise an error if generating an authorization header ' +
314
- 'with the "realm" parameter specified the wrong way' do
342
+ it "should raise an error if generating an authorization header " \
343
+ 'with the "realm" parameter specified the wrong way' do
315
344
  parameters = [
316
345
  ["realm", "http://sp.example.com/"],
317
- ["oauth_consumer_key", "0685bd9184jfhq22"],
318
- ["oauth_token", "ad180jjd733klru7"],
346
+ %w[oauth_consumer_key 0685bd9184jfhq22],
347
+ %w[oauth_token ad180jjd733klru7],
319
348
  ["oauth_signature_method", "HMAC-SHA1"],
320
349
  ["oauth_signature", "wOJIO9A2W5mFwDgiDvZbTSMK/PY="],
321
- ["oauth_timestamp", "137131200"],
322
- ["oauth_nonce", "4572616e48616d6d65724c61686176"],
350
+ %w[oauth_timestamp 137131200],
351
+ %w[oauth_nonce 4572616e48616d6d65724c61686176],
323
352
  ["oauth_version", "1.0"]
324
353
  ]
325
354
  expect(lambda do
326
- Signet::OAuth1.generate_authorization_header(parameters)
355
+ Signet::OAuth1.generate_authorization_header parameters
327
356
  end).to raise_error(ArgumentError)
328
357
  end
329
358
 
330
- it 'should correctly parse an authorization header' do
359
+ it "should correctly parse an authorization header" do
331
360
  parameters = Signet::OAuth1.parse_authorization_header(
332
- 'OAuth realm="http://sp.example.com/", ' +
333
- 'oauth_consumer_key="0685bd9184jfhq22", ' +
334
- 'oauth_token="ad180jjd733klru7", ' +
335
- 'oauth_signature_method="HMAC-SHA1", ' +
336
- 'oauth_signature="wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D", ' +
337
- 'oauth_timestamp="137131200", ' +
338
- 'oauth_nonce="4572616e48616d6d65724c61686176", ' +
361
+ 'OAuth realm="http://sp.example.com/", ' \
362
+ 'oauth_consumer_key="0685bd9184jfhq22", ' \
363
+ 'oauth_token="ad180jjd733klru7", ' \
364
+ 'oauth_signature_method="HMAC-SHA1", ' \
365
+ 'oauth_signature="wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D", ' \
366
+ 'oauth_timestamp="137131200", ' \
367
+ 'oauth_nonce="4572616e48616d6d65724c61686176", ' \
339
368
  'oauth_version="1.0"'
340
- ).inject({}) { |h,(k,v)| h[k]=v; h }
341
- expect(parameters['realm']).to eq 'http://sp.example.com/'
342
- expect(parameters['oauth_consumer_key']).to eq '0685bd9184jfhq22'
343
- expect(parameters['oauth_token']).to eq 'ad180jjd733klru7'
344
- expect(parameters['oauth_signature_method']).to eq 'HMAC-SHA1'
345
- expect(parameters['oauth_signature']).to eq 'wOJIO9A2W5mFwDgiDvZbTSMK/PY='
346
- expect(parameters['oauth_timestamp']).to eq '137131200'
347
- expect(parameters['oauth_nonce']).to eq '4572616e48616d6d65724c61686176'
348
- expect(parameters['oauth_version']).to eq '1.0'
349
- end
350
-
351
- it 'should not unescape a realm in an authorization header' do
369
+ ).each_with_object({}) { |(k, v), h| h[k] = v; }
370
+ expect(parameters["realm"]).to eq "http://sp.example.com/"
371
+ expect(parameters["oauth_consumer_key"]).to eq "0685bd9184jfhq22"
372
+ expect(parameters["oauth_token"]).to eq "ad180jjd733klru7"
373
+ expect(parameters["oauth_signature_method"]).to eq "HMAC-SHA1"
374
+ expect(parameters["oauth_signature"]).to eq "wOJIO9A2W5mFwDgiDvZbTSMK/PY="
375
+ expect(parameters["oauth_timestamp"]).to eq "137131200"
376
+ expect(parameters["oauth_nonce"]).to eq "4572616e48616d6d65724c61686176"
377
+ expect(parameters["oauth_version"]).to eq "1.0"
378
+ end
379
+
380
+ it "should not unescape a realm in an authorization header" do
352
381
  parameters = Signet::OAuth1.parse_authorization_header(
353
- 'OAuth realm="http%3A%2F%2Fsp.example.com%2F", ' +
354
- 'domain="http%3A%2F%2Fsp.example.com%2F", ' +
355
- 'oauth_consumer_key="0685bd9184jfhq22", ' +
356
- 'oauth_token="ad180jjd733klru7", ' +
357
- 'oauth_signature_method="HMAC-SHA1", ' +
358
- 'oauth_signature="wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D", ' +
359
- 'oauth_timestamp="137131200", ' +
360
- 'oauth_nonce="4572616e48616d6d65724c61686176", ' +
382
+ 'OAuth realm="http%3A%2F%2Fsp.example.com%2F", ' \
383
+ 'domain="http%3A%2F%2Fsp.example.com%2F", ' \
384
+ 'oauth_consumer_key="0685bd9184jfhq22", ' \
385
+ 'oauth_token="ad180jjd733klru7", ' \
386
+ 'oauth_signature_method="HMAC-SHA1", ' \
387
+ 'oauth_signature="wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D", ' \
388
+ 'oauth_timestamp="137131200", ' \
389
+ 'oauth_nonce="4572616e48616d6d65724c61686176", ' \
361
390
  'oauth_version="1.0"'
362
- ).inject({}) { |h,(k,v)| h[k]=v; h }
363
- expect(parameters['realm']).to eq 'http%3A%2F%2Fsp.example.com%2F'
364
- expect(parameters['domain']).to eq 'http://sp.example.com/'
365
- expect(parameters['oauth_consumer_key']).to eq '0685bd9184jfhq22'
366
- expect(parameters['oauth_token']).to eq 'ad180jjd733klru7'
367
- expect(parameters['oauth_signature_method']).to eq 'HMAC-SHA1'
368
- expect(parameters['oauth_signature']).to eq 'wOJIO9A2W5mFwDgiDvZbTSMK/PY='
369
- expect(parameters['oauth_timestamp']).to eq '137131200'
370
- expect(parameters['oauth_nonce']).to eq '4572616e48616d6d65724c61686176'
371
- expect(parameters['oauth_version']).to eq '1.0'
372
- end
373
-
374
- it 'should raise an error if parsing an authorization header ' +
375
- 'with bogus values' do
391
+ ).each_with_object({}) { |(k, v), h| h[k] = v; }
392
+ expect(parameters["realm"]).to eq "http%3A%2F%2Fsp.example.com%2F"
393
+ expect(parameters["domain"]).to eq "http://sp.example.com/"
394
+ expect(parameters["oauth_consumer_key"]).to eq "0685bd9184jfhq22"
395
+ expect(parameters["oauth_token"]).to eq "ad180jjd733klru7"
396
+ expect(parameters["oauth_signature_method"]).to eq "HMAC-SHA1"
397
+ expect(parameters["oauth_signature"]).to eq "wOJIO9A2W5mFwDgiDvZbTSMK/PY="
398
+ expect(parameters["oauth_timestamp"]).to eq "137131200"
399
+ expect(parameters["oauth_nonce"]).to eq "4572616e48616d6d65724c61686176"
400
+ expect(parameters["oauth_version"]).to eq "1.0"
401
+ end
402
+
403
+ it "should raise an error if parsing an authorization header " \
404
+ "with bogus values" do
376
405
  expect(lambda do
377
- Signet::OAuth1.parse_authorization_header(42)
406
+ Signet::OAuth1.parse_authorization_header 42
378
407
  end).to raise_error(TypeError)
379
408
  end
380
409
 
381
- it 'should raise an error if parsing a non-OAuth authorization header' do
410
+ it "should raise an error if parsing a non-OAuth authorization header" do
382
411
  expect(lambda do
383
412
  Signet::OAuth1.parse_authorization_header(
384
- 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
413
+ "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="
385
414
  )
386
415
  end).to raise_error(Signet::ParseError)
387
416
  end
388
417
 
389
- it 'should correctly parse a form encoded credential' do
418
+ it "should correctly parse a form encoded credential" do
390
419
  credential = Signet::OAuth1.parse_form_encoded_credentials(
391
- 'oauth_token=hh5s93j4hdidpola&oauth_token_secret=hdhd0244k9j7ao03'
420
+ "oauth_token=hh5s93j4hdidpola&oauth_token_secret=hdhd0244k9j7ao03"
392
421
  )
393
- expect(credential.key).to eq 'hh5s93j4hdidpola'
394
- expect(credential.secret).to eq 'hdhd0244k9j7ao03'
422
+ expect(credential.key).to eq "hh5s93j4hdidpola"
423
+ expect(credential.secret).to eq "hdhd0244k9j7ao03"
395
424
  end
396
425
 
397
- it 'should correctly parse a form encoded credential' do
426
+ it "should correctly parse a form encoded credential" do
398
427
  credential = Signet::OAuth1.parse_form_encoded_credentials(
399
- 'oauth_token=hdk48Djdsa&oauth_token_secret=xyz4992k83j47x0b&' +
400
- 'oauth_callback_confirmed=true'
428
+ "oauth_token=hdk48Djdsa&oauth_token_secret=xyz4992k83j47x0b&" \
429
+ "oauth_callback_confirmed=true"
401
430
  )
402
- expect(credential.key).to eq 'hdk48Djdsa'
403
- expect(credential.secret).to eq 'xyz4992k83j47x0b'
431
+ expect(credential.key).to eq "hdk48Djdsa"
432
+ expect(credential.secret).to eq "xyz4992k83j47x0b"
404
433
  end
405
434
 
406
- it 'should raise an error if parsing a form encoded credential ' +
407
- 'with bogus values' do
435
+ it "should raise an error if parsing a form encoded credential " \
436
+ "with bogus values" do
408
437
  expect(lambda do
409
- Signet::OAuth1.parse_form_encoded_credentials(42)
438
+ Signet::OAuth1.parse_form_encoded_credentials 42
410
439
  end).to raise_error(TypeError)
411
440
  end
412
441
 
413
- it 'should correctly generate a signature for a set of parameters' do
442
+ it "should correctly generate a signature for a set of parameters" do
414
443
  method = :get
415
444
  uri = "http://photos.example.net/photos"
416
- client_credential_secret = 'kd94hf93k423kf44'
417
- token_credential_secret = 'pfkkdhi9sl3r4s00'
445
+ client_credential_secret = "kd94hf93k423kf44"
446
+ token_credential_secret = "pfkkdhi9sl3r4s00"
418
447
  parameters = {
419
- "oauth_consumer_key" => "dpf43f3p2l4k3l03",
420
- "oauth_token" => "nnch734d00sl2jdk",
448
+ "oauth_consumer_key" => "dpf43f3p2l4k3l03",
449
+ "oauth_token" => "nnch734d00sl2jdk",
421
450
  "oauth_signature_method" => "HMAC-SHA1",
422
- "oauth_timestamp" => "1191242096",
423
- "oauth_nonce" => "kllo9940pd9333jh",
424
- "oauth_version" => "1.0",
425
- "file" => "vacation.jpg",
426
- "size" => "original"
451
+ "oauth_timestamp" => "1191242096",
452
+ "oauth_nonce" => "kllo9940pd9333jh",
453
+ "oauth_version" => "1.0",
454
+ "file" => "vacation.jpg",
455
+ "size" => "original"
427
456
  }
428
457
  expect(Signet::OAuth1.sign_parameters(
429
- method,
430
- uri,
431
- parameters,
432
- client_credential_secret,
433
- token_credential_secret
434
- )).to eq "tR3+Ty81lMeYAr/Fid0kMTYa/WM="
458
+ method,
459
+ uri,
460
+ parameters,
461
+ client_credential_secret,
462
+ token_credential_secret
463
+ )).to eq "tR3+Ty81lMeYAr/Fid0kMTYa/WM="
435
464
  end
436
465
 
437
- it 'should raise an error when trying to sign with with unknown method' do
466
+ it "should raise an error when trying to sign with with unknown method" do
438
467
  method = :get
439
468
  uri = "http://photos.example.net/photos"
440
- client_credential_secret = 'kd94hf93k423kf44'
441
- token_credential_secret = 'pfkkdhi9sl3r4s00'
469
+ client_credential_secret = "kd94hf93k423kf44"
470
+ token_credential_secret = "pfkkdhi9sl3r4s00"
442
471
  parameters = {
443
- "oauth_consumer_key" => "dpf43f3p2l4k3l03",
444
- "oauth_token" => "nnch734d00sl2jdk",
472
+ "oauth_consumer_key" => "dpf43f3p2l4k3l03",
473
+ "oauth_token" => "nnch734d00sl2jdk",
445
474
  "oauth_signature_method" => "HMAC-BOGUS", # Unknown signature method
446
- "oauth_timestamp" => "1191242096",
447
- "oauth_nonce" => "kllo9940pd9333jh",
448
- "oauth_version" => "1.0",
449
- "file" => "vacation.jpg",
450
- "size" => "original"
475
+ "oauth_timestamp" => "1191242096",
476
+ "oauth_nonce" => "kllo9940pd9333jh",
477
+ "oauth_version" => "1.0",
478
+ "file" => "vacation.jpg",
479
+ "size" => "original"
451
480
  }
452
481
  expect(lambda do
453
482
  Signet::OAuth1.sign_parameters(
@@ -460,548 +489,548 @@ describe Signet::OAuth1 do
460
489
  end).to raise_error(NotImplementedError)
461
490
  end
462
491
 
463
- it 'should correctly generate authorization URIs' do
464
- authorization_uri = 'http://photos.example.net/authorize'
465
- temporary_credential_key = 'hh5s93j4hdidpola'
466
- callback = 'http://printer.example.com/request_token_ready'
492
+ it "should correctly generate authorization URIs" do
493
+ authorization_uri = "http://photos.example.net/authorize"
494
+ temporary_credential_key = "hh5s93j4hdidpola"
495
+ callback = "http://printer.example.com/request_token_ready"
467
496
  parsed_uri = Addressable::URI.parse(
468
- Signet::OAuth1.generate_authorization_uri(
497
+ Signet::OAuth1.generate_authorization_uri(
469
498
  authorization_uri,
470
- :temporary_credential_key => temporary_credential_key,
471
- :callback => callback
499
+ temporary_credential_key: temporary_credential_key,
500
+ callback: callback
472
501
  )
473
502
  )
474
- expect(parsed_uri.query_values).to have_key('oauth_token')
475
- expect(parsed_uri.query_values['oauth_token']).to eq temporary_credential_key
476
- expect(parsed_uri.query_values).to have_key('oauth_callback')
477
- expect(parsed_uri.query_values['oauth_callback']).to eq callback
503
+ expect(parsed_uri.query_values).to have_key("oauth_token")
504
+ expect(parsed_uri.query_values["oauth_token"]).to eq temporary_credential_key
505
+ expect(parsed_uri.query_values).to have_key("oauth_callback")
506
+ expect(parsed_uri.query_values["oauth_callback"]).to eq callback
478
507
  end
479
508
  end
480
509
 
481
- describe Signet::OAuth1, 'when generating temporary credentials parameters' do
510
+ describe Signet::OAuth1, "when generating temporary credentials parameters" do
482
511
  before do
483
- @client_credential_key = 'dpf43f3p2l4k3l03'
484
- @callback = 'http://printer.example.com/request_token_ready'
485
- @signature_method = 'HMAC-SHA1'
486
- @scope = 'http://photos.example.com/full_access'
487
- @additional_parameters = [['scope', @scope]]
512
+ @client_credential_key = "dpf43f3p2l4k3l03"
513
+ @callback = "http://printer.example.com/request_token_ready"
514
+ @signature_method = "HMAC-SHA1"
515
+ @scope = "http://photos.example.com/full_access"
516
+ @additional_parameters = [["scope", @scope]]
488
517
  @unsigned_parameters =
489
518
  Signet::OAuth1.unsigned_temporary_credential_parameters(
490
- :client_credential_key => @client_credential_key,
491
- :callback => @callback,
492
- :signature_method => @signature_method,
493
- :additional_parameters => @additional_parameters
494
- ).inject({}) { |h,(k,v)| h[k]=v; h }
519
+ client_credential_key: @client_credential_key,
520
+ callback: @callback,
521
+ signature_method: @signature_method,
522
+ additional_parameters: @additional_parameters
523
+ ).each_with_object({}) { |(k, v), h| h[k] = v; }
495
524
  end
496
525
 
497
- it 'should raise an error if the client credential key is missing' do
526
+ it "should raise an error if the client credential key is missing" do
498
527
  expect(lambda do
499
528
  Signet::OAuth1.unsigned_temporary_credential_parameters(
500
- :client_credential_key => nil,
501
- :callback => @callback,
502
- :signature_method => @signature_method,
503
- :additional_parameters => @additional_parameters
529
+ client_credential_key: nil,
530
+ callback: @callback,
531
+ signature_method: @signature_method,
532
+ additional_parameters: @additional_parameters
504
533
  )
505
534
  end).to raise_error(ArgumentError)
506
535
  end
507
536
 
508
- it 'should have the correct client credential key' do
509
- expect(@unsigned_parameters).to have_key('oauth_consumer_key')
510
- expect(@unsigned_parameters['oauth_consumer_key']).to eq @client_credential_key
537
+ it "should have the correct client credential key" do
538
+ expect(@unsigned_parameters).to have_key("oauth_consumer_key")
539
+ expect(@unsigned_parameters["oauth_consumer_key"]).to eq @client_credential_key
511
540
  end
512
541
 
513
- it 'should have the correct signature method' do
514
- expect(@unsigned_parameters).to have_key('oauth_signature_method')
515
- expect(@unsigned_parameters['oauth_signature_method']).to eq @signature_method
542
+ it "should have the correct signature method" do
543
+ expect(@unsigned_parameters).to have_key("oauth_signature_method")
544
+ expect(@unsigned_parameters["oauth_signature_method"]).to eq @signature_method
516
545
  end
517
546
 
518
- it 'should have a valid timestamp' do
547
+ it "should have a valid timestamp" do
519
548
  # Verify that we have a timestamp, it's in the correct format and within
520
549
  # a reasonable range of the current time.
521
- expect(@unsigned_parameters).to have_key('oauth_timestamp')
522
- expect(@unsigned_parameters['oauth_timestamp']).to match(/^[0-9]+$/)
523
- expect(@unsigned_parameters['oauth_timestamp'].to_i).to be <= Time.now.to_i
524
- expect(@unsigned_parameters['oauth_timestamp'].to_i).to be >= Time.now.to_i - 1
550
+ expect(@unsigned_parameters).to have_key("oauth_timestamp")
551
+ expect(@unsigned_parameters["oauth_timestamp"]).to match(/^[0-9]+$/)
552
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be <= Time.now.to_i
553
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be >= Time.now.to_i - 1
525
554
  end
526
555
 
527
- it 'should have a valid nonce' do
556
+ it "should have a valid nonce" do
528
557
  # Verify that we have a nonce and that it has sufficient length for
529
558
  # uniqueness.
530
- expect(@unsigned_parameters).to have_key('oauth_nonce')
531
- expect(@unsigned_parameters['oauth_nonce']).to match(/^[0-9a-zA-Z]{16,100}$/)
559
+ expect(@unsigned_parameters).to have_key("oauth_nonce")
560
+ expect(@unsigned_parameters["oauth_nonce"]).to match(/^[0-9a-zA-Z]{16,100}$/)
532
561
  end
533
562
 
534
- it 'should have the correct callback' do
535
- expect(@unsigned_parameters).to have_key('oauth_callback')
536
- expect(@unsigned_parameters['oauth_callback']).to eq @callback
563
+ it "should have the correct callback" do
564
+ expect(@unsigned_parameters).to have_key("oauth_callback")
565
+ expect(@unsigned_parameters["oauth_callback"]).to eq @callback
537
566
  end
538
567
 
539
- it 'should have the correct scope parameter' do
540
- expect(@unsigned_parameters).to have_key('scope')
541
- expect(@unsigned_parameters['scope']).to eq @scope
568
+ it "should have the correct scope parameter" do
569
+ expect(@unsigned_parameters).to have_key("scope")
570
+ expect(@unsigned_parameters["scope"]).to eq @scope
542
571
  end
543
572
 
544
- it 'should have the correct OAuth version' do
545
- expect(@unsigned_parameters).to have_key('oauth_version')
546
- expect(@unsigned_parameters['oauth_version']).to eq '1.0'
573
+ it "should have the correct OAuth version" do
574
+ expect(@unsigned_parameters).to have_key("oauth_version")
575
+ expect(@unsigned_parameters["oauth_version"]).to eq "1.0"
547
576
  end
548
577
  end
549
578
 
550
- describe Signet::OAuth1, 'when generating token credential parameters' do
579
+ describe Signet::OAuth1, "when generating token credential parameters" do
551
580
  before do
552
- @client_credential_key = 'dpf43f3p2l4k3l03'
553
- @temporary_credential_key = 'hh5s93j4hdidpola'
554
- @verifier = '473f82d3'
555
- @signature_method = 'HMAC-SHA1'
581
+ @client_credential_key = "dpf43f3p2l4k3l03"
582
+ @temporary_credential_key = "hh5s93j4hdidpola"
583
+ @verifier = "473f82d3"
584
+ @signature_method = "HMAC-SHA1"
556
585
  @unsigned_parameters =
557
586
  Signet::OAuth1.unsigned_token_credential_parameters(
558
- :client_credential_key => @client_credential_key,
559
- :temporary_credential_key => @temporary_credential_key,
560
- :signature_method => @signature_method,
561
- :verifier => @verifier
562
- ).inject({}) { |h,(k,v)| h[k]=v; h }
587
+ client_credential_key: @client_credential_key,
588
+ temporary_credential_key: @temporary_credential_key,
589
+ signature_method: @signature_method,
590
+ verifier: @verifier
591
+ ).each_with_object({}) { |(k, v), h| h[k] = v; }
563
592
  end
564
593
 
565
- it 'should raise an error if the client credential key is missing' do
594
+ it "should raise an error if the client credential key is missing" do
566
595
  expect(lambda do
567
596
  Signet::OAuth1.unsigned_token_credential_parameters(
568
- :client_credential_key => nil,
569
- :temporary_credential_key => @temporary_credential_key,
570
- :signature_method => @signature_method,
571
- :verifier => @verifier
597
+ client_credential_key: nil,
598
+ temporary_credential_key: @temporary_credential_key,
599
+ signature_method: @signature_method,
600
+ verifier: @verifier
572
601
  )
573
602
  end).to raise_error(ArgumentError)
574
603
  end
575
604
 
576
- it 'should raise an error if the temporary credential key is missing' do
605
+ it "should raise an error if the temporary credential key is missing" do
577
606
  expect(lambda do
578
607
  Signet::OAuth1.unsigned_token_credential_parameters(
579
- :client_credential_key => @client_credential_key,
580
- :temporary_credential_key => nil,
581
- :signature_method => @signature_method,
582
- :verifier => @verifier
608
+ client_credential_key: @client_credential_key,
609
+ temporary_credential_key: nil,
610
+ signature_method: @signature_method,
611
+ verifier: @verifier
583
612
  )
584
613
  end).to raise_error(ArgumentError)
585
614
  end
586
615
 
587
- it 'should raise an error if the verifier is missing' do
616
+ it "should raise an error if the verifier is missing" do
588
617
  expect(lambda do
589
618
  Signet::OAuth1.unsigned_token_credential_parameters(
590
- :client_credential_key => @client_credential_key,
591
- :temporary_credential_key => @temporary_credential_key,
592
- :signature_method => @signature_method,
593
- :verifier => nil
619
+ client_credential_key: @client_credential_key,
620
+ temporary_credential_key: @temporary_credential_key,
621
+ signature_method: @signature_method,
622
+ verifier: nil
594
623
  )
595
624
  end).to raise_error(ArgumentError)
596
625
  end
597
626
 
598
- it 'should have the correct client credential key' do
599
- expect(@unsigned_parameters).to have_key('oauth_consumer_key')
600
- expect(@unsigned_parameters['oauth_consumer_key']).to eq @client_credential_key
627
+ it "should have the correct client credential key" do
628
+ expect(@unsigned_parameters).to have_key("oauth_consumer_key")
629
+ expect(@unsigned_parameters["oauth_consumer_key"]).to eq @client_credential_key
601
630
  end
602
631
 
603
- it 'should have the correct temporary credentials key' do
604
- expect(@unsigned_parameters).to have_key('oauth_token')
605
- expect(@unsigned_parameters['oauth_token']).to eq @temporary_credential_key
632
+ it "should have the correct temporary credentials key" do
633
+ expect(@unsigned_parameters).to have_key("oauth_token")
634
+ expect(@unsigned_parameters["oauth_token"]).to eq @temporary_credential_key
606
635
  end
607
636
 
608
- it 'should have the correct signature method' do
609
- expect(@unsigned_parameters).to have_key('oauth_signature_method')
610
- expect(@unsigned_parameters['oauth_signature_method']).to eq @signature_method
637
+ it "should have the correct signature method" do
638
+ expect(@unsigned_parameters).to have_key("oauth_signature_method")
639
+ expect(@unsigned_parameters["oauth_signature_method"]).to eq @signature_method
611
640
  end
612
641
 
613
- it 'should have a valid timestamp' do
642
+ it "should have a valid timestamp" do
614
643
  # Verify that we have a timestamp, it's in the correct format and within
615
644
  # a reasonable range of the current time.
616
- expect(@unsigned_parameters).to have_key('oauth_timestamp')
617
- expect(@unsigned_parameters['oauth_timestamp']).to match(/^[0-9]+$/)
618
- expect(@unsigned_parameters['oauth_timestamp'].to_i).to be <= Time.now.to_i
619
- expect(@unsigned_parameters['oauth_timestamp'].to_i).to be >= Time.now.to_i - 1
645
+ expect(@unsigned_parameters).to have_key("oauth_timestamp")
646
+ expect(@unsigned_parameters["oauth_timestamp"]).to match(/^[0-9]+$/)
647
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be <= Time.now.to_i
648
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be >= Time.now.to_i - 1
620
649
  end
621
650
 
622
- it 'should have a valid nonce' do
651
+ it "should have a valid nonce" do
623
652
  # Verify that we have a nonce and that it has sufficient length for
624
653
  # uniqueness.
625
- expect(@unsigned_parameters).to have_key('oauth_nonce')
626
- expect(@unsigned_parameters['oauth_nonce']).to match(/^[0-9a-zA-Z]{16,100}$/)
654
+ expect(@unsigned_parameters).to have_key("oauth_nonce")
655
+ expect(@unsigned_parameters["oauth_nonce"]).to match(/^[0-9a-zA-Z]{16,100}$/)
627
656
  end
628
657
 
629
- it 'should have the verifier' do
630
- expect(@unsigned_parameters).to have_key('oauth_verifier')
631
- expect(@unsigned_parameters['oauth_verifier']).to eq @verifier
658
+ it "should have the verifier" do
659
+ expect(@unsigned_parameters).to have_key("oauth_verifier")
660
+ expect(@unsigned_parameters["oauth_verifier"]).to eq @verifier
632
661
  end
633
662
 
634
- it 'should have the correct OAuth version' do
635
- expect(@unsigned_parameters).to have_key('oauth_version')
636
- expect(@unsigned_parameters['oauth_version']).to eq '1.0'
663
+ it "should have the correct OAuth version" do
664
+ expect(@unsigned_parameters).to have_key("oauth_version")
665
+ expect(@unsigned_parameters["oauth_version"]).to eq "1.0"
637
666
  end
638
667
  end
639
668
 
640
- describe Signet::OAuth1, 'when generating protected resource parameters' do
669
+ describe Signet::OAuth1, "when generating protected resource parameters" do
641
670
  before do
642
- @client_credential_key = 'dpf43f3p2l4k3l03'
643
- @token_credential_key = 'nnch734d00sl2jdk'
644
- @signature_method = 'HMAC-SHA1'
671
+ @client_credential_key = "dpf43f3p2l4k3l03"
672
+ @token_credential_key = "nnch734d00sl2jdk"
673
+ @signature_method = "HMAC-SHA1"
645
674
  @unsigned_parameters =
646
675
  Signet::OAuth1.unsigned_resource_parameters(
647
- :client_credential_key => @client_credential_key,
648
- :token_credential_key => @token_credential_key,
649
- :signature_method => @signature_method
650
- ).inject({}) { |h,(k,v)| h[k]=v; h }
676
+ client_credential_key: @client_credential_key,
677
+ token_credential_key: @token_credential_key,
678
+ signature_method: @signature_method
679
+ ).each_with_object({}) { |(k, v), h| h[k] = v; }
651
680
  end
652
681
 
653
- it 'should raise an error if the client credential key is missing' do
682
+ it "should raise an error if the client credential key is missing" do
654
683
  expect(lambda do
655
684
  Signet::OAuth1.unsigned_resource_parameters(
656
- :client_credential_key => nil,
657
- :token_credential_key => @token_credential_key,
658
- :signature_method => @signature_method
685
+ client_credential_key: nil,
686
+ token_credential_key: @token_credential_key,
687
+ signature_method: @signature_method
659
688
  )
660
689
  end).to raise_error(ArgumentError)
661
690
  end
662
691
 
663
- it 'should raise an error if the token credential key is missing' do
692
+ it "should raise an error if the token credential key is missing" do
664
693
  expect(lambda do
665
694
  Signet::OAuth1.unsigned_resource_parameters(
666
- :client_credential_key => @client_credential_key,
667
- :token_credential_key => nil,
668
- :signature_method => @signature_method
695
+ client_credential_key: @client_credential_key,
696
+ token_credential_key: nil,
697
+ signature_method: @signature_method
669
698
  )
670
699
  end).to raise_error(ArgumentError)
671
700
  end
672
701
 
673
- it 'should have the correct client credential key' do
674
- expect(@unsigned_parameters).to have_key('oauth_consumer_key')
675
- expect(@unsigned_parameters['oauth_consumer_key']).to eq @client_credential_key
702
+ it "should have the correct client credential key" do
703
+ expect(@unsigned_parameters).to have_key("oauth_consumer_key")
704
+ expect(@unsigned_parameters["oauth_consumer_key"]).to eq @client_credential_key
676
705
  end
677
706
 
678
- it 'should have the correct token credentials key' do
679
- expect(@unsigned_parameters).to have_key('oauth_token')
680
- expect(@unsigned_parameters['oauth_token']).to eq @token_credential_key
707
+ it "should have the correct token credentials key" do
708
+ expect(@unsigned_parameters).to have_key("oauth_token")
709
+ expect(@unsigned_parameters["oauth_token"]).to eq @token_credential_key
681
710
  end
682
711
 
683
- it 'should have the correct signature method' do
684
- expect(@unsigned_parameters).to have_key('oauth_signature_method')
685
- expect(@unsigned_parameters['oauth_signature_method']).to eq @signature_method
712
+ it "should have the correct signature method" do
713
+ expect(@unsigned_parameters).to have_key("oauth_signature_method")
714
+ expect(@unsigned_parameters["oauth_signature_method"]).to eq @signature_method
686
715
  end
687
716
 
688
- it 'should have a valid timestamp' do
717
+ it "should have a valid timestamp" do
689
718
  # Verify that we have a timestamp, it's in the correct format and within
690
719
  # a reasonable range of the current time.
691
- expect(@unsigned_parameters).to have_key('oauth_timestamp')
692
- expect(@unsigned_parameters['oauth_timestamp']).to match(/^[0-9]+$/)
693
- expect(@unsigned_parameters['oauth_timestamp'].to_i).to be <= Time.now.to_i
694
- expect(@unsigned_parameters['oauth_timestamp'].to_i).to be >= Time.now.to_i - 1
720
+ expect(@unsigned_parameters).to have_key("oauth_timestamp")
721
+ expect(@unsigned_parameters["oauth_timestamp"]).to match(/^[0-9]+$/)
722
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be <= Time.now.to_i
723
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be >= Time.now.to_i - 1
695
724
  end
696
725
 
697
- it 'should have a valid nonce' do
726
+ it "should have a valid nonce" do
698
727
  # Verify that we have a nonce and that it has sufficient length for
699
728
  # uniqueness.
700
- expect(@unsigned_parameters).to have_key('oauth_nonce')
701
- expect(@unsigned_parameters['oauth_nonce']).to match(/^[0-9a-zA-Z]{16,100}$/)
729
+ expect(@unsigned_parameters).to have_key("oauth_nonce")
730
+ expect(@unsigned_parameters["oauth_nonce"]).to match(/^[0-9a-zA-Z]{16,100}$/)
702
731
  end
703
732
 
704
- it 'should have the correct OAuth version' do
705
- expect(@unsigned_parameters).to have_key('oauth_version')
706
- expect(@unsigned_parameters['oauth_version']).to eq '1.0'
733
+ it "should have the correct OAuth version" do
734
+ expect(@unsigned_parameters).to have_key("oauth_version")
735
+ expect(@unsigned_parameters["oauth_version"]).to eq "1.0"
707
736
  end
708
737
  end
709
738
 
710
- describe Signet::OAuth1, 'when generating token credential parameters ' +
711
- 'with Signet::OAuth1::Credential objects' do
739
+ describe Signet::OAuth1, "when generating token credential parameters " \
740
+ "with Signet::OAuth1::Credential objects" do
712
741
  before do
713
742
  @client_credential = Signet::OAuth1::Credential.new(
714
- 'dpf43f3p2l4k3l03', 'kd94hf93k423kf44'
743
+ "dpf43f3p2l4k3l03", "kd94hf93k423kf44"
715
744
  )
716
745
  @temporary_credential = Signet::OAuth1::Credential.new(
717
- 'hh5s93j4hdidpola', 'hdhd0244k9j7ao03'
746
+ "hh5s93j4hdidpola", "hdhd0244k9j7ao03"
718
747
  )
719
- @verifier = '473f82d3'
720
- @signature_method = 'HMAC-SHA1'
748
+ @verifier = "473f82d3"
749
+ @signature_method = "HMAC-SHA1"
721
750
  @unsigned_parameters =
722
751
  Signet::OAuth1.unsigned_token_credential_parameters(
723
- :client_credential => @client_credential,
724
- :temporary_credential => @temporary_credential,
725
- :signature_method => @signature_method,
726
- :verifier => @verifier
727
- ).inject({}) { |h,(k,v)| h[k]=v; h }
752
+ client_credential: @client_credential,
753
+ temporary_credential: @temporary_credential,
754
+ signature_method: @signature_method,
755
+ verifier: @verifier
756
+ ).each_with_object({}) { |(k, v), h| h[k] = v; }
728
757
  end
729
758
 
730
- it 'should have the correct client credential key' do
731
- expect(@unsigned_parameters).to have_key('oauth_consumer_key')
732
- expect(@unsigned_parameters['oauth_consumer_key']).to eq @client_credential.key
759
+ it "should have the correct client credential key" do
760
+ expect(@unsigned_parameters).to have_key("oauth_consumer_key")
761
+ expect(@unsigned_parameters["oauth_consumer_key"]).to eq @client_credential.key
733
762
  end
734
763
 
735
- it 'should have the correct temporary credentials key' do
736
- expect(@unsigned_parameters).to have_key('oauth_token')
737
- expect(@unsigned_parameters['oauth_token']).to eq @temporary_credential.key
764
+ it "should have the correct temporary credentials key" do
765
+ expect(@unsigned_parameters).to have_key("oauth_token")
766
+ expect(@unsigned_parameters["oauth_token"]).to eq @temporary_credential.key
738
767
  end
739
768
 
740
- it 'should have the correct signature method' do
741
- expect(@unsigned_parameters).to have_key('oauth_signature_method')
742
- expect(@unsigned_parameters['oauth_signature_method']).to eq @signature_method
769
+ it "should have the correct signature method" do
770
+ expect(@unsigned_parameters).to have_key("oauth_signature_method")
771
+ expect(@unsigned_parameters["oauth_signature_method"]).to eq @signature_method
743
772
  end
744
773
 
745
- it 'should have a valid timestamp' do
774
+ it "should have a valid timestamp" do
746
775
  # Verify that we have a timestamp, it's in the correct format and within
747
776
  # a reasonable range of the current time.
748
- expect(@unsigned_parameters).to have_key('oauth_timestamp')
749
- expect(@unsigned_parameters['oauth_timestamp']).to match(/^[0-9]+$/)
750
- expect(@unsigned_parameters['oauth_timestamp'].to_i).to be <= Time.now.to_i
751
- expect(@unsigned_parameters['oauth_timestamp'].to_i).to be >= Time.now.to_i - 1
777
+ expect(@unsigned_parameters).to have_key("oauth_timestamp")
778
+ expect(@unsigned_parameters["oauth_timestamp"]).to match(/^[0-9]+$/)
779
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be <= Time.now.to_i
780
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be >= Time.now.to_i - 1
752
781
  end
753
782
 
754
- it 'should have a valid nonce' do
783
+ it "should have a valid nonce" do
755
784
  # Verify that we have a nonce and that it has sufficient length for
756
785
  # uniqueness.
757
- expect(@unsigned_parameters).to have_key('oauth_nonce')
758
- expect(@unsigned_parameters['oauth_nonce']).to match(/^[0-9a-zA-Z]{16,100}$/)
786
+ expect(@unsigned_parameters).to have_key("oauth_nonce")
787
+ expect(@unsigned_parameters["oauth_nonce"]).to match(/^[0-9a-zA-Z]{16,100}$/)
759
788
  end
760
789
 
761
- it 'should have the correct OAuth version' do
762
- expect(@unsigned_parameters).to have_key('oauth_version')
763
- expect(@unsigned_parameters['oauth_version']).to eq '1.0'
790
+ it "should have the correct OAuth version" do
791
+ expect(@unsigned_parameters).to have_key("oauth_version")
792
+ expect(@unsigned_parameters["oauth_version"]).to eq "1.0"
764
793
  end
765
794
  end
766
795
 
767
- describe Signet::OAuth1, 'when generating token credential parameters ' +
768
- 'with a Signet::OAuth1::Client object' do
796
+ describe Signet::OAuth1, "when generating token credential parameters " \
797
+ "with a Signet::OAuth1::Client object" do
769
798
  before do
770
799
  @client = Signet::OAuth1::Client.new
771
800
  @client.client_credential = Signet::OAuth1::Credential.new(
772
- 'dpf43f3p2l4k3l03', 'kd94hf93k423kf44'
801
+ "dpf43f3p2l4k3l03", "kd94hf93k423kf44"
773
802
  )
774
803
  @client.temporary_credential = Signet::OAuth1::Credential.new(
775
- 'hh5s93j4hdidpola', 'hdhd0244k9j7ao03'
804
+ "hh5s93j4hdidpola", "hdhd0244k9j7ao03"
776
805
  )
777
- @verifier = '473f82d3'
778
- @signature_method = 'HMAC-SHA1'
806
+ @verifier = "473f82d3"
807
+ @signature_method = "HMAC-SHA1"
779
808
  @unsigned_parameters =
780
809
  Signet::OAuth1.unsigned_token_credential_parameters(
781
- :client => @client,
782
- :signature_method => @signature_method,
783
- :verifier => @verifier
784
- ).inject({}) { |h,(k,v)| h[k]=v; h }
810
+ client: @client,
811
+ signature_method: @signature_method,
812
+ verifier: @verifier
813
+ ).each_with_object({}) { |(k, v), h| h[k] = v; }
785
814
  end
786
815
 
787
- it 'should have the correct client credential key' do
788
- expect(@unsigned_parameters).to have_key('oauth_consumer_key')
789
- expect(@unsigned_parameters['oauth_consumer_key']).to eq @client.client_credential_key
816
+ it "should have the correct client credential key" do
817
+ expect(@unsigned_parameters).to have_key("oauth_consumer_key")
818
+ expect(@unsigned_parameters["oauth_consumer_key"]).to eq @client.client_credential_key
790
819
  end
791
820
 
792
- it 'should have the correct temporary credentials key' do
793
- expect(@unsigned_parameters).to have_key('oauth_token')
794
- expect(@unsigned_parameters['oauth_token']).to eq @client.temporary_credential_key
821
+ it "should have the correct temporary credentials key" do
822
+ expect(@unsigned_parameters).to have_key("oauth_token")
823
+ expect(@unsigned_parameters["oauth_token"]).to eq @client.temporary_credential_key
795
824
  end
796
825
 
797
- it 'should have the correct signature method' do
798
- expect(@unsigned_parameters).to have_key('oauth_signature_method')
799
- expect(@unsigned_parameters['oauth_signature_method']).to eq @signature_method
826
+ it "should have the correct signature method" do
827
+ expect(@unsigned_parameters).to have_key("oauth_signature_method")
828
+ expect(@unsigned_parameters["oauth_signature_method"]).to eq @signature_method
800
829
  end
801
830
 
802
- it 'should have a valid timestamp' do
831
+ it "should have a valid timestamp" do
803
832
  # Verify that we have a timestamp, it's in the correct format and within
804
833
  # a reasonable range of the current time.
805
- expect(@unsigned_parameters).to have_key('oauth_timestamp')
806
- expect(@unsigned_parameters['oauth_timestamp']).to match(/^[0-9]+$/)
807
- expect(@unsigned_parameters['oauth_timestamp'].to_i).to be <= Time.now.to_i
808
- expect(@unsigned_parameters['oauth_timestamp'].to_i).to be >= Time.now.to_i - 1
834
+ expect(@unsigned_parameters).to have_key("oauth_timestamp")
835
+ expect(@unsigned_parameters["oauth_timestamp"]).to match(/^[0-9]+$/)
836
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be <= Time.now.to_i
837
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be >= Time.now.to_i - 1
809
838
  end
810
839
 
811
- it 'should have a valid nonce' do
840
+ it "should have a valid nonce" do
812
841
  # Verify that we have a nonce and that it has sufficient length for
813
842
  # uniqueness.
814
- expect(@unsigned_parameters).to have_key('oauth_nonce')
815
- expect(@unsigned_parameters['oauth_nonce']).to match(/^[0-9a-zA-Z]{16,100}$/)
843
+ expect(@unsigned_parameters).to have_key("oauth_nonce")
844
+ expect(@unsigned_parameters["oauth_nonce"]).to match(/^[0-9a-zA-Z]{16,100}$/)
816
845
  end
817
846
 
818
- it 'should have the correct OAuth version' do
819
- expect(@unsigned_parameters).to have_key('oauth_version')
820
- expect(@unsigned_parameters['oauth_version']).to eq '1.0'
847
+ it "should have the correct OAuth version" do
848
+ expect(@unsigned_parameters).to have_key("oauth_version")
849
+ expect(@unsigned_parameters["oauth_version"]).to eq "1.0"
821
850
  end
822
851
  end
823
852
 
824
- describe Signet::OAuth1, 'when generating token credential parameters ' +
825
- 'with Signet::OAuth1::Credential objects' do
853
+ describe Signet::OAuth1, "when generating token credential parameters " \
854
+ "with Signet::OAuth1::Credential objects" do
826
855
  before do
827
856
  @client_credential = Signet::OAuth1::Credential.new(
828
- 'dpf43f3p2l4k3l03', 'kd94hf93k423kf44'
857
+ "dpf43f3p2l4k3l03", "kd94hf93k423kf44"
829
858
  )
830
859
  @temporary_credential = Signet::OAuth1::Credential.new(
831
- 'hh5s93j4hdidpola', 'hdhd0244k9j7ao03'
860
+ "hh5s93j4hdidpola", "hdhd0244k9j7ao03"
832
861
  )
833
- @verifier = '473f82d3'
834
- @signature_method = 'HMAC-SHA1'
862
+ @verifier = "473f82d3"
863
+ @signature_method = "HMAC-SHA1"
835
864
  @unsigned_parameters =
836
865
  Signet::OAuth1.unsigned_token_credential_parameters(
837
- :client_credential => @client_credential,
838
- :temporary_credential => @temporary_credential,
839
- :signature_method => @signature_method,
840
- :verifier => @verifier
841
- ).inject({}) { |h,(k,v)| h[k]=v; h }
866
+ client_credential: @client_credential,
867
+ temporary_credential: @temporary_credential,
868
+ signature_method: @signature_method,
869
+ verifier: @verifier
870
+ ).each_with_object({}) { |(k, v), h| h[k] = v; }
842
871
  end
843
872
 
844
- it 'should have the correct client credential key' do
845
- expect(@unsigned_parameters).to have_key('oauth_consumer_key')
846
- expect(@unsigned_parameters['oauth_consumer_key']).to eq @client_credential.key
873
+ it "should have the correct client credential key" do
874
+ expect(@unsigned_parameters).to have_key("oauth_consumer_key")
875
+ expect(@unsigned_parameters["oauth_consumer_key"]).to eq @client_credential.key
847
876
  end
848
877
 
849
- it 'should have the correct temporary credentials key' do
850
- expect(@unsigned_parameters).to have_key('oauth_token')
851
- expect(@unsigned_parameters['oauth_token']).to eq @temporary_credential.key
878
+ it "should have the correct temporary credentials key" do
879
+ expect(@unsigned_parameters).to have_key("oauth_token")
880
+ expect(@unsigned_parameters["oauth_token"]).to eq @temporary_credential.key
852
881
  end
853
882
 
854
- it 'should have the correct signature method' do
855
- expect(@unsigned_parameters).to have_key('oauth_signature_method')
856
- expect(@unsigned_parameters['oauth_signature_method']).to eq @signature_method
883
+ it "should have the correct signature method" do
884
+ expect(@unsigned_parameters).to have_key("oauth_signature_method")
885
+ expect(@unsigned_parameters["oauth_signature_method"]).to eq @signature_method
857
886
  end
858
887
 
859
- it 'should have a valid timestamp' do
888
+ it "should have a valid timestamp" do
860
889
  # Verify that we have a timestamp, it's in the correct format and within
861
890
  # a reasonable range of the current time.
862
- expect(@unsigned_parameters).to have_key('oauth_timestamp')
863
- expect(@unsigned_parameters['oauth_timestamp']).to match(/^[0-9]+$/)
864
- expect(@unsigned_parameters['oauth_timestamp'].to_i).to be <= Time.now.to_i
865
- expect(@unsigned_parameters['oauth_timestamp'].to_i).to be >= Time.now.to_i - 1
891
+ expect(@unsigned_parameters).to have_key("oauth_timestamp")
892
+ expect(@unsigned_parameters["oauth_timestamp"]).to match(/^[0-9]+$/)
893
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be <= Time.now.to_i
894
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be >= Time.now.to_i - 1
866
895
  end
867
896
 
868
- it 'should have a valid nonce' do
897
+ it "should have a valid nonce" do
869
898
  # Verify that we have a nonce and that it has sufficient length for
870
899
  # uniqueness.
871
- expect(@unsigned_parameters).to have_key('oauth_nonce')
872
- expect(@unsigned_parameters['oauth_nonce']).to match(/^[0-9a-zA-Z]{16,100}$/)
900
+ expect(@unsigned_parameters).to have_key("oauth_nonce")
901
+ expect(@unsigned_parameters["oauth_nonce"]).to match(/^[0-9a-zA-Z]{16,100}$/)
873
902
  end
874
903
 
875
- it 'should have the correct OAuth version' do
876
- expect(@unsigned_parameters).to have_key('oauth_version')
877
- expect(@unsigned_parameters['oauth_version']).to eq '1.0'
904
+ it "should have the correct OAuth version" do
905
+ expect(@unsigned_parameters).to have_key("oauth_version")
906
+ expect(@unsigned_parameters["oauth_version"]).to eq "1.0"
878
907
  end
879
908
  end
880
909
 
881
- describe Signet::OAuth1, 'extracting credential keys from options' do
882
- it 'should raise an error for bogus credentials' do
910
+ describe Signet::OAuth1, "extracting credential keys from options" do
911
+ it "should raise an error for bogus credentials" do
883
912
  expect(lambda do
884
913
  Signet::OAuth1.extract_credential_key_option(
885
- :client, {:client_credential_key => true}
914
+ :client, client_credential_key: true
886
915
  )
887
916
  end).to raise_error(TypeError)
888
917
  end
889
918
 
890
- it 'should raise an error for bogus credentials' do
919
+ it "should raise an error for bogus credentials" do
891
920
  expect(lambda do
892
921
  Signet::OAuth1.extract_credential_key_option(
893
- :client, {:client_credential => 42}
922
+ :client, client_credential: 42
894
923
  )
895
924
  end).to raise_error(TypeError)
896
925
  end
897
926
 
898
- it 'should raise an error for bogus credentials' do
927
+ it "should raise an error for bogus credentials" do
899
928
  expect(lambda do
900
929
  Signet::OAuth1.extract_credential_key_option(
901
- :client, {:client => 42}
930
+ :client, client: 42
902
931
  )
903
932
  end).to raise_error(TypeError)
904
933
  end
905
934
 
906
- it 'should return nil for missing credential key' do
935
+ it "should return nil for missing credential key" do
907
936
  expect(Signet::OAuth1.extract_credential_key_option(:client, {})).to eq nil
908
937
  end
909
938
 
910
- it 'should find the correct credential key' do
939
+ it "should find the correct credential key" do
911
940
  expect(Signet::OAuth1.extract_credential_key_option(
912
- :client, {:client_credential_key => 'dpf43f3p2l4k3l03'}
913
- )).to eq 'dpf43f3p2l4k3l03'
941
+ :client, client_credential_key: "dpf43f3p2l4k3l03"
942
+ )).to eq "dpf43f3p2l4k3l03"
914
943
  end
915
944
 
916
- it 'should find the correct credential key' do
945
+ it "should find the correct credential key" do
917
946
  expect(Signet::OAuth1.extract_credential_key_option(
918
- :client, {:client_credential => Signet::OAuth1::Credential.new(
919
- 'dpf43f3p2l4k3l03', 'kd94hf93k423kf44'
920
- )}
921
- )).to eq 'dpf43f3p2l4k3l03'
947
+ :client, client_credential: Signet::OAuth1::Credential.new(
948
+ "dpf43f3p2l4k3l03", "kd94hf93k423kf44"
949
+ )
950
+ )).to eq "dpf43f3p2l4k3l03"
922
951
  end
923
952
 
924
- it 'should find the correct credential key' do
953
+ it "should find the correct credential key" do
925
954
  client = Signet::OAuth1::Client.new
926
955
  client.client_credential = Signet::OAuth1::Credential.new(
927
- 'dpf43f3p2l4k3l03', 'kd94hf93k423kf44'
956
+ "dpf43f3p2l4k3l03", "kd94hf93k423kf44"
928
957
  )
929
958
  expect(Signet::OAuth1.extract_credential_key_option(
930
- :client, {:client => client}
931
- )).to eq 'dpf43f3p2l4k3l03'
959
+ :client, client: client
960
+ )).to eq "dpf43f3p2l4k3l03"
932
961
  end
933
962
 
934
- it 'should find the correct credential key' do
963
+ it "should find the correct credential key" do
935
964
  client = Signet::OAuth1::Client.new
936
965
  client.temporary_credential = Signet::OAuth1::Credential.new(
937
- 'hh5s93j4hdidpola', 'hdhd0244k9j7ao03'
966
+ "hh5s93j4hdidpola", "hdhd0244k9j7ao03"
938
967
  )
939
968
  expect(Signet::OAuth1.extract_credential_key_option(
940
- :temporary, {:client => client}
941
- )).to eq 'hh5s93j4hdidpola'
969
+ :temporary, client: client
970
+ )).to eq "hh5s93j4hdidpola"
942
971
  end
943
972
  end
944
973
 
945
- describe Signet::OAuth1, 'extracting credential secrets from options' do
946
- it 'should raise an error for bogus credentials' do
974
+ describe Signet::OAuth1, "extracting credential secrets from options" do
975
+ it "should raise an error for bogus credentials" do
947
976
  expect(lambda do
948
977
  Signet::OAuth1.extract_credential_secret_option(
949
- :client, {:client_credential_secret => true}
978
+ :client, client_credential_secret: true
950
979
  )
951
980
  end).to raise_error(TypeError)
952
981
  end
953
982
 
954
- it 'should raise an error for bogus credentials' do
983
+ it "should raise an error for bogus credentials" do
955
984
  expect(lambda do
956
985
  Signet::OAuth1.extract_credential_secret_option(
957
- :client, {:client_credential => 42}
986
+ :client, client_credential: 42
958
987
  )
959
988
  end).to raise_error(TypeError)
960
989
  end
961
990
 
962
- it 'should raise an error for bogus credentials' do
991
+ it "should raise an error for bogus credentials" do
963
992
  expect(lambda do
964
993
  Signet::OAuth1.extract_credential_secret_option(
965
- :client, {:client => 42}
994
+ :client, client: 42
966
995
  )
967
996
  end).to raise_error(TypeError)
968
997
  end
969
998
 
970
- it 'should raise an error for missing credential secret' do
999
+ it "should raise an error for missing credential secret" do
971
1000
  expect(Signet::OAuth1.extract_credential_secret_option(:client, {})).to eq nil
972
1001
  end
973
1002
 
974
- it 'should find the correct credential secret' do
1003
+ it "should find the correct credential secret" do
975
1004
  expect(Signet::OAuth1.extract_credential_secret_option(
976
- :client, {:client_credential_secret => 'kd94hf93k423kf44'}
977
- )).to eq 'kd94hf93k423kf44'
1005
+ :client, client_credential_secret: "kd94hf93k423kf44"
1006
+ )).to eq "kd94hf93k423kf44"
978
1007
  end
979
1008
 
980
- it 'should find the correct credential secret' do
1009
+ it "should find the correct credential secret" do
981
1010
  expect(Signet::OAuth1.extract_credential_secret_option(
982
- :client, {:client_credential => Signet::OAuth1::Credential.new(
983
- 'dpf43f3p2l4k3l03', 'kd94hf93k423kf44'
984
- )}
985
- )).to eq 'kd94hf93k423kf44'
1011
+ :client, client_credential: Signet::OAuth1::Credential.new(
1012
+ "dpf43f3p2l4k3l03", "kd94hf93k423kf44"
1013
+ )
1014
+ )).to eq "kd94hf93k423kf44"
986
1015
  end
987
1016
 
988
- it 'should find the correct credential secret' do
1017
+ it "should find the correct credential secret" do
989
1018
  client = Signet::OAuth1::Client.new
990
1019
  client.client_credential = Signet::OAuth1::Credential.new(
991
- 'dpf43f3p2l4k3l03', 'kd94hf93k423kf44'
1020
+ "dpf43f3p2l4k3l03", "kd94hf93k423kf44"
992
1021
  )
993
1022
  expect(Signet::OAuth1.extract_credential_secret_option(
994
- :client, {:client => client}
995
- )).to eq 'kd94hf93k423kf44'
1023
+ :client, client: client
1024
+ )).to eq "kd94hf93k423kf44"
996
1025
  end
997
1026
 
998
- it 'should find the correct credential secret' do
1027
+ it "should find the correct credential secret" do
999
1028
  client = Signet::OAuth1::Client.new
1000
1029
  client.temporary_credential = Signet::OAuth1::Credential.new(
1001
- 'hh5s93j4hdidpola', 'hdhd0244k9j7ao03'
1030
+ "hh5s93j4hdidpola", "hdhd0244k9j7ao03"
1002
1031
  )
1003
1032
  expect(Signet::OAuth1.extract_credential_secret_option(
1004
- :temporary, {:client => client}
1005
- )).to eq 'hdhd0244k9j7ao03'
1033
+ :temporary, client: client
1034
+ )).to eq "hdhd0244k9j7ao03"
1006
1035
  end
1007
1036
  end