signet 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +47 -36
  3. data/Gemfile +5 -4
  4. data/README.md +4 -5
  5. data/Rakefile +86 -37
  6. data/lib/signet.rb +17 -14
  7. data/lib/signet/errors.rb +4 -4
  8. data/lib/signet/oauth_1.rb +128 -153
  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 +302 -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 +527 -524
  26. data/spec/signet/oauth_2/client_spec.rb +612 -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 +50 -43
  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,327 @@ 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 an authorization header" do
283
286
  parameters = [
284
- ["oauth_consumer_key", "0685bd9184jfhq22"],
285
- ["oauth_token", "ad180jjd733klru7"],
287
+ %w[oauth_consumer_key 0685bd9184jfhq22],
288
+ %w[oauth_token ad180jjd733klru7],
286
289
  ["oauth_signature_method", "HMAC-SHA1"],
287
290
  ["oauth_signature", "wOJIO9A2W5mFwDgiDvZbTSMK/PY="],
288
- ["oauth_timestamp", "137131200"],
289
- ["oauth_nonce", "4572616e48616d6d65724c61686176"],
291
+ %w[oauth_timestamp 137131200],
292
+ %w[oauth_nonce 4572616e48616d6d65724c61686176],
290
293
  ["oauth_version", "1.0"]
291
294
  ]
292
295
  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
296
+ parameters, "http://sp.example.com/"
297
+ )).to eq(
298
+ 'OAuth realm="http://sp.example.com/", ' \
299
+ 'oauth_consumer_key="0685bd9184jfhq22", ' \
300
+ 'oauth_token="ad180jjd733klru7", ' \
301
+ 'oauth_signature_method="HMAC-SHA1", ' \
302
+ 'oauth_signature="wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D", ' \
303
+ 'oauth_timestamp="137131200", ' \
304
+ 'oauth_nonce="4572616e48616d6d65724c61686176", ' \
305
+ 'oauth_version="1.0"'
306
+ )
307
+ end
308
+
309
+ it "should raise an error if generating an authorization header " \
310
+ "with bogus values" do
308
311
  expect(lambda do
309
- Signet::OAuth1.generate_authorization_header(42)
312
+ Signet::OAuth1.generate_authorization_header 42
310
313
  end).to raise_error(TypeError)
311
314
  end
312
315
 
313
- it 'should raise an error if generating an authorization header ' +
314
- 'with the "realm" parameter specified the wrong way' do
316
+ it "should raise an error if generating an authorization header " \
317
+ 'with the "realm" parameter specified the wrong way' do
315
318
  parameters = [
316
319
  ["realm", "http://sp.example.com/"],
317
- ["oauth_consumer_key", "0685bd9184jfhq22"],
318
- ["oauth_token", "ad180jjd733klru7"],
320
+ %w[oauth_consumer_key 0685bd9184jfhq22],
321
+ %w[oauth_token ad180jjd733klru7],
319
322
  ["oauth_signature_method", "HMAC-SHA1"],
320
323
  ["oauth_signature", "wOJIO9A2W5mFwDgiDvZbTSMK/PY="],
321
- ["oauth_timestamp", "137131200"],
322
- ["oauth_nonce", "4572616e48616d6d65724c61686176"],
324
+ %w[oauth_timestamp 137131200],
325
+ %w[oauth_nonce 4572616e48616d6d65724c61686176],
323
326
  ["oauth_version", "1.0"]
324
327
  ]
325
328
  expect(lambda do
326
- Signet::OAuth1.generate_authorization_header(parameters)
329
+ Signet::OAuth1.generate_authorization_header parameters
327
330
  end).to raise_error(ArgumentError)
328
331
  end
329
332
 
330
- it 'should correctly parse an authorization header' do
333
+ it "should correctly parse an authorization header" do
331
334
  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", ' +
335
+ 'OAuth realm="http://sp.example.com/", ' \
336
+ 'oauth_consumer_key="0685bd9184jfhq22", ' \
337
+ 'oauth_token="ad180jjd733klru7", ' \
338
+ 'oauth_signature_method="HMAC-SHA1", ' \
339
+ 'oauth_signature="wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D", ' \
340
+ 'oauth_timestamp="137131200", ' \
341
+ 'oauth_nonce="4572616e48616d6d65724c61686176", ' \
339
342
  '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
343
+ ).each_with_object({}) { |(k, v), h| h[k] = v; }
344
+ expect(parameters["realm"]).to eq "http://sp.example.com/"
345
+ expect(parameters["oauth_consumer_key"]).to eq "0685bd9184jfhq22"
346
+ expect(parameters["oauth_token"]).to eq "ad180jjd733klru7"
347
+ expect(parameters["oauth_signature_method"]).to eq "HMAC-SHA1"
348
+ expect(parameters["oauth_signature"]).to eq "wOJIO9A2W5mFwDgiDvZbTSMK/PY="
349
+ expect(parameters["oauth_timestamp"]).to eq "137131200"
350
+ expect(parameters["oauth_nonce"]).to eq "4572616e48616d6d65724c61686176"
351
+ expect(parameters["oauth_version"]).to eq "1.0"
352
+ end
353
+
354
+ it "should not unescape a realm in an authorization header" do
352
355
  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", ' +
356
+ 'OAuth realm="http%3A%2F%2Fsp.example.com%2F", ' \
357
+ 'domain="http%3A%2F%2Fsp.example.com%2F", ' \
358
+ 'oauth_consumer_key="0685bd9184jfhq22", ' \
359
+ 'oauth_token="ad180jjd733klru7", ' \
360
+ 'oauth_signature_method="HMAC-SHA1", ' \
361
+ 'oauth_signature="wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D", ' \
362
+ 'oauth_timestamp="137131200", ' \
363
+ 'oauth_nonce="4572616e48616d6d65724c61686176", ' \
361
364
  '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
