-
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.
Skip start page, redirect users to ID
Skips the start page by emulating the same request made by the start button in the appropriate controller action. Redirects users to the location returned by the OmniAuth request phase call to the identity service. Checks that this redirect location is a valid identity service URL. Renders the existing start page if Faraday encounters an error when making the call.
- Loading branch information
Showing
3 changed files
with
79 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
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
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 @@ | ||
require "rails_helper" | ||
|
||
RSpec.feature "Skipping the qualifications start page", type: :system do | ||
include CommonSteps | ||
|
||
scenario "when a user visits the start page path", test: :with_stubbed_auth do | ||
given_the_service_is_open | ||
and_omniauth_request_phase_provides_a_valid_redirect | ||
|
||
when_i_visit_the_qualifications_start_page | ||
then_i_am_redirected_to_the_identity_service | ||
end | ||
|
||
private | ||
|
||
def and_omniauth_request_phase_provides_a_valid_redirect | ||
allow_any_instance_of(Qualifications::StartsController) | ||
.to receive(:identity_api_domain).and_return("http://www.example.com") | ||
|
||
stub_request(:post, identity_service_auth_url) | ||
.to_return(status: 302, headers: { "location" => fake_identity_service_location }) | ||
end | ||
|
||
def when_i_visit_the_qualifications_start_page | ||
visit qualifications_start_path | ||
end | ||
|
||
def then_i_am_redirected_to_the_identity_service | ||
expect(page).to have_current_path(fake_identity_service_location) | ||
end | ||
|
||
def identity_service_auth_url | ||
%(#{ENV["HOSTING_DOMAIN"]}/qualifications/users/auth/identity?trn_token=) | ||
end | ||
|
||
def fake_identity_service_location | ||
"http://www.example.com/fake-identity-service" | ||
end | ||
end |