From b71d4480f64e308039441c3fc49c3df81bc35b2c Mon Sep 17 00:00:00 2001 From: nikz Date: Sat, 5 May 2018 21:42:21 +0100 Subject: [PATCH] Adds a spec to verify extra header params on Client Credentials This is a regression spec, based on the issue in #257 which looks like it was fixed during a refactoring. --- spec/oauth2/strategy/client_credentials_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/oauth2/strategy/client_credentials_spec.rb b/spec/oauth2/strategy/client_credentials_spec.rb index c2bc508c..df77a39b 100644 --- a/spec/oauth2/strategy/client_credentials_spec.rb +++ b/spec/oauth2/strategy/client_credentials_spec.rb @@ -10,6 +10,7 @@ stub.post('/oauth/token', 'grant_type' => 'client_credentials') do |env| client_id, client_secret = Base64.decode64(env[:request_headers]['Authorization'].split(' ', 2)[1]).split(':', 2) client_id == 'abc' && client_secret == 'def' || raise(Faraday::Adapter::Test::Stubs::NotFound) + @last_headers = env[:request_headers] case @mode when 'formencoded' [200, {'Content-Type' => 'application/x-www-form-urlencoded'}, kvform_token] @@ -66,4 +67,15 @@ end end end + + describe '#get_token (with extra header parameters)' do + before do + @mode = 'json' + @access = subject.get_token(:headers => {'X-Extra-Header' => 'wow'}) + end + + it 'sends the header correctly.' do + expect(@last_headers['X-Extra-Header']).to eq('wow') + end + end end