365
+ ).each_with_object({}) { |(k, v), h| h[k] = v; }
366
+ expect(parameters["realm"]).to eq "http%3A%2F%2Fsp.example.com%2F"
367
+ expect(parameters["domain"]).to eq "http://sp.example.com/"
368
+ expect(parameters["oauth_consumer_key"]).to eq "0685bd9184jfhq22"
369
+ expect(parameters["oauth_token"]).to eq "ad180jjd733klru7"
370
+ expect(parameters["oauth_signature_method"]).to eq "HMAC-SHA1"
371
+ expect(parameters["oauth_signature"]).to eq "wOJIO9A2W5mFwDgiDvZbTSMK/PY="
372
+ expect(parameters["oauth_timestamp"]).to eq "137131200"
373
+ expect(parameters["oauth_nonce"]).to eq "4572616e48616d6d65724c61686176"
374
+ expect(parameters["oauth_version"]).to eq "1.0"
375
+ end
376
+
377
+ it "should raise an error if parsing an authorization header " \
378
+ "with bogus values" do
376
379
  expect(lambda do
377
- Signet::OAuth1.parse_authorization_header(42)
380
+ Signet::OAuth1.parse_authorization_header 42
378
381
  end).to raise_error(TypeError)
379
382
  end
380
383
 
381
- it 'should raise an error if parsing a non-OAuth authorization header' do
384
+ it "should raise an error if parsing a non-OAuth authorization header" do
382
385
  expect(lambda do
383
386
  Signet::OAuth1.parse_authorization_header(
384
- 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
387
+ "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="
385
388
  )
386
389
  end).to raise_error(Signet::ParseError)
387
390
  end
388
391
 
389
- it 'should correctly parse a form encoded credential' do
392
+ it "should correctly parse a form encoded credential" do
390
393
  credential = Signet::OAuth1.parse_form_encoded_credentials(
391
- 'oauth_token=hh5s93j4hdidpola&oauth_token_secret=hdhd0244k9j7ao03'
394
+ "oauth_token=hh5s93j4hdidpola&oauth_token_secret=hdhd0244k9j7ao03"
392
395
  )
393
- expect(credential.key).to eq 'hh5s93j4hdidpola'
394
- expect(credential.secret).to eq 'hdhd0244k9j7ao03'
396
+ expect(credential.key).to eq "hh5s93j4hdidpola"
397
+ expect(credential.secret).to eq "hdhd0244k9j7ao03"
395
398
  end
396
399
 
397
- it 'should correctly parse a form encoded credential' do
400
+ it "should correctly parse a form encoded credential" do
398
401
  credential = Signet::OAuth1.parse_form_encoded_credentials(
399
- 'oauth_token=hdk48Djdsa&oauth_token_secret=xyz4992k83j47x0b&' +
400
- 'oauth_callback_confirmed=true'
402
+ "oauth_token=hdk48Djdsa&oauth_token_secret=xyz4992k83j47x0b&" \
403
+ "oauth_callback_confirmed=true"
401
404
  )
402
- expect(credential.key).to eq 'hdk48Djdsa'
403
- expect(credential.secret).to eq 'xyz4992k83j47x0b'
405
+ expect(credential.key).to eq "hdk48Djdsa"
406
+ expect(credential.secret).to eq "xyz4992k83j47x0b"
404
407
  end
405
408
 
406
- it 'should raise an error if parsing a form encoded credential ' +
407
- 'with bogus values' do
409
+ it "should raise an error if parsing a form encoded credential " \
410
+ "with bogus values" do
408
411
  expect(lambda do
409
- Signet::OAuth1.parse_form_encoded_credentials(42)
412
+ Signet::OAuth1.parse_form_encoded_credentials 42
410
413
  end).to raise_error(TypeError)
411
414
  end
412
415
 
413
- it 'should correctly generate a signature for a set of parameters' do
416
+ it "should correctly generate a signature for a set of parameters" do
414
417
  method = :get
415
418
  uri = "http://photos.example.net/photos"
416
- client_credential_secret = 'kd94hf93k423kf44'
417
- token_credential_secret = 'pfkkdhi9sl3r4s00'
419
+ client_credential_secret = "kd94hf93k423kf44"
420
+ token_credential_secret = "pfkkdhi9sl3r4s00"
418
421
  parameters = {
419
- "oauth_consumer_key" => "dpf43f3p2l4k3l03",
420
- "oauth_token" => "nnch734d00sl2jdk",
422
+ "oauth_consumer_key" => "dpf43f3p2l4k3l03",
423
+ "oauth_token" => "nnch734d00sl2jdk",
421
424
  "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"
425
+ "oauth_timestamp" => "1191242096",
426
+ "oauth_nonce" => "kllo9940pd9333jh",
427
+ "oauth_version" => "1.0",
428
+ "file" => "vacation.jpg",
429
+ "size" => "original"
427
430
  }
428
431
  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="
432
+ method,
433
+ uri,
434
+ parameters,
435
+ client_credential_secret,
436
+ token_credential_secret
437
+ )).to eq "tR3+Ty81lMeYAr/Fid0kMTYa/WM="
435
438
  end
436
439
 
437
- it 'should raise an error when trying to sign with with unknown method' do
440
+ it "should raise an error when trying to sign with with unknown method" do
438
441
  method = :get
439
442
  uri = "http://photos.example.net/photos"
