signet 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec4912c2e8dee5bddbb079ad27efb8d99654abaf
4
- data.tar.gz: 3e9118048022e46c0e50a25256e2448283ace5df
3
+ metadata.gz: fe41f18e201f3ff8052e35418010f84ea01ff4e7
4
+ data.tar.gz: 963c6a9098d23b2d675a7dfa7c085dc53f5d0376
5
5
  SHA512:
6
- metadata.gz: 48faf986e4169b761eabc7b03268e427417ce2cb7aa575dd6364e4e3883a74492b6b554c3ea950455229af51dcaab31b6fdddcdee8836f1b5361ad8c1408daf1
7
- data.tar.gz: 6689401b7e31bf871e4264e8d12810aea2821220c05d9afb962e875b61104b085c1275e12a9c3279988f215982647918461af0a5c6108e964c2eb754c7d65618
6
+ metadata.gz: b31a6ba85a206b28b9341949c19aae39ba6a027a6a2fb6bf3994a6705353d987c2283b93e8138675ce4ca66efb18a02d0f113a079c4b20f05cefb04c72116c3b
7
+ data.tar.gz: 68db4243e27964341dc75f25d1232c36b73df79f84ccb1e4c0d60652b2660e760649dbe4980286000acc65190b148fe9d72ae77b632e51d5a680358f491959a5
@@ -1,3 +1,9 @@
1
+ # 0.7.3
2
+
3
+ * Fix timestamp parsing on 32-bit systems
4
+ * Fix expiration check when issue/expiry times are nil
5
+
6
+
1
7
  # 0.7.2
2
8
 
3
9
  * Don't assume Faraday form encoding middleware is present
@@ -801,7 +801,7 @@ module Signet
801
801
  # @return [TrueClass, FalseClass]
802
802
  # The expiration state of the access token.
803
803
  def expires_within?(sec)
804
- return self.expires_at != nil && Time.now >= (self.expires_at - sec)
804
+ return self.expires_at.nil? || Time.now >= (self.expires_at - sec)
805
805
  end
806
806
 
807
807
  ##
@@ -1177,7 +1177,7 @@ module Signet
1177
1177
  time
1178
1178
  when String
1179
1179
  Time.parse(time)
1180
- when Fixnum
1180
+ when Fixnum, Bignum
1181
1181
  Time.at(time)
1182
1182
  else
1183
1183
  fail "Invalid time value #{time}"
@@ -18,7 +18,7 @@ unless defined? Signet::VERSION
18
18
  module VERSION
19
19
  MAJOR = 0
20
20
  MINOR = 7
21
- TINY = 2
21
+ TINY = 3
22
22
 
23
23
  STRING = [MAJOR, MINOR, TINY].join('.')
24
24
  end
@@ -11,13 +11,8 @@
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
-
15
- spec_dir = File.expand_path(File.join(File.dirname(__FILE__), "../.."))
16
- $:.unshift(spec_dir)
17
- $:.uniq!
18
-
19
14
  require 'spec_helper'
20
-
15
+ require 'multi_json'
21
16
  require 'signet/oauth_1/client'
22
17
  require 'addressable/uri'
23
18
  require 'stringio'
@@ -11,13 +11,7 @@
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
-
15
- spec_dir = File.expand_path(File.join(File.dirname(__FILE__), "../.."))
16
- $:.unshift(spec_dir)
17
- $:.uniq!
18
-
19
14
  require 'spec_helper'
20
-
21
15
  require 'signet/oauth_1/credential'
22
16
 
23
17
  describe Signet::OAuth1::Credential, 'with a Hash for initialization' do
@@ -11,13 +11,7 @@
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
-
15
- spec_dir = File.expand_path(File.join(File.dirname(__FILE__), "../.."))
16
- $:.unshift(spec_dir)
17
- $:.uniq!
18
-
19
14
  require 'spec_helper'
20
-
21
15
  require 'signet/oauth_1/server'
22
16
  require 'signet/oauth_1/client'
23
17
  require 'addressable/uri'
