This repository has been archived by the owner on Jun 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from G5/rc-v1-0-3
RC v1.0.3
- Loading branch information
Showing
5 changed files
with
91 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module DeviseG5Authenticatable | ||
VERSION = '1.0.0' | ||
VERSION = '1.0.3' | ||
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 |
---|---|---|
|
@@ -41,7 +41,13 @@ | |
uid: '45', | ||
info: { name: 'Foo Bar', | ||
email: '[email protected]' }, | ||
credentials: { token: 'abc123' } | ||
credentials: { token: 'abc123' }, | ||
extra: { | ||
raw_info: { | ||
accessible_applications: [{ url: 'global' }], | ||
restricted_application_redirect_url: 'https://imc.com' | ||
} | ||
} | ||
) | ||
end | ||
before { request.env['omniauth.auth'] = auth_hash } | ||
|
@@ -148,6 +154,53 @@ | |
end | ||
end | ||
end | ||
|
||
context 'when user does not have access to application' do | ||
let(:auth_hash) do | ||
OmniAuth::AuthHash.new( | ||
provider: 'g5', | ||
uid: '45', | ||
info: { name: 'Foo Bar', | ||
email: '[email protected]' }, | ||
credentials: { token: 'abc123' }, | ||
extra: { | ||
raw_info: { | ||
accessible_applications: [], | ||
restricted_application_redirect_url: 'https://imc.com' | ||
} | ||
} | ||
) | ||
end | ||
|
||
let(:model) do | ||
stub_model(model_class, | ||
provider: auth_hash.provider, | ||
uid: auth_hash.uid, | ||
email: auth_hash.email, | ||
g5_access_token: auth_hash.credentials.token, | ||
save!: true, | ||
update_g5_credentials: true, | ||
email_changed?: false) | ||
end | ||
|
||
before do | ||
allow(model_class).to receive(:find_and_update_for_g5_oauth) | ||
.and_return(model) | ||
end | ||
|
||
let(:model_class) { User } | ||
let(:scope) { :user } | ||
|
||
it 'should redirect the user to the restricted_application_redirect_url' do | ||
create_session | ||
params = { restricted: subject.request.base_url } | ||
expect(subject).to redirect_to(auth_hash.extra.raw_info.restricted_application_redirect_url + '?' + params.to_query) | ||
end | ||
|
||
it 'should not sign in a user' do | ||
expect { create_session }.to_not change { controller.current_user } | ||
end | ||
end | ||
end | ||
|
||
describe '#destroy' do | ||
|
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