440
- client_credential_secret = 'kd94hf93k423kf44'
441
- token_credential_secret = 'pfkkdhi9sl3r4s00'
443
+ client_credential_secret = "kd94hf93k423kf44"
444
+ token_credential_secret = "pfkkdhi9sl3r4s00"
442
445
  parameters = {
443
- "oauth_consumer_key" => "dpf43f3p2l4k3l03",
444
- "oauth_token" => "nnch734d00sl2jdk",
446
+ "oauth_consumer_key" => "dpf43f3p2l4k3l03",
447
+ "oauth_token" => "nnch734d00sl2jdk",
445
448
  "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"
449
+ "oauth_timestamp" => "1191242096",
450
+ "oauth_nonce" => "kllo9940pd9333jh",
451
+ "oauth_version" => "1.0",
452
+ "file" => "vacation.jpg",
453
+ "size" => "original"
451
454
  }
452
455
  expect(lambda do
453
456
  Signet::OAuth1.sign_parameters(
@@ -460,548 +463,548 @@ describe Signet::OAuth1 do
460
463
  end).to raise_error(NotImplementedError)
461
464
  end
462
465
 
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'
466
+ it "should correctly generate authorization URIs" do
467
+ authorization_uri = "http://photos.example.net/authorize"
468
+ temporary_credential_key = "hh5s93j4hdidpola"
469
+ callback = "http://printer.example.com/request_token_ready"
467
470
  parsed_uri = Addressable::URI.parse(
468
- Signet::OAuth1.generate_authorization_uri(
471
+ Signet::OAuth1.generate_authorization_uri(
469
472
  authorization_uri,
470
- :temporary_credential_key => temporary_credential_key,
471
- :callback => callback
473
+ temporary_credential_key: temporary_credential_key,
474
+ callback: callback
472
475
  )
473
476
  )
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
477
+ expect(parsed_uri.query_values).to have_key("oauth_token")
478
+ expect(parsed_uri.query_values["oauth_token"]).to eq temporary_credential_key
479
+ expect(parsed_uri.query_values).to have_key("oauth_callback")
480
+ expect(parsed_uri.query_values["oauth_callback"]).to eq callback
478
481
  end
479
482
  end
480
483
 
481
- describe Signet::OAuth1, 'when generating temporary credentials parameters' do
484
+ describe Signet::OAuth1, "when generating temporary credentials parameters" do
482
485
  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]]
486
+ @client_credential_key = "dpf43f3p2l4k3l03"
487
+ @callback = "http://printer.example.com/request_token_ready"
488
+ @signature_method = "HMAC-SHA1"
489
+ @scope = "http://photos.example.com/full_access"
490
+ @additional_parameters = [["scope", @scope]]
488
491
  @unsigned_parameters =
489
492
  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 }
493
+ client_credential_key: @client_credential_key,
494
+ callback: @callback,
495
+ signature_method: @signature_method,
496
+ additional_parameters: @additional_parameters
497
+ ).each_with_object({}) { |(k, v), h| h[k] = v; }
495
498
  end
496
499
 
497
- it 'should raise an error if the client credential key is missing' do
500
+ it "should raise an error if the client credential key is missing" do
498
501
  expect(lambda do
499
502
  Signet::OAuth1.unsigned_temporary_credential_parameters(
500
- :client_credential_key => nil,
501
- :callback => @callback,
502
- :signature_method => @signature_method,
503
- :additional_parameters => @additional_parameters
503
+ client_credential_key: nil,
504
+ callback: @callback,
505
+ signature_method: @signature_method,
506
+ additional_parameters: @additional_parameters
504
507
  )
505
508
  end).to raise_error(ArgumentError)
506
509
  end
507
510
 
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
511
+ it "should have the correct client credential key" do
512
+ expect(@unsigned_parameters).to have_key("oauth_consumer_key")
513
+ expect(@unsigned_parameters["oauth_consumer_key"]).to eq @client_credential_key
511
514
  end
512
515
 
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
516
+ it "should have the correct signature method" do
517
+ expect(@unsigned_parameters).to have_key("oauth_signature_method")
518
+ expect(@unsigned_parameters["oauth_signature_method"]).to eq @signature_method
516
519
  end
517
520
 
518
- it 'should have a valid timestamp' do
521
+ it "should have a valid timestamp" do
519
522
  # Verify that we have a timestamp, it's in the correct format and within
520
523
  # 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
524
+ expect(@unsigned_parameters).to have_key("oauth_timestamp")
525
+ expect(@unsigned_parameters["oauth_timestamp"]).to match(/^[0-9]+$/)
526
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be <= Time.now.to_i
527
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be >= Time.now.to_i - 1
525
528
  end
526
529
 
527
- it 'should have a valid nonce' do
530
+ it "should have a valid nonce" do
528
531
  # Verify that we have a nonce and that it has sufficient length for
529
532
  # uniqueness.
530
- expect(@unsigned_parameters).to have_key('oauth_nonce')
531
- expect(@unsigned_parameters['oauth_nonce']).to match(/^[0-9a-zA-Z]{16,100}$/)
533
+ expect(@unsigned_parameters).to have_key("oauth_nonce")
534
+ expect(@unsigned_parameters["oauth_nonce"]).to match(/^[0-9a-zA-Z]{16,100}$/)
532
535
  end
533
536
 
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
537
+ it "should have the correct callback" do
538
+ expect(@unsigned_parameters).to have_key("oauth_callback")
539
+ expect(@unsigned_parameters["oauth_callback"]).to eq @callback
537
540
  end
538
541
 
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
542
+ it "should have the correct scope parameter" do
543
+ expect(@unsigned_parameters).to have_key("scope")
544
+ expect(@unsigned_parameters["scope"]).to eq @scope
542
545
  end
