Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ group :test do
gem 'rspec-retry'
gem 'scss_lint', require: false
gem 'shoulda-matchers', '~> 4.0', require: false
gem 'timecop'
gem 'webdrivers', '~> 4.0'
gem 'webmock'
gem 'zonebie'
Expand Down
2 changes: 0 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,6 @@ GEM
thor (1.1.0)
thread_safe (0.3.6)
tilt (2.0.10)
timecop (0.9.4)
tpm-key_attestation (0.10.0)
bindata (~> 2.4)
openssl-signature_algorithm (~> 1.0)
Expand Down Expand Up @@ -799,7 +798,6 @@ DEPENDENCIES
stringex
strong_migrations (>= 0.4.2)
subprocess
timecop
uglifier (~> 4.2)
user_agent_parser
valid_email (>= 0.1.3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
expect(@analytics).to receive(:track_event).
with(Analytics::ACCOUNT_RESET, properties)

Timecop.travel(Time.zone.now + 2.days) do
travel_to(Time.zone.now + 2.days) do
session[:granted_token] = AccountResetRequest.all[0].granted_token
delete :delete
end
Expand Down Expand Up @@ -133,7 +133,7 @@
expect(@analytics).to receive(:track_event).
with(Analytics::ACCOUNT_RESET, properties)

Timecop.travel(Time.zone.now + 2.days) do
travel_to(Time.zone.now + 2.days) do
get :show, params: { token: AccountResetRequest.all[0].granted_token }
end

Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/idv/capture_doc_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

context 'with an expired token' do
it 'redirects to the root url' do
Timecop.travel(Time.zone.now + 1.day) do
travel_to(Time.zone.now + 1.day) do
get :index, params: { 'document-capture-session': session_uuid }
end

Expand Down
8 changes: 5 additions & 3 deletions spec/controllers/sign_up/completions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
end

describe '#update' do
let(:now) { Time.zone.now }
let(:now) { Time.zone.now.change(usec: 0) }

before do
stub_analytics
Expand Down Expand Up @@ -166,7 +166,8 @@
last_consented_at: now,
clear_deleted_at: true,
)
Timecop.freeze(now) do
freeze_time do
travel_to(now)
patch :update
end
end
Expand Down Expand Up @@ -217,7 +218,8 @@
last_consented_at: now,
clear_deleted_at: true,
)
Timecop.freeze(now) do
freeze_time do
travel_to(now)
patch :update
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
it 'updates the remember_device_revoked_at attribute for the user' do
now = Time.zone.now

expect { Timecop.freeze(now) { subject } }.to change { user.remember_device_revoked_at.to_i }.
expect { freeze_time { travel_to(now); subject } }.to change { user.remember_device_revoked_at.to_i }.
from(original_device_revoked_at.to_i).
to(now.to_i)
end
Expand Down
4 changes: 3 additions & 1 deletion spec/controllers/users/reset_passwords_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@
raw_reset_token, db_confirmation_token =
Devise.token_generator.generate(User, :reset_password_token)

