omniauth-ynab 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/.rubocop.yml +48 -0
- data/.travis.yml +24 -0
- data/Gemfile +19 -0
- data/LICENSE.md +19 -0
- data/README.md +67 -0
- data/Rakefile +18 -0
- data/lib/omniauth/strategies/ynab.rb +127 -0
- data/lib/omniauth-ynab/version.rb +5 -0
- data/lib/omniauth-ynab.rb +2 -0
- data/omniauth-ynab.gemspec +24 -0
- data/spec/helper.rb +28 -0
- data/spec/omniauth/strategies/ynab_spec.rb +107 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 783b099188295e40f0cbb1ac052fd9d37a14e719
|
4
|
+
data.tar.gz: c275d6197366152f2f7ce05da8581017e45bd476
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2d5106f0bee36cf97f86907ac9907a66ac51c487d658d3b37c7068c3a84ce90cba6d45dd99bad323a4cdc1dd2cbf669c5647bb9c35c9c440b140b2327033d342
|
7
|
+
data.tar.gz: 0f14e663e8c8a4d2aee498f67d139e64386963f04813dc8b4c6021bacd49dad7837f2a446c0d63732e8197fefaa9c56ed5b083ae4291828a6556e71a82094c77
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
Layout/AccessModifierIndentation:
|
2
|
+
EnforcedStyle: outdent
|
3
|
+
|
4
|
+
Layout/SpaceInsideHashLiteralBraces:
|
5
|
+
EnforcedStyle: no_space
|
6
|
+
|
7
|
+
Metrics/BlockNesting:
|
8
|
+
Max: 2
|
9
|
+
|
10
|
+
Metrics/LineLength:
|
11
|
+
AllowURI: true
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
Metrics/MethodLength:
|
15
|
+
CountComments: false
|
16
|
+
Max: 10
|
17
|
+
|
18
|
+
Metrics/ParameterLists:
|
19
|
+
Max: 4
|
20
|
+
CountKeywordArgs: true
|
21
|
+
|
22
|
+
Style/CollectionMethods:
|
23
|
+
PreferredMethods:
|
24
|
+
map: 'collect'
|
25
|
+
reduce: 'inject'
|
26
|
+
find: 'detect'
|
27
|
+
find_all: 'select'
|
28
|
+
|
29
|
+
Style/Documentation:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
Style/DoubleNegation:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
Style/HashSyntax:
|
36
|
+
EnforcedStyle: hash_rockets
|
37
|
+
|
38
|
+
Style/StderrPuts:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
Style/StringLiterals:
|
42
|
+
EnforcedStyle: double_quotes
|
43
|
+
|
44
|
+
Style/TrailingCommaInArguments:
|
45
|
+
EnforcedStyleForMultiline: comma
|
46
|
+
|
47
|
+
Style/TrailingCommaInLiteral:
|
48
|
+
EnforcedStyleForMultiline: comma
|
data/.travis.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
bundler_args: --without development
|
2
|
+
before_install:
|
3
|
+
- gem update --system
|
4
|
+
- gem update bundler
|
5
|
+
cache: bundler
|
6
|
+
env:
|
7
|
+
global:
|
8
|
+
- JRUBY_OPTS="$JRUBY_OPTS --debug"
|
9
|
+
language: ruby
|
10
|
+
rvm:
|
11
|
+
- jruby-9000
|
12
|
+
- 2.1.10 # EOL Soon
|
13
|
+
- 2.2.9
|
14
|
+
- 2.3.6
|
15
|
+
- 2.4.3
|
16
|
+
- 2.5.0
|
17
|
+
- jruby-head
|
18
|
+
- ruby-head
|
19
|
+
matrix:
|
20
|
+
allow_failures:
|
21
|
+
- rvm: jruby-head
|
22
|
+
- rvm: ruby-head
|
23
|
+
fast_finish: true
|
24
|
+
sudo: false
|
data/Gemfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem "rake", "~> 12.0"
|
4
|
+
|
5
|
+
group :test do
|
6
|
+
gem "addressable", "~> 2.3.8", :platforms => %i[jruby ruby_18]
|
7
|
+
gem "coveralls"
|
8
|
+
gem "json", :platforms => %i[jruby ruby_18 ruby_19]
|
9
|
+
gem "mime-types", "~> 1.25", :platforms => %i[jruby ruby_18]
|
10
|
+
gem "rack-test"
|
11
|
+
gem "rest-client", "~> 1.7.3", :platforms => %i[jruby ruby_18]
|
12
|
+
gem "rspec", "~> 3.2"
|
13
|
+
gem "rubocop", ">= 0.51", :platforms => %i[ruby_19 ruby_20 ruby_21 ruby_22 ruby_23 ruby_24]
|
14
|
+
gem "simplecov", ">= 0.9"
|
15
|
+
gem "webmock", "~> 3.0"
|
16
|
+
end
|
17
|
+
|
18
|
+
# Specify your gem's dependencies in omniauth-oauth2.gemspec
|
19
|
+
gemspec
|
data/LICENSE.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (C) 2014 Michael Bleigh, Erik Michaels-Ober and Intridea, Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# OmniAuth OAuth2
|
2
|
+
|
3
|
+
[][gem]
|
4
|
+
[][travis]
|
5
|
+
[][gemnasium]
|
6
|
+
[][codeclimate]
|
7
|
+
[][coveralls]
|
8
|
+
[](https://hakiri.io/github/omniauth/omniauth-oauth2/master)
|
9
|
+
|
10
|
+
[gem]: https://rubygems.org/gems/omniauth-oauth2
|
11
|
+
[travis]: http://travis-ci.org/omniauth/omniauth-oauth2
|
12
|
+
[gemnasium]: https://gemnasium.com/github.com/omniauth/omniauth-oauth2
|
13
|
+
[codeclimate]: https://codeclimate.com/github/omniauth/omniauth-oauth2
|
14
|
+
[coveralls]: https://coveralls.io/r/omniauth/omniauth-oauth2
|
15
|
+
|
16
|
+
This gem contains a generic OAuth2 strategy for OmniAuth. It is meant to serve
|
17
|
+
as a building block strategy for other strategies and not to be used
|
18
|
+
independently (since it has no inherent way to gather uid and user info).
|
19
|
+
|
20
|
+
## Creating an OAuth2 Strategy
|
21
|
+
|
22
|
+
To create an OmniAuth OAuth2 strategy using this gem, you can simply subclass
|
23
|
+
it and add a few extra methods like so:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require 'omniauth-oauth2'
|
27
|
+
|
28
|
+
module OmniAuth
|
29
|
+
module Strategies
|
30
|
+
class SomeSite < OmniAuth::Strategies::OAuth2
|
31
|
+
# Give your strategy a name.
|
32
|
+
option :name, "some_site"
|
33
|
+
|
34
|
+
# This is where you pass the options you would pass when
|
35
|
+
# initializing your consumer from the OAuth gem.
|
36
|
+
option :client_options, {:site => "https://api.somesite.com"}
|
37
|
+
|
38
|
+
# These are called after authentication has succeeded. If
|
39
|
+
# possible, you should try to set the UID without making
|
40
|
+
# additional calls (if the user id is returned with the token
|
41
|
+
# or as a URI parameter). This may not be possible with all
|
42
|
+
# providers.
|
43
|
+
uid{ raw_info['id'] }
|
44
|
+
|
45
|
+
info do
|
46
|
+
{
|
47
|
+
:name => raw_info['name'],
|
48
|
+
:email => raw_info['email']
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
extra do
|
53
|
+
{
|
54
|
+
'raw_info' => raw_info
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
def raw_info
|
59
|
+
@raw_info ||= access_token.get('/me').parsed
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
```
|
65
|
+
|
66
|
+
That's pretty much it!
|
67
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
require "rspec/core/rake_task"
|
4
|
+
|
5
|
+
RSpec::Core::RakeTask.new
|
6
|
+
|
7
|
+
task :test => :spec
|
8
|
+
|
9
|
+
begin
|
10
|
+
require "rubocop/rake_task"
|
11
|
+
RuboCop::RakeTask.new
|
12
|
+
rescue LoadError
|
13
|
+
task :rubocop do
|
14
|
+
$stderr.puts "RuboCop is disabled"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
task :default => %i[spec rubocop]
|
@@ -0,0 +1,127 @@
|
|
1
|
+
require "oauth2"
|
2
|
+
require "omniauth"
|
3
|
+
require "securerandom"
|
4
|
+
require "socket" # for SocketError
|
5
|
+
require "timeout" # for Timeout::Error
|
6
|
+
|
7
|
+
module OmniAuth
|
8
|
+
module Strategies
|
9
|
+
# Authentication strategy for connecting with APIs constructed using
|
10
|
+
# the [OAuth 2.0 Specification](http://tools.ietf.org/html/draft-ietf-oauth-v2-10).
|
11
|
+
# You must generally register your application with the provider and
|
12
|
+
# utilize an application id and secret in order to authenticate using
|
13
|
+
# OAuth 2.0.
|
14
|
+
class Ynab
|
15
|
+
include OmniAuth::Strategy
|
16
|
+
|
17
|
+
def self.inherited(subclass)
|
18
|
+
OmniAuth::Strategy.included(subclass)
|
19
|
+
end
|
20
|
+
|
21
|
+
args %i[client_id client_secret]
|
22
|
+
|
23
|
+
option :client_id, nil
|
24
|
+
option :client_secret, nil
|
25
|
+
option :client_options, {}
|
26
|
+
option :authorize_params, {}
|
27
|
+
option :authorize_options, [:scope]
|
28
|
+
option :token_params, {}
|
29
|
+
option :token_options, []
|
30
|
+
option :auth_token_params, {}
|
31
|
+
option :provider_ignores_state, false
|
32
|
+
|
33
|
+
attr_accessor :access_token
|
34
|
+
|
35
|
+
def client
|
36
|
+
::OAuth2::Client.new(options.client_id, options.client_secret, deep_symbolize(options.client_options))
|
37
|
+
end
|
38
|
+
|
39
|
+
credentials do
|
40
|
+
hash = {"token" => access_token.token}
|
41
|
+
hash["refresh_token"] = access_token.refresh_token if access_token.expires? && access_token.refresh_token
|
42
|
+
hash["expires_at"] = access_token.expires_at if access_token.expires?
|
43
|
+
hash["expires"] = access_token.expires?
|
44
|
+
hash
|
45
|
+
end
|
46
|
+
|
47
|
+
def request_phase
|
48
|
+
redirect client.auth_code.authorize_url({:redirect_uri => callback_url}.merge(authorize_params))
|
49
|
+
end
|
50
|
+
|
51
|
+
def authorize_params
|
52
|
+
options.authorize_params[:state] = SecureRandom.hex(24)
|
53
|
+
params = options.authorize_params.merge(options_for("authorize"))
|
54
|
+
if OmniAuth.config.test_mode
|
55
|
+
@env ||= {}
|
56
|
+
@env["rack.session"] ||= {}
|
57
|
+
end
|
58
|
+
session["omniauth.state"] = params[:state]
|
59
|
+
params
|
60
|
+
end
|
61
|
+
|
62
|
+
def token_params
|
63
|
+
options.token_params.merge(options_for("token"))
|
64
|
+
end
|
65
|
+
|
66
|
+
def callback_phase # rubocop:disable AbcSize, CyclomaticComplexity, MethodLength, PerceivedComplexity
|
67
|
+
error = request.params["error_reason"] || request.params["error"]
|
68
|
+
if error
|
69
|
+
fail!(error, CallbackError.new(request.params["error"], request.params["error_description"] || request.params["error_reason"], request.params["error_uri"]))
|
70
|
+
elsif !options.provider_ignores_state && (request.params["state"].to_s.empty? || request.params["state"] != session.delete("omniauth.state"))
|
71
|
+
fail!(:csrf_detected, CallbackError.new(:csrf_detected, "CSRF detected"))
|
72
|
+
else
|
73
|
+
self.access_token = build_access_token
|
74
|
+
self.access_token = access_token.refresh! if access_token.expired?
|
75
|
+
super
|
76
|
+
end
|
77
|
+
rescue ::OAuth2::Error, CallbackError => e
|
78
|
+
fail!(:invalid_credentials, e)
|
79
|
+
rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e
|
80
|
+
fail!(:timeout, e)
|
81
|
+
rescue ::SocketError => e
|
82
|
+
fail!(:failed_to_connect, e)
|
83
|
+
end
|
84
|
+
|
85
|
+
protected
|
86
|
+
|
87
|
+
def build_access_token
|
88
|
+
verifier = request.params["code"]
|
89
|
+
client.auth_code.get_token(verifier, {:redirect_uri => callback_url}.merge(token_params.to_hash(:symbolize_keys => true)), deep_symbolize(options.auth_token_params))
|
90
|
+
end
|
91
|
+
|
92
|
+
def deep_symbolize(options)
|
93
|
+
hash = {}
|
94
|
+
options.each do |key, value|
|
95
|
+
hash[key.to_sym] = value.is_a?(Hash) ? deep_symbolize(value) : value
|
96
|
+
end
|
97
|
+
hash
|
98
|
+
end
|
99
|
+
|
100
|
+
def options_for(option)
|
101
|
+
hash = {}
|
102
|
+
options.send(:"#{option}_options").select { |key| options[key] }.each do |key|
|
103
|
+
hash[key.to_sym] = options[key]
|
104
|
+
end
|
105
|
+
hash
|
106
|
+
end
|
107
|
+
|
108
|
+
# An error that is indicated in the OAuth 2.0 callback.
|
109
|
+
# This could be a `redirect_uri_mismatch` or other
|
110
|
+
class CallbackError < StandardError
|
111
|
+
attr_accessor :error, :error_reason, :error_uri
|
112
|
+
|
113
|
+
def initialize(error, error_reason = nil, error_uri = nil)
|
114
|
+
self.error = error
|
115
|
+
self.error_reason = error_reason
|
116
|
+
self.error_uri = error_uri
|
117
|
+
end
|
118
|
+
|
119
|
+
def message
|
120
|
+
[error, error_reason, error_uri].compact.join(" | ")
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
OmniAuth.config.add_camelization "ynab", "Ynab"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "omniauth-ynab/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.add_dependency "oauth2", "~> 1.1"
|
7
|
+
gem.add_dependency "omniauth", "~> 1.2"
|
8
|
+
|
9
|
+
gem.add_development_dependency "bundler", "~> 1.0"
|
10
|
+
|
11
|
+
gem.authors = ["Mike Berkman"]
|
12
|
+
gem.email = ["mike@berkman.co"]
|
13
|
+
gem.description = "A YNAB OAuth2 strategy for OmniAuth."
|
14
|
+
gem.summary = gem.description
|
15
|
+
gem.homepage = "https://github.com/berkman/omniauth-ynab"
|
16
|
+
gem.licenses = %w[MIT]
|
17
|
+
|
18
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").collect { |f| File.basename(f) }
|
19
|
+
gem.files = `git ls-files`.split("\n")
|
20
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
gem.name = "omniauth-ynab"
|
22
|
+
gem.require_paths = %w[lib]
|
23
|
+
gem.version = OmniAuth::Ynab::VERSION
|
24
|
+
end
|
data/spec/helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path("..", __FILE__)
|
2
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
3
|
+
|
4
|
+
if RUBY_VERSION >= "1.9"
|
5
|
+
require "simplecov"
|
6
|
+
require "coveralls"
|
7
|
+
|
8
|
+
SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter]
|
9
|
+
|
10
|
+
SimpleCov.start do
|
11
|
+
minimum_coverage(78.48)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
require "rspec"
|
16
|
+
require "rack/test"
|
17
|
+
require "webmock/rspec"
|
18
|
+
require "omniauth"
|
19
|
+
require "omniauth-oauth2"
|
20
|
+
|
21
|
+
RSpec.configure do |config|
|
22
|
+
config.expect_with :rspec do |c|
|
23
|
+
c.syntax = :expect
|
24
|
+
end
|
25
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
26
|
+
config.include Rack::Test::Methods
|
27
|
+
config.include WebMock::API
|
28
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::Ynab do # rubocop:disable Metrics/BlockLength
|
4
|
+
def app
|
5
|
+
lambda do |_env|
|
6
|
+
[200, {}, ["Hello."]]
|
7
|
+
end
|
8
|
+
end
|
9
|
+
let(:fresh_strategy) { Class.new(OmniAuth::Strategies::Ynab) }
|
10
|
+
|
11
|
+
before do
|
12
|
+
OmniAuth.config.test_mode = true
|
13
|
+
end
|
14
|
+
|
15
|
+
after do
|
16
|
+
OmniAuth.config.test_mode = false
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "Subclassing Behavior" do
|
20
|
+
subject { fresh_strategy }
|
21
|
+
|
22
|
+
it "performs the OmniAuth::Strategy included hook" do
|
23
|
+
expect(OmniAuth.strategies).to include(OmniAuth::Strategies::Ynab)
|
24
|
+
expect(OmniAuth.strategies).to include(subject)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#client" do
|
29
|
+
subject { fresh_strategy }
|
30
|
+
|
31
|
+
it "is initialized with symbolized client_options" do
|
32
|
+
instance = subject.new(app, :client_options => {"authorize_url" => "https://example.com"})
|
33
|
+
expect(instance.client.options[:authorize_url]).to eq("https://example.com")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "sets ssl options as connection options" do
|
37
|
+
instance = subject.new(app, :client_options => {"ssl" => {"ca_path" => "foo"}})
|
38
|
+
expect(instance.client.options[:connection_opts][:ssl]).to eq(:ca_path => "foo")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#authorize_params" do
|
43
|
+
subject { fresh_strategy }
|
44
|
+
|
45
|
+
it "includes any authorize params passed in the :authorize_params option" do
|
46
|
+
instance = subject.new("abc", "def", :authorize_params => {:foo => "bar", :baz => "zip"})
|
47
|
+
expect(instance.authorize_params["foo"]).to eq("bar")
|
48
|
+
expect(instance.authorize_params["baz"]).to eq("zip")
|
49
|
+
end
|
50
|
+
|
51
|
+
it "includes top-level options that are marked as :authorize_options" do
|
52
|
+
instance = subject.new("abc", "def", :authorize_options => %i[scope foo state], :scope => "bar", :foo => "baz")
|
53
|
+
expect(instance.authorize_params["scope"]).to eq("bar")
|
54
|
+
expect(instance.authorize_params["foo"]).to eq("baz")
|
55
|
+
end
|
56
|
+
|
57
|
+
it "includes random state in the authorize params" do
|
58
|
+
instance = subject.new("abc", "def")
|
59
|
+
expect(instance.authorize_params.keys).to eq(["state"])
|
60
|
+
expect(instance.session["omniauth.state"]).not_to be_empty
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#token_params" do
|
65
|
+
subject { fresh_strategy }
|
66
|
+
|
67
|
+
it "includes any authorize params passed in the :authorize_params option" do
|
68
|
+
instance = subject.new("abc", "def", :token_params => {:foo => "bar", :baz => "zip"})
|
69
|
+
expect(instance.token_params).to eq("foo" => "bar", "baz" => "zip")
|
70
|
+
end
|
71
|
+
|
72
|
+
it "includes top-level options that are marked as :authorize_options" do
|
73
|
+
instance = subject.new("abc", "def", :token_options => %i[scope foo], :scope => "bar", :foo => "baz")
|
74
|
+
expect(instance.token_params).to eq("scope" => "bar", "foo" => "baz")
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "#callback_phase" do
|
79
|
+
subject { fresh_strategy }
|
80
|
+
it "calls fail with the client error received" do
|
81
|
+
instance = subject.new("abc", "def")
|
82
|
+
allow(instance).to receive(:request) do
|
83
|
+
double("Request", :params => {"error_reason" => "user_denied", "error" => "access_denied"})
|
84
|
+
end
|
85
|
+
|
86
|
+
expect(instance).to receive(:fail!).with("user_denied", anything)
|
87
|
+
instance.callback_phase
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe OmniAuth::Strategies::Ynab::CallbackError do
|
93
|
+
let(:error) { Class.new(OmniAuth::Strategies::Ynab::CallbackError) }
|
94
|
+
describe "#message" do
|
95
|
+
subject { error }
|
96
|
+
it "includes all of the attributes" do
|
97
|
+
instance = subject.new("error", "description", "uri")
|
98
|
+
expect(instance.message).to match(/error/)
|
99
|
+
expect(instance.message).to match(/description/)
|
100
|
+
expect(instance.message).to match(/uri/)
|
101
|
+
end
|
102
|
+
it "includes all of the attributes" do
|
103
|
+
instance = subject.new(nil, :symbol)
|
104
|
+
expect(instance.message).to eq("symbol")
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-ynab
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Berkman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-08-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: oauth2
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: omniauth
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
description: A YNAB OAuth2 strategy for OmniAuth.
|
56
|
+
email:
|
57
|
+
- mike@berkman.co
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".rubocop.yml"
|
65
|
+
- ".travis.yml"
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE.md
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- lib/omniauth-ynab.rb
|
71
|
+
- lib/omniauth-ynab/version.rb
|
72
|
+
- lib/omniauth/strategies/ynab.rb
|
73
|
+
- omniauth-ynab.gemspec
|
74
|
+
- spec/helper.rb
|
75
|
+
- spec/omniauth/strategies/ynab_spec.rb
|
76
|
+
homepage: https://github.com/berkman/omniauth-ynab
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.5.2.3
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: A YNAB OAuth2 strategy for OmniAuth.
|
100
|
+
test_files:
|
101
|
+
- spec/helper.rb
|
102
|
+
- spec/omniauth/strategies/ynab_spec.rb
|