@@ -11,14 +11,9 @@
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
-
15
- spec_dir = File.expand_path(File.join(File.dirname(__FILE__), "../../.."))
16
- $:.unshift(spec_dir)
17
- $:.uniq!
18
-
19
14
  require 'spec_helper'
20
-
21
15
  require 'signet'
16
+ require 'signet/oauth_1'
22
17
  require 'signet/oauth_1/signature_methods/hmac_sha1'
23
18
 
24
19
  describe Signet::OAuth1::HMACSHA1 do
@@ -11,14 +11,9 @@
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
-
15
- spec_dir = File.expand_path(File.join(File.dirname(__FILE__), "../../.."))
16
- $:.unshift(spec_dir)
17
- $:.uniq!
18
-
19
14
  require 'spec_helper'
20
-
21
15
  require 'signet'
16
+ require 'signet/oauth_1'
22
17
  require 'signet/oauth_1/signature_methods/plaintext'
23
18
 
24
19
  describe Signet::OAuth1::PLAINTEXT do
@@ -11,14 +11,9 @@
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
-
15
- spec_dir = File.expand_path(File.join(File.dirname(__FILE__), "../../.."))
16
- $:.unshift(spec_dir)
17
- $:.uniq!
18
-
19
14
  require 'spec_helper'
20
-
21
15
  require 'signet'
16
+ require 'signet/oauth_1'
22
17
  require 'signet/oauth_1/signature_methods/rsa_sha1'
23
18
 
24
19
  describe Signet::OAuth1::RSASHA1 do
@@ -11,13 +11,7 @@
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
-
15
- spec_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
16
- $:.unshift(spec_dir)
17
- $:.uniq!
18
-
19
14
  require 'spec_helper'
20
-
21
15
  require 'signet/oauth_1'
22
16
  require 'signet/oauth_1/client'
23
17
  require 'signet/oauth_1/credential'
@@ -11,13 +11,7 @@
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
-
15
- spec_dir = File.expand_path(File.join(File.dirname(__FILE__), "../.."))
16
- $:.unshift(spec_dir)
17
- $:.uniq!
18
-
19
14
  require 'spec_helper'
20
-
21
15
  require 'signet/oauth_2/client'
22
16
  require 'openssl'
23
17
  require 'jwt'
@@ -441,6 +435,21 @@ describe Signet::OAuth2::Client, 'configured for Google userinfo API' do
441
435
  expect(@client).to_not be_expired
442
436
  end
443
437
 
438
+ it 'should indicate the token is expired if expired_at nil' do
439
+ @client.expires_at = nil
440
+ expect(@client.expires_within?(60)).to be true
441
+ end
442
+
443
+ it 'should indicate the token is not expiring when expiry beyond window' do
444
+ @client.expires_at = Time.now+100
445
+ expect(@client.expires_within?(60)).to be false
446
+ end
447
+
448
+ it 'should indicate the token is expiring soon when expiry within window' do
449
+ @client.expires_at = Time.now+30
450
+ expect(@client.expires_within?(60)).to be true
451
+ end
452
+
444
453
  it 'should raise an error if the authorization endpoint is not secure' do
445
454
  @client.client_id = 'client-12345'
446
455
  @client.client_secret = 'secret-12345'
@@ -888,7 +897,7 @@ xwIDAQAB
888
897
  -----END PUBLIC KEY-----
889
898
  PUBKEY
890
899
  @client.decoded_id_token(pubkey)
891
- end).to raise_error(JWT::VerificationError)
900
+ end).to raise_error
892
901
  stubs.verify_stubbed_calls
893
902
  end
894
903
  end
@@ -11,13 +11,8 @@
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
-
15
- spec_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
16
- $:.unshift(spec_dir)
17
- $:.uniq!
18
-
19
14
  require 'spec_helper'
20
-
15
+ require 'signet/errors'
21
16
  require 'signet/oauth_2'
22
17
 
23
18
  describe Signet::OAuth2 do
@@ -11,13 +11,7 @@
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
-
15
- spec_dir = File.expand_path(File.join(File.dirname(__FILE__)))
16
- $:.unshift(spec_dir)
17
- $:.uniq!
18
-
19
14
  require 'spec_helper'