Timecop.freeze(Time.zone.now) do
now = Time.zone.now
freeze_time do
travel_to(now)
Comment thread
mitchellhenke marked this conversation as resolved.
Outdated
user = create(
:user,
:signed_up,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
subject { delete :destroy, params: { sp_id: sp_id } }

it 'marks the identity as deleted and redirects' do
expect { Timecop.freeze(now) { subject } }.
expect { freeze_time { travel_to(now); subject } }.
to change { @identity.reload.deleted_at&.to_i }.
from(nil).to(now.to_i)
expect(response).to redirect_to(account_connected_accounts_path)
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/users/sessions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@
expected_time = now + 10
session[:pinged_at] = now

Timecop.travel(Time.zone.now + 10)
get :active
Timecop.return
travel_to(Time.zone.now + 10) do
get :active
end

expect(session[:pinged_at].to_i).to be_within(1).of(expected_time.to_i)
end
Expand Down
4 changes: 2 additions & 2 deletions spec/decorators/user_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@

describe '#lockout_time_remaining' do
it 'returns the difference in seconds between otp drift and second_factor_locked_at' do
Timecop.freeze(Time.zone.now) do
freeze_time do
user = build_stubbed(:user, second_factor_locked_at: Time.zone.now - 180)
user_decorator = UserDecorator.new(user)
allow(IdentityConfig.store).to receive(:lockout_period_in_minutes).and_return(8)
Expand All @@ -80,7 +80,7 @@

describe '#lockout_time_remaining_in_words' do
it 'converts lockout_time_remaining to words representing minutes and seconds left' do
Timecop.freeze(Time.zone.now) do
freeze_time do
user = build_stubbed(:user, second_factor_locked_at: Time.zone.now - 181)
user_decorator = UserDecorator.new(user)
allow(IdentityConfig.store).to receive(:lockout_period_in_minutes).and_return(8)
Expand Down
2 changes: 1 addition & 1 deletion spec/features/account_reset/cancel_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
click_button t('account_reset.request.yes_continue')
reset_email

Timecop.travel(Time.zone.now + 2.days) do
travel_to(Time.zone.now + 2.days) do
AccountReset::GrantRequestsAndSendEmails.new.perform(Time.zone.today)
open_last_email
click_email_link_matching(/cancel\?token/)
Expand Down
4 changes: 2 additions & 2 deletions spec/features/account_reset/delete_account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

reset_email

Timecop.travel(Time.zone.now + 2.days) do
travel_to(Time.zone.now + 2.days) do
AccountReset::GrantRequestsAndSendEmails.new.perform(Time.zone.today)
open_last_email
click_email_link_matching(/delete_account\?token/)
Expand Down Expand Up @@ -86,7 +86,7 @@
reset_email

allow(IdentityConfig.store).to receive(:push_notifications_enabled).and_return(true)
Timecop.travel(2.days.from_now) do
travel_to(2.days.from_now) do
request = stub_push_notification_request(
sp_push_notification_endpoint: push_notification_url,
event_type: PushNotification::AccountPurgedEvent::EVENT_TYPE,
Expand Down
2 changes: 1 addition & 1 deletion spec/features/event_disavowal_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
scenario 'attempting to disavow an event after a long time and the disavowal has expired' do
perform_disavowable_password_reset

Timecop.travel 11.days.from_now do
travel_to(11.days.from_now) do
open_last_email
click_email_link_matching(%r{events/disavow})

Expand Down
2 changes: 1 addition & 1 deletion spec/features/idv/doc_auth/agreement_step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def expect_doc_auth_first_step
end

around do |ex|
Timecop.travel(now) { ex.run }
travel_to(now) { ex.run }
end

it 'renders the warning banner but no other content' do
Expand Down
4 changes: 2 additions & 2 deletions spec/features/idv/doc_auth/document_capture_step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
throttle_type: :idv_acuant,
)

Timecop.travel(IdentityConfig.store.acuant_attempt_window_in_minutes.minutes.from_now) do
travel_to(IdentityConfig.store.acuant_attempt_window_in_minutes.minutes.from_now) do
sign_in_and_2fa_user(user)
complete_doc_auth_steps_before_document_capture_step
attach_and_submit_images
Expand Down Expand Up @@ -238,7 +238,7 @@
throttle_type: :idv_acuant,
)

Timecop.travel(IdentityConfig.store.acuant_attempt_window_in_minutes.minutes.from_now) do
travel_to(IdentityConfig.store.acuant_attempt_window_in_minutes.minutes.from_now) do
sign_in_and_2fa_user(user)
complete_doc_auth_steps_before_document_capture_step
attach_and_submit_images
Expand Down
2 changes: 1 addition & 1 deletion spec/features/idv/doc_auth/send_link_step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
throttle_type: :idv_send_link,
)

