-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
set response_on_fragment for error_response in pre_authorization by r…
…esponse_type
- Loading branch information
1 parent
fabe4ea
commit c70acc9
Showing
2 changed files
with
58 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,51 @@ | ||
require 'rails_helper' | ||
|
||
describe Doorkeeper::OpenidConnect::OAuth::PreAuthorization do | ||
subject { Doorkeeper::OAuth::PreAuthorization.new server, { nonce: '123456' } } | ||
subject { Doorkeeper::OAuth::PreAuthorization.new server, attrs } | ||
let(:server) { double } | ||
let(:attrs) {} | ||
|
||
describe '#initialize' do | ||
it 'stores the nonce attribute' do | ||
expect(subject.nonce).to eq '123456' | ||
context 'with nonce parameter' do | ||
let(:attrs) { { nonce: '123456' } } | ||
|
||
it 'stores the nonce attribute' do | ||
expect(subject.nonce).to eq '123456' | ||
end | ||
end | ||
end | ||
|
||
describe '#error_response' do | ||
context 'with response_type = code' do | ||
let(:attrs) { { response_type: 'code', redirect_uri: 'client.com/callback' } } | ||
|
||
it 'should redirect to redirect_uri with query parameter' do | ||
expect(subject.error_response.redirect_uri).to match(/#{attrs[:redirect_uri]}\?/) | ||
end | ||
end | ||
|
||
context 'with response_type = token' do | ||
let(:attrs) { { response_type: 'token', redirect_uri: 'client.com/callback' } } | ||
|
||
it 'should redirect to redirect_uri with fragment' do | ||
expect(subject.error_response.redirect_uri).to match(/#{attrs[:redirect_uri]}#/) | ||
end | ||
end | ||
|
||
context 'with response_type = id_token' do | ||
let(:attrs) { { response_type: 'id_token', redirect_uri: 'client.com/callback' } } | ||
|
||
it 'should redirect to redirect_uri with fragment' do | ||
expect(subject.error_response.redirect_uri).to match(/#{attrs[:redirect_uri]}#/) | ||
end | ||
end | ||
|
||
context 'with response_type = id_token token' do | ||
let(:attrs) { { response_type: 'id_token token', redirect_uri: 'client.com/callback' } } | ||
|
||
it 'should redirect to redirect_uri with fragment' do | ||
expect(subject.error_response.redirect_uri).to match(/#{attrs[:redirect_uri]}#/) | ||
end | ||
end | ||
end | ||
end |