20
-
21
15
  require 'signet/oauth_2'
22
16
 
23
17
  describe Signet do
@@ -1,10 +1,5 @@
1
- spec_dir = File.expand_path(File.dirname(__FILE__))
2
- root_dir = File.expand_path(File.join(spec_dir, ".."))
3
- lib_dir = File.expand_path(File.join(root_dir, "lib"))
4
- compat_dir = File.expand_path(File.join(spec_dir, "force_compat"))
1
+ compat_dir = File.expand_path(File.join('..', 'force_compat'))
5
2
 
6
- $:.unshift(spec_dir)
7
- $:.unshift(lib_dir)
8
3
  $:.unshift(compat_dir)
9
4
  $:.uniq!
10
5
 
@@ -0,0 +1,17 @@
1
+ RSpec.describe 'spec_helper.rb' do
2
+ let(:spec_dir) { File.expand_path(File.dirname(__FILE__)) }
3
+ let(:root_dir) { File.expand_path(File.join(spec_dir, '..')) }
4
+ let(:lib_dir) { File.expand_path(File.join(root_dir, 'lib')) }
5
+
6
+ describe 'spec_dir' do
7
+ it 'is already in $LOAD_PATH' do
8
+ expect($LOAD_PATH).to include spec_dir
9
+ end
10
+ end
11
+
12
+ describe 'lib_dir' do
13
+ it 'is already in $LOAD_PATH' do
14
+ expect($LOAD_PATH).to include lib_dir
15
+ end
16
+ end
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: signet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Aman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-12-21 00:00:00.000000000 Z
12
+ date: 2016-06-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
@@ -186,7 +186,6 @@ files:
186
186
  - spec/signet/oauth_1/client_spec.rb
187
187
  - spec/signet/oauth_1/credential_spec.rb
188
188
  - spec/signet/oauth_1/server_spec.rb
189
- - spec/signet/oauth_1/services/google_spec.rb
190
189
  - spec/signet/oauth_1/signature_methods/hmac_sha1_spec.rb
191
190
  - spec/signet/oauth_1/signature_methods/plaintext_spec.rb
192
191
  - spec/signet/oauth_1/signature_methods/rsa_sha1_spec.rb
@@ -196,6 +195,7 @@ files:
196
195
  - spec/signet_spec.rb
197
196
  - spec/spec.opts
198
197
  - spec/spec_helper.rb
198
+ - spec/spec_helper_spec.rb
199
199
  - tasks/clobber.rake
200
200
  - tasks/gem.rake
201
201
  - tasks/git.rake
