-
Notifications
You must be signed in to change notification settings - Fork 28
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
7 changed files
with
105 additions
and
189 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,10 +1,7 @@ | ||
require 'bundler/gem_tasks' | ||
require 'rake/testtask' | ||
require 'rspec/core/rake_task' | ||
|
||
Rake::TestTask.new do |task| | ||
task.libs << 'lib' | ||
task.libs << 'test' | ||
task.test_files = FileList['test/*_test.rb'] | ||
end | ||
RSpec::Core::RakeTask.new | ||
|
||
task :default => :test | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,27 @@ | ||
# coding: utf-8 | ||
$:.push File.expand_path('../lib', __FILE__) | ||
$LOAD_PATH.push File.expand_path('lib', __dir__) | ||
require 'omniauth/discord/version' | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "omniauth-discord" | ||
spec.name = 'omniauth-discord' | ||
spec.version = Omniauth::Discord::VERSION | ||
spec.authors = ["Adão Raul"] | ||
spec.email = ["adao.raul@gmail.com"] | ||
spec.authors = ['Adão Raul'] | ||
spec.email = ['adao.raul@gmail.com'] | ||
|
||
spec.summary = "Discord OAuth2 Strategy for OmniAuth" | ||
spec.summary = 'Discord OAuth2 Strategy for OmniAuth' | ||
spec.description = spec.summary | ||
spec.homepage = "http://github.com/adaoraul/omniauth-discord" | ||
spec.license = "MIT" | ||
spec.homepage = 'http://github.com/adaoraul/omniauth-discord' | ||
spec.license = 'MIT' | ||
|
||
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } | ||
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) } | ||
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } | ||
spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) | ||
spec.require_paths = ["lib"] | ||
spec.require_paths = ['lib'] | ||
|
||
spec.add_runtime_dependency 'omniauth-oauth2', '~> 1.4' | ||
spec.add_runtime_dependency 'omniauth' | ||
spec.add_runtime_dependency 'omniauth-oauth2' | ||
|
||
spec.add_development_dependency "dotenv" | ||
spec.add_development_dependency "bundler" | ||
spec.add_development_dependency "rake" | ||
spec.add_development_dependency "minitest-utils" | ||
spec.add_development_dependency "mocha" | ||
spec.add_development_dependency 'rack-test' | ||
spec.add_development_dependency 'rspec' | ||
spec.add_development_dependency 'simplecov' | ||
spec.add_development_dependency 'webmock' | ||
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,71 @@ | ||
require 'spec_helper' | ||
|
||
describe OmniAuth::Strategies::Discord do | ||
let(:access_token) { instance_double('AccessToken', options: {}) } | ||
let(:parsed_response) { instance_double('ParsedResponse') } | ||
let(:response) { instance_double('Response', parsed: parsed_response) } | ||
|
||
let(:enterprise_site) { 'https://some.other.site.com/api/v3' } | ||
let(:enterprise_authorize_url) { 'https://some.other.site.com/login/oauth/authorize' } | ||
let(:enterprise_token_url) { 'https://some.other.site.com/login/oauth/access_token' } | ||
let(:enterprise) do | ||
OmniAuth::Strategies::Discord.new('GITHUB_KEY', 'GITHUB_SECRET', | ||
client_options: { | ||
site: enterprise_site, | ||
authorize_url: enterprise_authorize_url, | ||
token_url: enterprise_token_url | ||
}) | ||
end | ||
|
||
subject do | ||
OmniAuth::Strategies::Discord.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://discordapp.com/api') | ||
end | ||
|
||
it 'should have correct authorize url' do | ||
expect(subject.options.client_options.authorize_url).to eq('oauth2/authorize') | ||
end | ||
|
||
it 'should have correct token url' do | ||
expect(subject.options.client_options.token_url).to eq('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 | ||
|
||
context '#raw_info' do | ||
it 'should use relative paths' do | ||
expect(access_token).to receive(:get).with('users/@me').and_return(response) | ||
expect(subject.raw_info).to eq(parsed_response) | ||
end | ||
end | ||
|
||
describe '#callback_url' do | ||
it 'is a combination of host, script name, and callback path' do | ||
allow(subject).to receive(:full_host).and_return('https://example.com') | ||
allow(subject).to receive(:script_name).and_return('/sub_uri') | ||
|
||
expect(subject.callback_url).to eq('https://example.com/sub_uri/auth/discord/callback') | ||
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,15 @@ | ||
$LOAD_PATH.unshift File.expand_path(__dir__) | ||
$LOAD_PATH.unshift File.expand_path('../lib', __dir__) | ||
require 'simplecov' | ||
SimpleCov.start | ||
require 'rspec' | ||
require 'rack/test' | ||
require 'webmock/rspec' | ||
require 'omniauth' | ||
require 'omniauth-discord' | ||
|
||
RSpec.configure do |config| | ||
config.include WebMock::API | ||
config.include Rack::Test::Methods | ||
config.extend OmniAuth::Test::StrategyMacros, type: :strategy | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.