543
546
 
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'
547
+ it "should have the correct OAuth version" do
548
+ expect(@unsigned_parameters).to have_key("oauth_version")
549
+ expect(@unsigned_parameters["oauth_version"]).to eq "1.0"
547
550
  end
548
551
  end
549
552
 
550
- describe Signet::OAuth1, 'when generating token credential parameters' do
553
+ describe Signet::OAuth1, "when generating token credential parameters" do
551
554
  before do
552
- @client_credential_key = 'dpf43f3p2l4k3l03'
553
- @temporary_credential_key = 'hh5s93j4hdidpola'
554
- @verifier = '473f82d3'
555
- @signature_method = 'HMAC-SHA1'
555
+ @client_credential_key = "dpf43f3p2l4k3l03"
556
+ @temporary_credential_key = "hh5s93j4hdidpola"
557
+ @verifier = "473f82d3"
558
+ @signature_method = "HMAC-SHA1"
556
559
  @unsigned_parameters =
557
560
  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 }
561
+ client_credential_key: @client_credential_key,
562
+ temporary_credential_key: @temporary_credential_key,
563
+ signature_method: @signature_method,
564
+ verifier: @verifier
565
+ ).each_with_object({}) { |(k, v), h| h[k] = v; }
563
566
  end
564
567
 
565
- it 'should raise an error if the client credential key is missing' do
568
+ it "should raise an error if the client credential key is missing" do
566
569
  expect(lambda do
567
570
  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
571
+ client_credential_key: nil,
572
+ temporary_credential_key: @temporary_credential_key,
573
+ signature_method: @signature_method,
574
+ verifier: @verifier
572
575
  )
573
576
  end).to raise_error(ArgumentError)
574
577
  end
575
578
 
576
- it 'should raise an error if the temporary credential key is missing' do
579
+ it "should raise an error if the temporary credential key is missing" do
577
580
  expect(lambda do
578
581
  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
582
+ client_credential_key: @client_credential_key,
583
+ temporary_credential_key: nil,
584
+ signature_method: @signature_method,
585
+ verifier: @verifier
583
586
  )
584
587
  end).to raise_error(ArgumentError)
585
588
  end
586
589
 
587
- it 'should raise an error if the verifier is missing' do
590
+ it "should raise an error if the verifier is missing" do
588
591
  expect(lambda do
589
592
  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
593
+ client_credential_key: @client_credential_key,
594
+ temporary_credential_key: @temporary_credential_key,
595
+ signature_method: @signature_method,
596
+ verifier: nil
594
597
  )
595
598
  end).to raise_error(ArgumentError)
596
599
  end
597
600
 
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
601
+ it "should have the correct client credential key" do
602
+ expect(@unsigned_parameters).to have_key("oauth_consumer_key")
603
+ expect(@unsigned_parameters["oauth_consumer_key"]).to eq @client_credential_key
601
604
  end
602
605
 
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
606
+ it "should have the correct temporary credentials key" do
607
+ expect(@unsigned_parameters).to have_key("oauth_token")
608
+ expect(@unsigned_parameters["oauth_token"]).to eq @temporary_credential_key
606
609
  end
607
610
 
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
611
+ it "should have the correct signature method" do
612
+ expect(@unsigned_parameters).to have_key("oauth_signature_method")
613
+ expect(@unsigned_parameters["oauth_signature_method"]).to eq @signature_method
611
614
  end
612
615
 
613
- it 'should have a valid timestamp' do
616
+ it "should have a valid timestamp" do
614
617
  # Verify that we have a timestamp, it's in the correct format and within
615
618
  # 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
619
+ expect(@unsigned_parameters).to have_key("oauth_timestamp")
620
+ expect(@unsigned_parameters["oauth_timestamp"]).to match(/^[0-9]+$/)
621
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be <= Time.now.to_i
622
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be >= Time.now.to_i - 1
620
623
  end
621
624
 
622
- it 'should have a valid nonce' do
625
+ it "should have a valid nonce" do
623
626
  # Verify that we have a nonce and that it has sufficient length for
624
627
  # uniqueness.
625
- expect(@unsigned_parameters).to have_key('oauth_nonce')
626
- expect(@unsigned_parameters['oauth_nonce']).to match(/^[0-9a-zA-Z]{16,100}$/)
628
+ expect(@unsigned_parameters).to have_key("oauth_nonce")
629
+ expect(@unsigned_parameters["oauth_nonce"]).to match(/^[0-9a-zA-Z]{16,100}$/)
627
630
  end
628
631
 
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
632
+ it "should have the verifier" do
633
+ expect(@unsigned_parameters).to have_key("oauth_verifier")
634
+ expect(@unsigned_parameters["oauth_verifier"]).to eq @verifier
632
635
  end
633
636
 
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'
637
+ it "should have the correct OAuth version" do
638
+ expect(@unsigned_parameters).to have_key("oauth_version")
639
+ expect(@unsigned_parameters["oauth_version"]).to eq "1.0"
637
640
  end
638
641
  end
639
642
 
640
- describe Signet::OAuth1, 'when generating protected resource parameters' do
643
+ describe Signet::OAuth1, "when generating protected resource parameters" do
641
644
  before do
642
- @client_credential_key = 'dpf43f3p2l4k3l03'
643
- @token_credential_key = 'nnch734d00sl2jdk'
644
- @signature_method = 'HMAC-SHA1'
645
+ @client_credential_key = "dpf43f3p2l4k3l03"
646
+ @token_credential_key = "nnch734d00sl2jdk"
647
+ @signature_method = "HMAC-SHA1"
645
648
  @unsigned_parameters =