@@ -1,241 +0,0 @@
1
- # Copyright (C) 2010 Google Inc.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- spec_dir = File.expand_path(File.join(File.dirname(__FILE__), "../../.."))
16
- $:.unshift(spec_dir)
17
- $:.uniq!
18
-
19
- require 'spec_helper'
20
-
21
- require 'signet/oauth_1/client'
22
- require 'faraday'
23
- require 'stringio'
24
-
25
- def merge_body(chunked_body)
26
- merged_body = StringIO.new
27
- chunked_body.each do |chunk|
28
- merged_body.write(chunk)
29
- end
30
- return merged_body.string
31
- end
32
-
33
- describe Signet::OAuth1::Client, 'configured for standard Google APIs' do
34
- before do
35
- @client = Signet::OAuth1::Client.new(
36
- :temporary_credential_uri =>
37
- 'https://www.google.com/accounts/OAuthGetRequestToken',
38
- :authorization_uri =>
39
- 'https://www.google.com/accounts/OAuthAuthorizeToken',
40
- :token_credential_uri =>
41
- 'https://www.google.com/accounts/OAuthGetAccessToken',
42
- :client_credential_key => 'anonymous',
43
- :client_credential_secret => 'anonymous'
44
- )
45
- end
46
-
47
- it 'should raise an error if scope is omitted' do
48
- expect(lambda do
49
- @client.fetch_temporary_credential!
50
- end).to raise_error(Signet::AuthorizationError)
51
- end
52
-
53
- it 'should raise an error if the server gives an unexpected status' do
54
- stubs = Faraday::Adapter::Test::Stubs.new do |stub|
55
- stub.post('/accounts/OAuthGetRequestToken') do
56
- [509, {}, 'Rate limit hit or something.']
57
- end
58
- end
59
- expect(lambda do
60
- connection = Faraday.new(:url => 'https://www.google.com') do |builder|
61
- builder.adapter(:test, stubs)
62
- end
63
- @client.fetch_temporary_credential!(
64
- :connection => connection,
65
- :additional_parameters => {
66
- :scope => 'https://www.google.com/m8/feeds/'
67
- }
68
- )
69
- end).to raise_error(Signet::AuthorizationError)
70
- stubs.verify_stubbed_calls
71
- end
72
-
73
- it 'should be able to obtain temporary credentials for the Contacts API' do
74
- @client.fetch_temporary_credential!(:additional_parameters => {
75
- :scope => 'https://www.google.com/m8/feeds/'
76
- })
77
- expect(@client.temporary_credential_key.size).to be > 0
78
- expect(@client.temporary_credential_secret.size).to be > 0
79
- end
80
-
81
- it 'should have the correct authorization URI' do
82
- @client.fetch_temporary_credential!(:additional_parameters => {
83
- :scope => 'https://www.google.com/m8/feeds/'
84
- })
85
- expect(@client.authorization_uri.query_values["oauth_token"]).to eq(
86
- @client.temporary_credential_key)
87
- end
88
-
89
- it 'should raise an error if the temporary credentials are bogus' do
90
- expect(lambda do
91
- @client.temporary_credential_key = '12345'
92
- @client.temporary_credential_secret = '12345'
93
- @client.fetch_token_credential!(:verifier => 'XbVKagBShNsAGBRJWoC4gtFR')
94
- end).to raise_error(Signet::AuthorizationError)
95
- end
96
-
97
- it 'should raise an error if the token credentials are bogus' do
98
- expect do
99
- skip 'Need to replace with mocked response as google endpoints no longer use oauth1'
100
- @client.token_credential_key = '12345'
101
- @client.token_credential_secret = '12345'
102
- res = @client.fetch_protected_resource(
103
- :uri =>
104
- 'https://www.google.com/m8/feeds/'
105
- )
106
- puts "Res = #{res.status}"
107
- end.to raise_error(Signet::AuthorizationError)
108
- end
109
-
110
- # We have to stub responses for the token credentials
111
-
112
- it 'should be able to obtain token credentials for the Contacts API' do
113
- stubs = Faraday::Adapter::Test::Stubs.new do |stub|
114
- stub.post('/accounts/OAuthGetAccessToken') do
115
- [
116
- 200,
117
- {},
118
- 'oauth_token=1%2FYFw6UH2Dn7W691-qAbCfsmqEHQrPb7ptIvYx9m6YkUQ&' +
119
- 'oauth_token_secret=Ew3YHAY4bcBryiOUvbdHGa57'
120
- ]
121
- end
122
- end
123
- connection = Faraday.new(:url => 'https://www.google.com') do |builder|
124
- builder.adapter(:test, stubs)
125
- end
126
- @client.temporary_credential_key = '4/oegn2eP-3yswD7HiESnJOB-8oh2i'
127
- @client.temporary_credential_secret = '8E1BF0J6ovMva0j87atj/tTG'
128
- @client.fetch_token_credential!(
129
- :verifier => 'XbVKagBShNsAGBRJWoC4gtFR',
130
- :connection => connection,
131
- :additional_parameters => {
132
- :scope => 'https://www.google.com/m8/feeds/'
133
- }
134
- )
135
- expect(@client.token_credential_key).to eq '1/YFw6UH2Dn7W691-qAbCfsmqEHQrPb7ptIvYx9m6YkUQ'
136
- expect(@client.token_credential_secret).to eq 'Ew3YHAY4bcBryiOUvbdHGa57'
137
- stubs.verify_stubbed_calls
138
- end
139
-
140
- it 'should raise an error if the server gives an unexpected status' do
141
- stubs = Faraday::Adapter::Test::Stubs.new do |stub|
142
- stub.post('/accounts/OAuthGetAccessToken') do
143
- [509, {}, 'Rate limit hit or something.']
144
- end
145
- end
146
- expect(lambda do
147
- connection = Faraday.new(:url => 'https://www.google.com') do |builder|
148
- builder.adapter(:test, stubs)
149
- end
150
- @client.temporary_credential_key = '4/oegn2eP-3yswD7HiESnJOB-8oh2i'
151
- @client.temporary_credential_secret = '8E1BF0J6ovMva0j87atj/tTG'
152
- @client.fetch_token_credential!(
153
- :verifier => 'XbVKagBShNsAGBRJWoC4gtFR',
154
- :connection => connection,
155
- :additional_parameters => {
156
- :scope => 'https://www.google.com/m8/feeds/'
157
- }
158
- )
159
- end).to raise_error(Signet::AuthorizationError)
160
- stubs.verify_stubbed_calls
161
- end
162
-
163
- it 'should correctly fetch the protected resource' do
164
- stubs = Faraday::Adapter::Test::Stubs.new do |stub|
165
- stub.get('/api/people/@me/@self') do
166
- [
167
- 200,
168
- {'Content-Type' => 'application/json'},
169
- '{"data":"goes here"}'
170
- ]
171
- end
172
- end
173
- connection = Faraday.new(
174
- :url => 'http://www-opensocial.googleusercontent.com'
175
- ) do |builder|
176
- builder.adapter(:test, stubs)
177
- end
178
- @client.token_credential_key =
179
- '1/YFw6UH2Dn7W691-qAbCfsmqEHQrPb7ptIvYx9m6YkUQ'
180
- @client.token_credential_secret = 'Ew3YHAY4bcBryiOUvbdHGa57'
181
- response = @client.fetch_protected_resource(
182
- :connection => connection,
183
- :uri =>
184
- 'http://www-opensocial.googleusercontent.com/api/people/@me/@self'
185
- )
186
- expect(response.status).to eq 200
187
- expect(response.headers['Content-Type']).to eq 'application/json'
188
- expect(response.body).to eq '{"data":"goes here"}'
189
- end
190
-
191
- it 'should correctly fetch the protected resource' do
192
- stubs = Faraday::Adapter::Test::Stubs.new do |stub|
193
- stub.get('/api/people/@me/@self') do
194
- [
195
- 200,
196
- {'Content-Type' => 'application/json'},
197
- '{"data":"goes here"}'
198
- ]
199
- end
200
- end
201
- connection = Faraday.new(
202
- :url => 'http://www-opensocial.googleusercontent.com'
203
- ) do |builder|
204
- builder.adapter(:test, stubs)
205
- end
206
- @client.token_credential_key =
207
- '1/YFw6UH2Dn7W691-qAbCfsmqEHQrPb7ptIvYx9m6YkUQ'
208
- @client.token_credential_secret = 'Ew3YHAY4bcBryiOUvbdHGa57'
209
- response = @client.fetch_protected_resource(
210
- :connection => connection,
211
- :request => Faraday.default_connection.build_request(:get) do |req|
212
- req.url(
213
- 'http://www-opensocial.googleusercontent.com/api/people/@me/@self'
214
- )
215
- end
216
- )
217
- expect(response.status).to eq 200
218
- expect(response.headers['Content-Type']).to eq 'application/json'
219
- expect(response.body).to eq '{"data":"goes here"}'
220
- end
221
- end
222
-
223
- describe Signet::OAuth1::Client, 'configured for two-legged OAuth' do
224
- before do
225
- @client = Signet::OAuth1::Client.new(
226
- :client_credential_key => '12345',
227
- :client_credential_secret => '12345',
228
- :two_legged => true
229
- )
230
- end
231
-
232
- it 'should raise an error if the client credentials are bogus' do
233
- skip 'Need to replace with mocked response as google endpoints no longer use oauth1'
234
- expect(lambda do
235
- @client.fetch_protected_resource(
236
- :uri =>
237
- 'https://www.google.com/m8/feeds/'
238
- )
239
- end).to raise_error(Signet::AuthorizationError)
240
- end
241
- end