-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle oauth error scenarios for staff
- Loading branch information
Showing
2 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
spec/system/support/staff_user_has_oauth_error_signing_in_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe "DSI authentication", type: :system do | ||
include AuthorizationSteps | ||
include AuthenticationSteps | ||
|
||
before do | ||
when_i_am_authorized_with_basic_auth | ||
allow(Sentry).to receive(:capture_exception) | ||
end | ||
|
||
scenario "Staff user has oauth error when signing in", test: :with_stubbed_auth do | ||
given_dsi_auth_is_mocked_with_a_failure("invalid_credentials") do | ||
when_i_visit_the_sign_in_page | ||
and_click_the_dsi_sign_in_button | ||
then_i_see_a_sign_in_error | ||
end | ||
end | ||
|
||
scenario "Staff user has sessionexpiry oauth error", test: :with_stubbed_auth do | ||
given_dsi_auth_is_mocked_with_a_failure("sessionexpired") do | ||
when_i_visit_the_sign_in_page | ||
and_click_the_dsi_sign_in_button | ||
then_i_am_redirected_to_sign_in | ||
end | ||
end | ||
|
||
private | ||
|
||
def then_i_see_a_sign_in_error | ||
expect(page).to have_content "There was a problem signing you in. Please try again." | ||
end | ||
|
||
def then_i_am_redirected_to_sign_in | ||
expect(page).to have_current_path(support_interface_sign_in_path) | ||
end | ||
end |