646
649
  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 }
650
+ client_credential_key: @client_credential_key,
651
+ token_credential_key: @token_credential_key,
652
+ signature_method: @signature_method
653
+ ).each_with_object({}) { |(k, v), h| h[k] = v; }
651
654
  end
652
655
 
653
- it 'should raise an error if the client credential key is missing' do
656
+ it "should raise an error if the client credential key is missing" do
654
657
  expect(lambda do
655
658
  Signet::OAuth1.unsigned_resource_parameters(
656
- :client_credential_key => nil,
657
- :token_credential_key => @token_credential_key,
658
- :signature_method => @signature_method
659
+ client_credential_key: nil,
660
+ token_credential_key: @token_credential_key,
661
+ signature_method: @signature_method
659
662
  )
660
663
  end).to raise_error(ArgumentError)
661
664
  end
662
665
 
663
- it 'should raise an error if the token credential key is missing' do
666
+ it "should raise an error if the token credential key is missing" do
664
667
  expect(lambda do
665
668
  Signet::OAuth1.unsigned_resource_parameters(
666
- :client_credential_key => @client_credential_key,
667
- :token_credential_key => nil,
668
- :signature_method => @signature_method
669
+ client_credential_key: @client_credential_key,
670
+ token_credential_key: nil,
671
+ signature_method: @signature_method
669
672
  )
670
673
  end).to raise_error(ArgumentError)
671
674
  end
672
675
 
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
676
+ it "should have the correct client credential key" do
677
+ expect(@unsigned_parameters).to have_key("oauth_consumer_key")
678
+ expect(@unsigned_parameters["oauth_consumer_key"]).to eq @client_credential_key
676
679
  end
677
680
 
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
681
+ it "should have the correct token credentials key" do
682
+ expect(@unsigned_parameters).to have_key("oauth_token")
683
+ expect(@unsigned_parameters["oauth_token"]).to eq @token_credential_key
681
684
  end
682
685
 
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
686
+ it "should have the correct signature method" do
687
+ expect(@unsigned_parameters).to have_key("oauth_signature_method")
688
+ expect(@unsigned_parameters["oauth_signature_method"]).to eq @signature_method
686
689
  end
687
690
 
688
- it 'should have a valid timestamp' do
691
+ it "should have a valid timestamp" do
689
692
  # Verify that we have a timestamp, it's in the correct format and within
690
693
  # 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
694
+ expect(@unsigned_parameters).to have_key("oauth_timestamp")
695
+ expect(@unsigned_parameters["oauth_timestamp"]).to match(/^[0-9]+$/)
696
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be <= Time.now.to_i
697
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be >= Time.now.to_i - 1
695
698
  end
696
699
 
697
- it 'should have a valid nonce' do
700
+ it "should have a valid nonce" do
698
701
  # Verify that we have a nonce and that it has sufficient length for
699
702
  # uniqueness.
700
- expect(@unsigned_parameters).to have_key('oauth_nonce')
701
- expect(@unsigned_parameters['oauth_nonce']).to match(/^[0-9a-zA-Z]{16,100}$/)
703
+ expect(@unsigned_parameters).to have_key("oauth_nonce")
704
+ expect(@unsigned_parameters["oauth_nonce"]).to match(/^[0-9a-zA-Z]{16,100}$/)
702
705
  end
703
706
 
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'
707
+ it "should have the correct OAuth version" do
708
+ expect(@unsigned_parameters).to have_key("oauth_version")
709
+ expect(@unsigned_parameters["oauth_version"]).to eq "1.0"
707
710
  end
708
711
  end
709
712
 
710
- describe Signet::OAuth1, 'when generating token credential parameters ' +
711
- 'with Signet::OAuth1::Credential objects' do
713
+ describe Signet::OAuth1, "when generating token credential parameters " \
714
+ "with Signet::OAuth1::Credential objects" do
712
715
  before do
713
716
  @client_credential = Signet::OAuth1::Credential.new(
714
- 'dpf43f3p2l4k3l03', 'kd94hf93k423kf44'
717
+ "dpf43f3p2l4k3l03", "kd94hf93k423kf44"
715
718
  )
716
719
  @temporary_credential = Signet::OAuth1::Credential.new(
717
- 'hh5s93j4hdidpola', 'hdhd0244k9j7ao03'
720
+ "hh5s93j4hdidpola", "hdhd0244k9j7ao03"
718
721
  )
719
- @verifier = '473f82d3'
720
- @signature_method = 'HMAC-SHA1'
722
+ @verifier = "473f82d3"
723
+ @signature_method = "HMAC-SHA1"
721
724
  @unsigned_parameters =
722
725
  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 }
726
+ client_credential: @client_credential,
727
+ temporary_credential: @temporary_credential,
728
+ signature_method: @signature_method,
729
+ verifier: @verifier
730
+ ).each_with_object({}) { |(k, v), h| h[k] = v; }
728
731
  end
729
732
 
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
733
+ it "should have the correct client credential key" do
734
+ expect(@unsigned_parameters).to have_key("oauth_consumer_key")
735
+ expect(@unsigned_parameters["oauth_consumer_key"]).to eq @client_credential.key
733
736
  end
734
737
 
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
738
+ it "should have the correct temporary credentials key" do
739
+ expect(@unsigned_parameters).to have_key("oauth_token")
740
+ expect(@unsigned_parameters["oauth_token"]).to eq @temporary_credential.key
738
741
  end
