@@ -22,13 +22,20 @@ def app; lambda{|env| [200, {}, ["Hello."]]} end
2222 subject { fresh_strategy }
2323
2424 it 'should include any authorize params passed in the :authorize_params option' do
25- instance = subject . new ( 'abc' , 'def' , :authorize_params => { :foo => 'bar' , :baz => 'zip' } )
26- instance . authorize_params . should == { 'foo' => 'bar' , 'baz' => 'zip' }
25+ instance = subject . new ( 'abc' , 'def' , :authorize_params => { :foo => 'bar' , :baz => 'zip' , :state => '123' } )
26+ instance . authorize_params . should == { 'foo' => 'bar' , 'baz' => 'zip' , 'state' => '123' }
2727 end
2828
2929 it 'should include top-level options that are marked as :authorize_options' do
30- instance = subject . new ( 'abc' , 'def' , :authorize_options => [ :scope , :foo ] , :scope => 'bar' , :foo => 'baz' )
31- instance . authorize_params . should == { 'scope' => 'bar' , 'foo' => 'baz' }
30+ instance = subject . new ( 'abc' , 'def' , :authorize_options => [ :scope , :foo ] , :scope => 'bar' , :foo => 'baz' , :authorize_params => { :state => '123' } )
31+ instance . authorize_params . should == { 'scope' => 'bar' , 'foo' => 'baz' , 'state' => '123' }
32+ end
33+
34+ it 'should include random state in the authorize params' do
35+ instance = subject . new ( 'abc' , 'def' )
36+ instance . authorize_params . keys . should == [ 'state' ]
37+ instance . session [ 'omniauth.state' ] . should_not be_empty
38+ instance . session [ 'omniauth.state' ] . should == instance . authorize_params [ 'state' ]
3239 end
3340 end
3441
0 commit comments