Timecop.travel(Time.zone.now + idv_send_link_attempt_window_in_minutes.minutes) do
travel_to(Time.zone.now + idv_send_link_attempt_window_in_minutes.minutes) do
fill_in :doc_auth_phone, with: '415-555-0199'
click_idv_continue
expect(page).to have_current_path(idv_doc_auth_link_sent_step)
Expand Down
2 changes: 1 addition & 1 deletion spec/features/idv/doc_auth/verify_step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
step_name: Idv::Steps::VerifyWaitStepShow,
)

Timecop.travel(IdentityConfig.store.idv_attempt_window_in_hours.hours.from_now) do
travel_to(IdentityConfig.store.idv_attempt_window_in_hours.hours.from_now) do
sign_in_and_2fa_user
complete_doc_auth_steps_before_verify_step
click_idv_continue
Expand Down
2 changes: 1 addition & 1 deletion spec/features/idv/doc_auth/welcome_step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def expect_doc_auth_upload_step
let(:now) { Time.zone.parse('2020-01-01T12:00:00Z') }

around do |ex|
Timecop.travel(now) { ex.run }
travel_to(now) { ex.run }
end

it 'renders the warning banner but no other content' do
Expand Down
4 changes: 2 additions & 2 deletions spec/features/idv/doc_capture/document_capture_step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@

DocAuth::Mock::DocAuthMockClient.reset!

Timecop.travel(IdentityConfig.store.acuant_attempt_window_in_minutes.minutes.from_now) do
travel_to(IdentityConfig.store.acuant_attempt_window_in_minutes.minutes.from_now) do
complete_doc_capture_steps_before_first_step(user)
attach_and_submit_images

Expand Down Expand Up @@ -374,7 +374,7 @@

DocAuth::Mock::DocAuthMockClient.reset!

Timecop.travel(IdentityConfig.store.acuant_attempt_window_in_minutes.minutes.from_now) do
travel_to(IdentityConfig.store.acuant_attempt_window_in_minutes.minutes.from_now) do
complete_doc_capture_steps_before_first_step(user)
attach_and_submit_images

Expand Down
2 changes: 1 addition & 1 deletion spec/features/idv/phone_otp_rate_limiting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def expect_rate_limit_to_expire(user)
Throttle.where(throttle_type: :idv_acuant).destroy_all

retry_minutes = IdentityConfig.store.lockout_period_in_minutes + 1
Timecop.travel retry_minutes.minutes.from_now do
travel_to(retry_minutes.minutes.from_now) do
start_idv_from_sp
complete_idv_steps_before_phone_otp_verification_step(user)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
start_idv_from_sp
complete_idv_steps_before_phone_otp_verification_step

Timecop.travel(expiration_minutes.minutes.from_now) do
travel_to(expiration_minutes.minutes.from_now) do
fill_in_code_with_last_phone_otp
click_button t('forms.buttons.submit.default')

Expand Down
2 changes: 1 addition & 1 deletion spec/features/multiple_emails/add_email_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@

Capybara.reset_session!

Timecop.travel 25.hours.from_now do
travel_to(25.hours.from_now) do
click_on_link_in_confirmation_email
expect(page).to have_current_path(root_path)
expect(page).to_not have_content(t('devise.confirmations.confirmed_but_sign_in'))
Expand Down
2 changes: 1 addition & 1 deletion spec/features/openid_connect/openid_connect_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

it 'succeeds in forcing login with prompt login and prior session' do
user = oidc_end_client_secret_jwt(prompt: 'login')
Timecop.travel((IdentityConfig.store.sp_handoff_bounce_max_seconds + 1).seconds.from_now) do
travel_to((IdentityConfig.store.sp_handoff_bounce_max_seconds + 1).seconds.from_now) do
oidc_end_client_secret_jwt(prompt: 'login', user: user)
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/features/remember_device/session_expiration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
visit_idp_from_sp_with_ial1(:oidc)
request_id = ServiceProviderRequestProxy.last.uuid