739
742
 
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
743
+ it "should have the correct signature method" do
744
+ expect(@unsigned_parameters).to have_key("oauth_signature_method")
745
+ expect(@unsigned_parameters["oauth_signature_method"]).to eq @signature_method
743
746
  end
744
747
 
745
- it 'should have a valid timestamp' do
748
+ it "should have a valid timestamp" do
746
749
  # Verify that we have a timestamp, it's in the correct format and within
747
750
  # 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
751
+ expect(@unsigned_parameters).to have_key("oauth_timestamp")
752
+ expect(@unsigned_parameters["oauth_timestamp"]).to match(/^[0-9]+$/)
753
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be <= Time.now.to_i
754
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be >= Time.now.to_i - 1
752
755
  end
753
756
 
754
- it 'should have a valid nonce' do
757
+ it "should have a valid nonce" do
755
758
  # Verify that we have a nonce and that it has sufficient length for
756
759
  # uniqueness.
757
- expect(@unsigned_parameters).to have_key('oauth_nonce')
758
- expect(@unsigned_parameters['oauth_nonce']).to match(/^[0-9a-zA-Z]{16,100}$/)
760
+ expect(@unsigned_parameters).to have_key("oauth_nonce")
761
+ expect(@unsigned_parameters["oauth_nonce"]).to match(/^[0-9a-zA-Z]{16,100}$/)
759
762
  end
760
763
 
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'
764
+ it "should have the correct OAuth version" do
765
+ expect(@unsigned_parameters).to have_key("oauth_version")
766
+ expect(@unsigned_parameters["oauth_version"]).to eq "1.0"
764
767
  end
765
768
  end
766
769
 
767
- describe Signet::OAuth1, 'when generating token credential parameters ' +
768
- 'with a Signet::OAuth1::Client object' do
770
+ describe Signet::OAuth1, "when generating token credential parameters " \
771
+ "with a Signet::OAuth1::Client object" do
769
772
  before do
770
773
  @client = Signet::OAuth1::Client.new
771
774
  @client.client_credential = Signet::OAuth1::Credential.new(
772
- 'dpf43f3p2l4k3l03', 'kd94hf93k423kf44'
775
+ "dpf43f3p2l4k3l03", "kd94hf93k423kf44"
773
776
  )
774
777
  @client.temporary_credential = Signet::OAuth1::Credential.new(
775
- 'hh5s93j4hdidpola', 'hdhd0244k9j7ao03'
778
+ "hh5s93j4hdidpola", "hdhd0244k9j7ao03"
776
779
  )
777
- @verifier = '473f82d3'
778
- @signature_method = 'HMAC-SHA1'
780
+ @verifier = "473f82d3"
781
+ @signature_method = "HMAC-SHA1"
779
782
  @unsigned_parameters =
780
783
  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 }
784
+ client: @client,
785
+ signature_method: @signature_method,
786
+ verifier: @verifier
787
+ ).each_with_object({}) { |(k, v), h| h[k] = v; }
785
788
  end
786
789
 
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
790
+ it "should have the correct client credential key" do
791
+ expect(@unsigned_parameters).to have_key("oauth_consumer_key")
792
+ expect(@unsigned_parameters["oauth_consumer_key"]).to eq @client.client_credential_key
790
793
  end
791
794
 
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
795
+ it "should have the correct temporary credentials key" do
796
+ expect(@unsigned_parameters).to have_key("oauth_token")
797
+ expect(@unsigned_parameters["oauth_token"]).to eq @client.temporary_credential_key
795
798
  end
796
799
 
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
800
+ it "should have the correct signature method" do
801
+ expect(@unsigned_parameters).to have_key("oauth_signature_method")
802
+ expect(@unsigned_parameters["oauth_signature_method"]).to eq @signature_method
800
803
  end
801
804
 
802
- it 'should have a valid timestamp' do
805
+ it "should have a valid timestamp" do
803
806
  # Verify that we have a timestamp, it's in the correct format and within
804
807
  # 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
808
+ expect(@unsigned_parameters).to have_key("oauth_timestamp")
809
+ expect(@unsigned_parameters["oauth_timestamp"]).to match(/^[0-9]+$/)
810
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be <= Time.now.to_i
811
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be >= Time.now.to_i - 1
809
812
  end
810
813
 
811
- it 'should have a valid nonce' do
814
+ it "should have a valid nonce" do
812
815
  # Verify that we have a nonce and that it has sufficient length for
813
816
  # uniqueness.
814
- expect(@unsigned_parameters).to have_key('oauth_nonce')
815
- expect(@unsigned_parameters['oauth_nonce']).to match(/^[0-9a-zA-Z]{16,100}$/)
817
+ expect(@unsigned_parameters).to have_key("oauth_nonce")
818
+ expect(@unsigned_parameters["oauth_nonce"]).to match(/^[0-9a-zA-Z]{16,100}$/)
816
819
  end
817
820
 
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'
821
+ it "should have the correct OAuth version" do
822
+ expect(@unsigned_parameters).to have_key("oauth_version")
823
+ expect(@unsigned_parameters["oauth_version"]).to eq "1.0"
821
824
  end
822
825
  end
823
826
 
824
- describe Signet::OAuth1, 'when generating token credential parameters ' +
825
- 'with Signet::OAuth1::Credential objects' do
827
+ describe Signet::OAuth1, "when generating token credential parameters " \
828
+ "with Signet::OAuth1::Credential objects" do
826
829
  before do
827
830
  @client_credential = Signet::OAuth1::Credential.new(
828
- 'dpf43f3p2l4k3l03', 'kd94hf93k423kf44'
831
+ "dpf43f3p2l4k3l03", "kd94hf93k423kf44"
829
832
  )
