-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
35a44c9
commit 422b0c4
Showing
8 changed files
with
52 additions
and
52 deletions.
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
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 |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
let(:omniauth_hash) do | ||
OmniAuth::AuthHash.new( | ||
{ | ||
provider: 'onelogin', | ||
provider: 'one_login', | ||
uid: '123', | ||
info: { | ||
email: '[email protected]', | ||
|
@@ -22,12 +22,12 @@ | |
) | ||
end | ||
|
||
describe 'GET /auth/onelogin/callback' do | ||
describe 'GET /auth/one-login/callback' do | ||
it 'redirects to candidate_interface_interstitial_path' do | ||
candidate = create(:candidate) | ||
create(:one_login_auth, candidate:, token: '123') | ||
|
||
get auth_onelogin_callback_path | ||
get auth_one_login_callback_path | ||
|
||
expect(response).to redirect_to(candidate_interface_interstitial_path) | ||
end | ||
|
@@ -36,20 +36,20 @@ | |
let(:omniauth_hash) { nil } | ||
|
||
it 'returns unprocessable_entity' do | ||
get auth_onelogin_callback_path | ||
get auth_one_login_callback_path | ||
|
||
expect(response).to have_http_status(:unprocessable_entity) | ||
end | ||
end | ||
|
||
context 'when candidate has a different onelogin token than the one returned by onelogin' do | ||
it 'redirects to auth_onelogin_sign_out_path' do | ||
context 'when candidate has a different one login token than the one returned by one login' do | ||
it 'redirects to auth_one_login_sign_out_path' do | ||
candidate = create(:candidate, email_address: '[email protected]') | ||
create(:one_login_auth, candidate:, token: '456') | ||
|
||
get auth_onelogin_callback_path | ||
get auth_one_login_callback_path | ||
|
||
expect(response).to redirect_to(auth_onelogin_sign_out_path) | ||
expect(response).to redirect_to(auth_one_login_sign_out_path) | ||
expect(session[:one_login_error]).to eq( | ||
"Candidate #{candidate.id} has a different one login token than the " \ | ||
'user trying to login. Token used to auth 123', | ||
|
@@ -112,15 +112,15 @@ | |
end | ||
end | ||
|
||
describe 'GET /auth/onelogin/sign_out' do | ||
describe 'GET /auth/one-login/sign_out' do | ||
it 'redirects to one_login logout url' do | ||
create(:candidate, email_address: '[email protected]') | ||
|
||
get auth_onelogin_callback_path # set the session variables | ||
get auth_onelogin_sign_out_path | ||
get auth_one_login_callback_path # set the session variables | ||
get auth_one_login_sign_out_path | ||
|
||
params = { | ||
post_logout_redirect_uri: URI(auth_onelogin_sign_out_complete_url), | ||
post_logout_redirect_uri: URI(auth_one_login_sign_out_complete_url), | ||
id_token_hint: 'id_token', | ||
} | ||
one_login_logout_url = URI.parse("#{ENV['GOVUK_ONE_LOGIN_ISSUER_URL']}logout").tap do |uri| | ||
|
@@ -130,22 +130,22 @@ | |
expect(response).to redirect_to(one_login_logout_url) | ||
end | ||
|
||
context 'when candidate has a different onelogin token than the one returned by onelogin' do | ||
context 'when candidate has a different one login token than the one returned by one login' do | ||
it 'redirects to one_login logout url and persists the session error message' do | ||
candidate = create(:candidate, email_address: '[email protected]') | ||
create(:one_login_auth, candidate:, token: '456') | ||
|
||
get auth_onelogin_callback_path # set the session variables | ||
get auth_onelogin_sign_out_path | ||
get auth_one_login_callback_path # set the session variables | ||
get auth_one_login_sign_out_path | ||
|
||
expect(session[:onelogin_id_token]).to be_nil | ||
expect(session[:one_login_id_token]).to be_nil | ||
expect(session[:one_login_error]).to eq( | ||
"Candidate #{candidate.id} has a different one login token than the " \ | ||
'user trying to login. Token used to auth 123', | ||
) | ||
|
||
params = { | ||
post_logout_redirect_uri: URI(auth_onelogin_sign_out_complete_url), | ||
post_logout_redirect_uri: URI(auth_one_login_sign_out_complete_url), | ||
id_token_hint: 'id_token', | ||
} | ||
one_login_url = URI.parse("#{ENV['GOVUK_ONE_LOGIN_ISSUER_URL']}logout").tap do |uri| | ||
|
@@ -160,21 +160,21 @@ | |
it 'redirects to sign_in page' do | ||
allow(OneLogin).to receive(:bypass?).and_return(true) | ||
|
||
get auth_onelogin_sign_out_path | ||
get auth_one_login_sign_out_path | ||
expect(response).to redirect_to candidate_interface_create_account_or_sign_in_path | ||
end | ||
end | ||
end | ||
|
||
describe 'GET /auth/onelogin/sign_out_complete' do | ||
context 'when candidate has a different onelogin token than the one returned by onelogin' do | ||
it 'redirects to logout_onelogin_path and persists the session error message' do | ||
describe 'GET /auth/one-login/sign_out_complete' do | ||
context 'when candidate has a different one login token than the one returned by one login' do | ||
it 'redirects to logout_one_login_path and persists the session error message' do | ||
candidate = create(:candidate, email_address: '[email protected]') | ||
create(:one_login_auth, candidate:, token: '456') | ||
allow(Sentry).to receive(:capture_message) | ||
|
||
get auth_onelogin_callback_path # set the session variables | ||
get auth_onelogin_sign_out_complete_path | ||
get auth_one_login_callback_path # set the session variables | ||
get auth_one_login_sign_out_complete_path | ||
|
||
expect(Sentry).to have_received(:capture_message).with( | ||
"Candidate #{candidate.id} has a different one login token than the " \ | ||
|
@@ -186,8 +186,8 @@ | |
end | ||
|
||
context 'candidate has no errors' do | ||
it 'redirects to logout_onelogin_path and persists the session error message' do | ||
get auth_onelogin_sign_out_complete_path | ||
it 'redirects to logout_one_login_path and persists the session error message' do | ||
get auth_one_login_sign_out_complete_path | ||
|
||
expect(response).to redirect_to( | ||
candidate_interface_create_account_or_sign_in_path, | ||
|
@@ -196,15 +196,15 @@ | |
end | ||
end | ||
|
||
describe 'GET /auth/onelogin/failure' do | ||
describe 'GET /auth/one-login/failure' do | ||
it 'redirects to auth_failure_path with one login error' do | ||
get auth_onelogin_callback_path # set the session variables | ||
get auth_one_login_callback_path # set the session variables | ||
get auth_failure_path(params: { message: 'error_message' }) | ||
|
||
expect(session[:one_login_error]).to eq( | ||
'One login failure with error_message for onelogin_id_token: id_token', | ||
'One login failure with error_message for one_login_id_token: id_token', | ||
) | ||
expect(response).to redirect_to(auth_onelogin_sign_out_path) | ||
expect(response).to redirect_to(auth_one_login_sign_out_path) | ||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module OneLoginHelper | ||
def user_exists_in_onelogin(email_address: '[email protected]', uid: 'UID') | ||
def user_exists_in_one_login(email_address: '[email protected]', uid: 'UID') | ||
OmniAuth.config.mock_auth[:onelogin] = OmniAuth::AuthHash.new( | ||
{ | ||
provider: 'onelogin', | ||
|
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