@@ -152,25 +152,23 @@ def assert_initialized_token(target) # rubocop:disable Metrics/AbcSize
152152 expect ( access ) . to be_expired
153153 end
154154
155- describe 'time skew ' do
156- let ( :time_skew ) { 10 }
155+ describe 'min validity ' do
156+ let ( :old_now ) { 1_528_454_438 }
157157 let ( :expires_in ) { 300 }
158- let ( :expires_at ) { Time . now . to_i - 10 + expires_in }
158+ let ( :expires_at ) { 1_528_454_438 + expires_in }
159159 let! ( :access ) { described_class . new ( client , token , :refresh_token => 'abaca' , :expires_at => expires_at , :expires_in => expires_in ) }
160+ let ( :now ) { Time . at ( expires_at ) - AccessToken ::MIN_VALIDITY }
160161
161- context 'when not within time skew correction' do
162- let ( :now ) { Time . at ( expires_at ) + time_skew + 1 }
163-
162+ context 'when not within min validity correction' do
164163 it 'access is expired' do
165164 allow ( Time ) . to receive ( :now ) . and_return ( now )
166165 expect ( access ) . to be_expired
167166 end
168167 end
169168
170- context 'when within time skew correction' do
171- let ( :now ) { Time . at ( expires_at ) + time_skew - 1 }
172-
169+ context 'when within min validity correction' do
173170 it 'access is not expired' do
171+ allow ( Time ) . to receive ( :now ) . and_return ( now - 1 )
174172 expect ( access ) . not_to be_expired
175173 end
176174 end
@@ -256,7 +254,7 @@ def assert_initialized_token(target) # rubocop:disable Metrics/AbcSize
256254 end
257255
258256 context 'when not within time skew correction' do
259- let ( :local_now ) { Time . at ( exp ) + time_skew + 1 }
257+ let ( :local_now ) { Time . at ( exp ) + time_skew - AccessToken :: MIN_VALIDITY }
260258
261259 it 'access is expired' do
262260 allow ( Time ) . to receive ( :now ) . and_return ( local_now )
@@ -265,7 +263,7 @@ def assert_initialized_token(target) # rubocop:disable Metrics/AbcSize
265263 end
266264
267265 context 'when within time skew correction' do
268- let ( :local_now ) { Time . at ( exp ) + time_skew - 1 }
266+ let ( :local_now ) { Time . at ( exp ) + time_skew - AccessToken :: MIN_VALIDITY - 1 }
269267
270268 it 'access is not expired' do
271269 allow ( Time ) . to receive ( :now ) . and_return ( local_now )
0 commit comments