830
833
  @temporary_credential = Signet::OAuth1::Credential.new(
831
- 'hh5s93j4hdidpola', 'hdhd0244k9j7ao03'
834
+ "hh5s93j4hdidpola", "hdhd0244k9j7ao03"
832
835
  )
833
- @verifier = '473f82d3'
834
- @signature_method = 'HMAC-SHA1'
836
+ @verifier = "473f82d3"
837
+ @signature_method = "HMAC-SHA1"
835
838
  @unsigned_parameters =
836
839
  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 }
840
+ client_credential: @client_credential,
841
+ temporary_credential: @temporary_credential,
842
+ signature_method: @signature_method,
843
+ verifier: @verifier
844
+ ).each_with_object({}) { |(k, v), h| h[k] = v; }
842
845
  end
843
846
 
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
847
+ it "should have the correct client credential key" do
848
+ expect(@unsigned_parameters).to have_key("oauth_consumer_key")
849
+ expect(@unsigned_parameters["oauth_consumer_key"]).to eq @client_credential.key
847
850
  end
848
851
 
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
852
+ it "should have the correct temporary credentials key" do
853
+ expect(@unsigned_parameters).to have_key("oauth_token")
854
+ expect(@unsigned_parameters["oauth_token"]).to eq @temporary_credential.key
852
855
  end
853
856
 
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
857
+ it "should have the correct signature method" do
858
+ expect(@unsigned_parameters).to have_key("oauth_signature_method")
859
+ expect(@unsigned_parameters["oauth_signature_method"]).to eq @signature_method
857
860
  end
858
861
 
859
- it 'should have a valid timestamp' do
862
+ it "should have a valid timestamp" do
860
863
  # Verify that we have a timestamp, it's in the correct format and within
861
864
  # 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
865
+ expect(@unsigned_parameters).to have_key("oauth_timestamp")
866
+ expect(@unsigned_parameters["oauth_timestamp"]).to match(/^[0-9]+$/)
867
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be <= Time.now.to_i
868
+ expect(@unsigned_parameters["oauth_timestamp"].to_i).to be >= Time.now.to_i - 1
866
869
  end
867
870
 
868
- it 'should have a valid nonce' do
871
+ it "should have a valid nonce" do
869
872
  # Verify that we have a nonce and that it has sufficient length for
870
873
  # uniqueness.
871
- expect(@unsigned_parameters).to have_key('oauth_nonce')
872
- expect(@unsigned_parameters['oauth_nonce']).to match(/^[0-9a-zA-Z]{16,100}$/)
874
+ expect(@unsigned_parameters).to have_key("oauth_nonce")
875
+ expect(@unsigned_parameters["oauth_nonce"]).to match(/^[0-9a-zA-Z]{16,100}$/)
873
876
  end
874
877
 
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'
878
+ it "should have the correct OAuth version" do
879
+ expect(@unsigned_parameters).to have_key("oauth_version")
880
+ expect(@unsigned_parameters["oauth_version"]).to eq "1.0"
878
881
  end
879
882
  end
880
883
 
881
- describe Signet::OAuth1, 'extracting credential keys from options' do
882
- it 'should raise an error for bogus credentials' do
884
+ describe Signet::OAuth1, "extracting credential keys from options" do
885
+ it "should raise an error for bogus credentials" do
883
886
  expect(lambda do
884
887
  Signet::OAuth1.extract_credential_key_option(
885
- :client, {:client_credential_key => true}
888
+ :client, client_credential_key: true
886
889
  )
887
890
  end).to raise_error(TypeError)
888
891
  end
889
892
 
890
- it 'should raise an error for bogus credentials' do
893
+ it "should raise an error for bogus credentials" do
891
894
  expect(lambda do
892
895
  Signet::OAuth1.extract_credential_key_option(
893
- :client, {:client_credential => 42}
896
+ :client, client_credential: 42
894
897
  )
895
898
  end).to raise_error(TypeError)
896
899
  end
897
900
 
898
- it 'should raise an error for bogus credentials' do
901
+ it "should raise an error for bogus credentials" do
899
902
  expect(lambda do
900
903
  Signet::OAuth1.extract_credential_key_option(
901
- :client, {:client => 42}
904
+ :client, client: 42
902
905
  )
903
906
  end).to raise_error(TypeError)
904
907
  end
905
908
 
906
- it 'should return nil for missing credential key' do
909
+ it "should return nil for missing credential key" do
907
910
  expect(Signet::OAuth1.extract_credential_key_option(:client, {})).to eq nil
908
911
  end
909
912
 
910
- it 'should find the correct credential key' do
913
+ it "should find the correct credential key" do
911
914
  expect(Signet::OAuth1.extract_credential_key_option(
912
- :client, {:client_credential_key => 'dpf43f3p2l4k3l03'}
913
- )).to eq 'dpf43f3p2l4k3l03'
915
+ :client, client_credential_key: "dpf43f3p2l4k3l03"
916
+ )).to eq "dpf43f3p2l4k3l03"
914
917
  end
915
918
 
916
- it 'should find the correct credential key' do
919
+ it "should find the correct credential key" do
917
920
  expect(Signet::OAuth1.extract_credential_key_option(
918
- :client, {:client_credential => Signet::OAuth1::Credential.new(
919
- 'dpf43f3p2l4k3l03', 'kd94hf93k423kf44'
920
- )}
921
- )).to eq 'dpf43f3p2l4k3l03'
921
+ :client, client_credential: Signet::OAuth1::Credential.new(
922
+ "dpf43f3p2l4k3l03", "kd94hf93k423kf44"
923
+ )
924
+ )).to eq "dpf43f3p2l4k3l03"
922
925
  end
