signet 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/signet/oauth_2/client.rb +13 -1
- data/lib/signet/version.rb +1 -1
- data/signet.gemspec +6 -0
- data/spec/signet/oauth_2/client_spec.rb +35 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 680cfcd2752495cc3e2086d74b858d6d279b78a223a2102e1a076736c3dd2fd9
|
4
|
+
data.tar.gz: 3e073eeb03f3017b17ca776cb6c7a1c7b6495cebe61a0931206af608a736eb33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bd67c59d78d3e1b10f54de27168bc95022b3b36ed001773cc83ba06eb36cfa8a81d244da724952b7c88a4a9a272fa4ab128af9c1774683460392167302777bc
|
7
|
+
data.tar.gz: 4516060a3baced5581ad3534cc13d195a5855c97d4bdbd1fe4a801034ef80d320527c692943cf37ae36d55dd889b0598c37966d9162a5464cd5fac76e8e2b13e
|
data/CHANGELOG.md
CHANGED
@@ -233,6 +233,11 @@ module Signet
|
|
233
233
|
# set, but this can be used to supply a more precise time.
|
234
234
|
self.issued_at = options[:issued_at] if options.has_key?(:issued_at)
|
235
235
|
|
236
|
+
# Special case where we want expires_at to be relative to issued_at
|
237
|
+
if options.has_key?(:issued_at) && options.has_key?(:expires_in)
|
238
|
+
set_relative_expires_at options[:issued_at], options[:expires_in]
|
239
|
+
end
|
240
|
+
|
236
241
|
self.access_token = options[:access_token] if options.has_key?(:access_token)
|
237
242
|
self.refresh_token = options[:refresh_token] if options.has_key?(:refresh_token)
|
238
243
|
self.id_token = options[:id_token] if options.has_key?(:id_token)
|
@@ -769,7 +774,7 @@ module Signet
|
|
769
774
|
|
770
775
|
##
|
771
776
|
# Returns the timestamp the access token will expire at.
|
772
|
-
# Returns nil if the token does not expire.
|
777
|
+
# Returns nil if the token does not expire.
|
773
778
|
#
|
774
779
|
# @return [Time, nil] The access token lifetime.
|
775
780
|
def expires_at
|
@@ -1196,6 +1201,13 @@ module Signet
|
|
1196
1201
|
fail "Invalid time value #{time}"
|
1197
1202
|
end
|
1198
1203
|
end
|
1204
|
+
|
1205
|
+
def set_relative_expires_at(issued_at, expires_in)
|
1206
|
+
self.issued_at = issued_at
|
1207
|
+
# Using local expires_in because if self.expires_in is used, it returns
|
1208
|
+
# the time left before the token expires
|
1209
|
+
self.expires_at = self.issued_at + expires_in.to_i
|
1210
|
+
end
|
1199
1211
|
end
|
1200
1212
|
end
|
1201
1213
|
end
|
data/lib/signet/version.rb
CHANGED
data/signet.gemspec
CHANGED
@@ -37,4 +37,10 @@ Gem::Specification.new do |s|
|
|
37
37
|
s.add_development_dependency 'simplecov', '~> 0.9'
|
38
38
|
|
39
39
|
s.post_install_message = Signet::VERSION::warn_on_old_ruby_version
|
40
|
+
|
41
|
+
if s.respond_to?(:metadata)
|
42
|
+
s.metadata['changelog_uri'] = 'https://github.com/google/signet/blob/master/CHANGELOG.md'
|
43
|
+
s.metadata['source_code_uri'] = 'https://github.com/google/signet'
|
44
|
+
s.metadata['bug_tracker_uri'] = 'https://github.com/google/signet/issues'
|
45
|
+
end
|
40
46
|
end
|
@@ -436,6 +436,41 @@ describe Signet::OAuth2::Client, 'configured for Google userinfo API' do
|
|
436
436
|
expect(@client).to be_expired
|
437
437
|
end
|
438
438
|
|
439
|
+
it 'should calculate the expires_at from issued_at when issued_at is set' do
|
440
|
+
expires_in = 3600
|
441
|
+
issued_at = Time.now - expires_in
|
442
|
+
@client.update_token!(
|
443
|
+
:issued_at => issued_at,
|
444
|
+
:expires_in => expires_in
|
445
|
+
)
|
446
|
+
expect(@client.expires_at).to eq issued_at + expires_in
|
447
|
+
expect(@client).to be_expired
|
448
|
+
end
|
449
|
+
|
450
|
+
it 'should calculate expires_at from Time.now when issed_at is NOT set' do
|
451
|
+
expires_in = 3600
|
452
|
+
expires_at = Time.now + expires_in
|
453
|
+
@client.update_token! :expires_in => expires_in
|
454
|
+
expect(@client.expires_at).to be_within(1).of(expires_at)
|
455
|
+
expect(@client).to_not be_expired
|
456
|
+
end
|
457
|
+
|
458
|
+
# This test is to document the way that expires_in has always been used:
|
459
|
+
# If expires_in is set on the client, it always resets the issued_at time
|
460
|
+
# to Time.now
|
461
|
+
it 'sets issued_at to Time.now when expires_in is not set through update_token!' do
|
462
|
+
one_hour = 3600
|
463
|
+
issued_at = Time.now - (2 * one_hour)
|
464
|
+
current_time = Time.now
|
465
|
+
|
466
|
+
@client.issued_at = issued_at
|
467
|
+
@client.expires_in = one_hour
|
468
|
+
|
469
|
+
expect(@client.issued_at).to_not eq issued_at
|
470
|
+
expect(@client.issued_at).to be_within(1).of(current_time)
|
471
|
+
expect(@client).to_not be_expired
|
472
|
+
end
|
473
|
+
|
439
474
|
it 'should allow setting expires_at manually' do
|
440
475
|
expires_at = Time.now+100
|
441
476
|
@client.expires_at = expires_at.to_i
|
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.9.
|
4
|
+
version: 0.9.2
|
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: 2018-
|
12
|
+
date: 2018-09-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|
@@ -214,7 +214,10 @@ files:
|
|
214
214
|
homepage: https://github.com/google/signet/
|
215
215
|
licenses:
|
216
216
|
- Apache-2.0
|
217
|
-
metadata:
|
217
|
+
metadata:
|
218
|
+
changelog_uri: https://github.com/google/signet/blob/master/CHANGELOG.md
|
219
|
+
source_code_uri: https://github.com/google/signet
|
220
|
+
bug_tracker_uri: https://github.com/google/signet/issues
|
218
221
|
post_install_message:
|
219
222
|
rdoc_options:
|
220
223
|
- "--main"
|