forked from longlostnick/omniauth-dropbox-oauth2
-
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.
- Loading branch information
Showing
5 changed files
with
116 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in omniauth-service-now.gemspec | ||
gemspec | ||
|
||
group :development, :test do | ||
gem 'guard' | ||
gem 'guard-rspec' | ||
gem 'guard-bundler' | ||
gem 'rb-fsevent' | ||
gem 'growl' | ||
gem 'rake' | ||
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env rake | ||
require "bundler/gem_tasks" | ||
require 'rspec/core/rake_task' | ||
|
||
RSpec::Core::RakeTask.new | ||
|
||
desc 'Run specs' | ||
task :default => :spec |
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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
require 'spec_helper' | ||
|
||
describe OmniAuth::Strategies::DropboxOauth2 do | ||
let(:access_token) { instance_double('AccessToken', :options => {}, :[] => 'user') } | ||
let(:parsed_response) { instance_double('ParsedResponse') } | ||
let(:response) { instance_double('Response', :parsed => parsed_response) } | ||
|
||
let(:enterprise_site) { 'https://some.other.site.com' } | ||
let(:enterprise_authorize_url) { 'https://some.other.site.com/login/oauth/authorize' } | ||
let(:enterprise_token_url) { 'https://some.other.site.com/login/oauth/token' } | ||
let(:enterprise) do | ||
OmniAuth::Strategies::DropboxOauth2.new('DROPBOX_CLIENT_ID', 'DROPBOX_CLIENT_SECRET', | ||
{ | ||
:client_options => { | ||
:site => enterprise_site, | ||
:authorize_url => enterprise_authorize_url, | ||
:token_url => enterprise_token_url | ||
} | ||
} | ||
) | ||
end | ||
|
||
subject do | ||
OmniAuth::Strategies::DropboxOauth2.new({}) | ||
end | ||
|
||
before(:each) do | ||
allow(subject).to receive(:access_token).and_return(access_token) | ||
end | ||
|
||
context 'client options' do | ||
it 'should have correct site' do | ||
expect(subject.options.client_options.site).to eq('https://api.dropbox.com') | ||
end | ||
|
||
it 'should have correct authorize url' do | ||
expect(subject.options.client_options.authorize_url).to eq('https://api.dropbox.com/oauth2/authorize') | ||
end | ||
|
||
it 'should have correct token url' do | ||
expect(subject.options.client_options.token_url).to eq('https://api.dropbox.com/oauth2/token') | ||
end | ||
|
||
describe 'should be overrideable' do | ||
it 'for site' do | ||
expect(enterprise.options.client_options.site).to eq(enterprise_site) | ||
end | ||
|
||
it 'for authorize url' do | ||
expect(enterprise.options.client_options.authorize_url).to eq(enterprise_authorize_url) | ||
end | ||
|
||
it 'for token url' do | ||
expect(enterprise.options.client_options.token_url).to eq(enterprise_token_url) | ||
end | ||
end | ||
end | ||
|
||
describe '#callback_url' do | ||
let(:base_url) { 'https://example.com' } | ||
|
||
context 'no script name present' do | ||
it 'has the correct default callback path' do | ||
allow(subject).to receive(:full_host) { base_url } | ||
allow(subject).to receive(:script_name) { '' } | ||
allow(subject).to receive(:query_string) { '' } | ||
expect(subject.callback_url).to eq(base_url + '/auth/dropbox_oauth2/callback') | ||
end | ||
end | ||
|
||
context 'script name' do | ||
it 'should set the callback path with script_name' do | ||
allow(subject).to receive(:full_host) { base_url } | ||
allow(subject).to receive(:script_name) { '/v1' } | ||
allow(subject).to receive(:query_string) { '' } | ||
expect(subject.callback_url).to eq(base_url + '/v1/auth/dropbox_oauth2/callback') | ||
end | ||
end | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
$:.unshift File.expand_path('..', __FILE__) | ||
$:.unshift File.expand_path('../../lib', __FILE__) | ||
require 'simplecov' | ||
SimpleCov.start | ||
require 'rspec' | ||
require 'rack/test' | ||
require 'webmock/rspec' | ||
require 'omniauth' | ||
require 'omniauth-dropbox-oauth2' | ||
|
||
RSpec.configure do |config| | ||
config.include WebMock::API | ||
config.include Rack::Test::Methods | ||
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy | ||
end | ||
|