923
926
 
924
- it 'should find the correct credential key' do
927
+ it "should find the correct credential key" do
925
928
  client = Signet::OAuth1::Client.new
926
929
  client.client_credential = Signet::OAuth1::Credential.new(
927
- 'dpf43f3p2l4k3l03', 'kd94hf93k423kf44'
930
+ "dpf43f3p2l4k3l03", "kd94hf93k423kf44"
928
931
  )
929
932
  expect(Signet::OAuth1.extract_credential_key_option(
930
- :client, {:client => client}
931
- )).to eq 'dpf43f3p2l4k3l03'
933
+ :client, client: client
934
+ )).to eq "dpf43f3p2l4k3l03"
932
935
  end
933
936
 
934
- it 'should find the correct credential key' do
937
+ it "should find the correct credential key" do
935
938
  client = Signet::OAuth1::Client.new
936
939
  client.temporary_credential = Signet::OAuth1::Credential.new(
937
- 'hh5s93j4hdidpola', 'hdhd0244k9j7ao03'
940
+ "hh5s93j4hdidpola", "hdhd0244k9j7ao03"
938
941
  )
939
942
  expect(Signet::OAuth1.extract_credential_key_option(
940
- :temporary, {:client => client}
941
- )).to eq 'hh5s93j4hdidpola'
943
+ :temporary, client: client
944
+ )).to eq "hh5s93j4hdidpola"
942
945
  end
943
946
  end
944
947
 
945
- describe Signet::OAuth1, 'extracting credential secrets from options' do
946
- it 'should raise an error for bogus credentials' do
948
+ describe Signet::OAuth1, "extracting credential secrets from options" do
949
+ it "should raise an error for bogus credentials" do
947
950
  expect(lambda do
948
951
  Signet::OAuth1.extract_credential_secret_option(
949
- :client, {:client_credential_secret => true}
952
+ :client, client_credential_secret: true
950
953
  )
951
954
  end).to raise_error(TypeError)
952
955
  end
953
956
 
954
- it 'should raise an error for bogus credentials' do
957
+ it "should raise an error for bogus credentials" do
955
958
  expect(lambda do
956
959
  Signet::OAuth1.extract_credential_secret_option(
957
- :client, {:client_credential => 42}
960
+ :client, client_credential: 42
958
961
  )
959
962
  end).to raise_error(TypeError)
960
963
  end
961
964
 
962
- it 'should raise an error for bogus credentials' do
965
+ it "should raise an error for bogus credentials" do
963
966
  expect(lambda do
964
967
  Signet::OAuth1.extract_credential_secret_option(
965
- :client, {:client => 42}
968
+ :client, client: 42
966
969
  )
967
970
  end).to raise_error(TypeError)
968
971
  end
969
972
 
970
- it 'should raise an error for missing credential secret' do
973
+ it "should raise an error for missing credential secret" do
971
974
  expect(Signet::OAuth1.extract_credential_secret_option(:client, {})).to eq nil
972
975
  end
973
976
 
974
- it 'should find the correct credential secret' do
977
+ it "should find the correct credential secret" do
975
978
  expect(Signet::OAuth1.extract_credential_secret_option(
976
- :client, {:client_credential_secret => 'kd94hf93k423kf44'}
977
- )).to eq 'kd94hf93k423kf44'
979
+ :client, client_credential_secret: "kd94hf93k423kf44"
980
+ )).to eq "kd94hf93k423kf44"
978
981
  end
979
982
 
980
- it 'should find the correct credential secret' do
983
+ it "should find the correct credential secret" do
981
984
  expect(Signet::OAuth1.extract_credential_secret_option(
982
- :client, {:client_credential => Signet::OAuth1::Credential.new(
983
- 'dpf43f3p2l4k3l03', 'kd94hf93k423kf44'
984
- )}
985
- )).to eq 'kd94hf93k423kf44'
985
+ :client, client_credential: Signet::OAuth1::Credential.new(
986
+ "dpf43f3p2l4k3l03", "kd94hf93k423kf44"
987
+ )
988
+ )).to eq "kd94hf93k423kf44"
986
989
  end
987
990
 
988
- it 'should find the correct credential secret' do
991
+ it "should find the correct credential secret" do
989
992
  client = Signet::OAuth1::Client.new
990
993
  client.client_credential = Signet::OAuth1::Credential.new(
991
- 'dpf43f3p2l4k3l03', 'kd94hf93k423kf44'
994
+ "dpf43f3p2l4k3l03", "kd94hf93k423kf44"
992
995
  )
993
996
  expect(Signet::OAuth1.extract_credential_secret_option(
994
- :client, {:client => client}
995
- )).to eq 'kd94hf93k423kf44'
997
+ :client, client: client
998
+ )).to eq "kd94hf93k423kf44"
996
999
  end
997
1000
 
998
- it 'should find the correct credential secret' do
1001
+ it "should find the correct credential secret" do
999
1002
  client = Signet::OAuth1::Client.new
1000
1003
  client.temporary_credential = Signet::OAuth1::Credential.new(
1001
- 'hh5s93j4hdidpola', 'hdhd0244k9j7ao03'
1004
+ "hh5s93j4hdidpola", "hdhd0244k9j7ao03"
1002
1005
  )
1003
1006
  expect(Signet::OAuth1.extract_credential_secret_option(
1004
- :temporary, {:client => client}
1005
- )).to eq 'hdhd0244k9j7ao03'
1007
+ :temporary, client: client
1008
+ )).to eq "hdhd0244k9j7ao03"
1006
1009
  end
1007
1010
  end