From 082962acf9f565c32bdd39d47cf41872189738fb Mon Sep 17 00:00:00 2001 From: Carson Reinke Date: Mon, 25 Apr 2016 13:46:58 -0400 Subject: [PATCH] Ignore query string for callback url since BigCommerce does not ignore it for redirect_uri Adding coverage folder to .gitignore --- .gitignore | 2 +- lib/omniauth/strategies/bigcommerce.rb | 5 +++++ spec/omniauth/strategies/bigcommerce_spec.rb | 11 +++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1e00991..d2efe35 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ .bundle Gemfile.lock coverage -reports +reports \ No newline at end of file diff --git a/lib/omniauth/strategies/bigcommerce.rb b/lib/omniauth/strategies/bigcommerce.rb index bb56cb1..b15d3ee 100644 --- a/lib/omniauth/strategies/bigcommerce.rb +++ b/lib/omniauth/strategies/bigcommerce.rb @@ -48,6 +48,11 @@ def authorize_params end end end + + #Exclude query string in callback + def callback_url + full_host + script_name + callback_path + end end end end diff --git a/spec/omniauth/strategies/bigcommerce_spec.rb b/spec/omniauth/strategies/bigcommerce_spec.rb index 7605915..8db0da0 100644 --- a/spec/omniauth/strategies/bigcommerce_spec.rb +++ b/spec/omniauth/strategies/bigcommerce_spec.rb @@ -45,6 +45,17 @@ it 'should have the correct path' do expect(subject.callback_path).to eq('/auth/bigcommerce/callback') end + + it 'should use no query string for callback url' do + request = double('Request', :params => {}, :cookies => {}, :env => {}) + allow(request).to receive(:scheme).and_return('http') + allow(request).to receive(:url).and_return('http://example.com') + + allow(subject).to receive(:request).and_return(request) + allow(subject).to receive(:script_name).and_return('') + + subject.callback_url + end end context 'authorize options' do