Timecop.travel(Devise.timeout_in + 1.minute) do
travel(Devise.timeout_in + 1.minute) do
# Simulate being idle on the sign in page long enough for the session to
# be deleted from Redis, but since Redis doesn't respect Timecop, we need
# to expire the session manually.
# be deleted from Redis, but since Redis doesn't respect ActiveSupport::Testing::TimeHelpers,
# we need to expire the session manually.
session_store.send(:destroy_session_from_sid, session_cookie.value)
# Simulate refreshing the page with JS to avoid a CSRF error
visit new_user_session_url(request_id: request_id)
Expand Down
8 changes: 4 additions & 4 deletions spec/features/remember_device/sp_expiration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

context "#{protocol}: signing in" do
it "does not require MFA before #{expiration_time.inspect}" do
Timecop.travel(expiration_time.from_now - 1.day) do
travel_to(expiration_time.from_now - 1.day) do
visit_idp_from_sp_with_ial1(protocol)
sign_in_user(user)

Expand All @@ -16,7 +16,7 @@
end

it "does require MFA after #{expiration_time.inspect}" do
Timecop.travel(expiration_time.from_now + 1.day) do
travel_to(expiration_time.from_now + 1.day) do
visit_idp_from_sp_with_ial1(protocol)
sign_in_user(user)

Expand All @@ -33,7 +33,7 @@

context "#{protocol}: visiting while already signed in" do
it "does not require MFA before #{expiration_time.inspect}" do
Timecop.travel(expiration_time.from_now - 1.day) do
travel_to(expiration_time.from_now - 1.day) do
sign_in_user(user)
visit_idp_from_sp_with_ial1(protocol)

Expand All @@ -42,7 +42,7 @@
end

it "does require MFA after #{expiration_time.inspect}" do
Timecop.travel(expiration_time.from_now + 1.day) do
travel_to(expiration_time.from_now + 1.day) do
if expiration_time == 30.days
sign_in_live_with_2fa(user)
visit_idp_from_sp_with_ial1(protocol)
Expand Down
4 changes: 2 additions & 2 deletions spec/features/remember_device/totp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ def remember_device_and_sign_out_user

context 'update totp' do
after do
Timecop.return
travel_back
end

def remember_device_and_sign_out_user
sign_in_and_2fa_user(user)
visit account_two_factor_authentication_path
page.find('.remove-auth-app').click # Delete
click_on t('account.index.totp_confirm_delete')
Timecop.travel 5.seconds.from_now # Travel past the revoked at date from disabling the device
travel_to(10.seconds.from_now) # Travel past the revoked at date from disabling the device
click_link "+ #{t('account.index.auth_app_add')}", href: authenticator_setup_url
fill_in :code, with: totp_secret_from_page
check :remember_device
Expand Down
8 changes: 4 additions & 4 deletions spec/features/reports/omb_fitara_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

feature 'OMB Fitara compliance officer runs report' do
it 'works in july' do
Timecop.travel Date.new(2019, 7, 2) do
travel_to(Date.new(2019, 7, 2)) do
visit sign_up_email_path
sign_up_and_2fa_ial1_user

Expand All @@ -12,7 +12,7 @@
end

it 'works in december' do
Timecop.travel Date.new(2019, 12, 2) do
travel_to(Date.new(2019, 12, 2)) do
visit sign_up_email_path
sign_up_and_2fa_ial1_user

Expand All @@ -22,7 +22,7 @@
end

it 'works in january' do
Timecop.travel Date.new(2019, 1, 2) do
travel_to(Date.new(2019, 1, 2)) do
visit sign_up_email_path
sign_up_and_2fa_ial1_user

Expand All @@ -37,7 +37,7 @@
it 'generates paths with date or latest prefix' do
expect(Identity::Hostdata).to receive(:env).and_return('ci')

Timecop.travel Date.new(2018, 1, 2) do
travel_to(Date.new(2018, 1, 2)) do
expect(Reports::OmbFitaraReport.new.send(:generate_s3_paths, report_name, 'json')).
to eq(
['ci/omb-fitara-report/latest.omb-fitara-report.json',
Expand Down
Loading