omniauth-boletosimples 0.0.7 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e86fa27c60378f8cb3d85dd2002c8d1abfbaf28a
4
- data.tar.gz: 1492d537fcdc7ef40702127e0fa198546c1bf7c0
2
+ SHA256:
3
+ metadata.gz: ebc1d552e8c1476b07a3ee17903f53badc394c83bcbcc51669c1c9e9fa1f339e
4
+ data.tar.gz: ad90e4596fe5a9dfe44042134defdaa8e2f7d0b92b6f8d60d7b73f125442da95
5
5
  SHA512:
6
- metadata.gz: 26de8f4d179e8382fce4c05c80522ba4f7ffb902fcf4d6ebeabb680c96a4eefe172a5c863dcef3520fbfe6fa12b55ef2fbff575bad68eb1902427f5b62ce109c
7
- data.tar.gz: e182e4641366f2711912f09c2748e0947cf950e7e97ebbf10d2dbe4e7c5022314b999d8e3922d67c049334b6fe8cd5cd7205bdb19bb0af1f9b446cedbe625395
6
+ metadata.gz: 11b356002b99a8435e76c061d731ea68944bb0964f71f7c488b9bfa85591a91cfbf684a815719144e5fec031416e5b9036c4ae50cb0e2d708d9c0eccf76bbb9f
7
+ data.tar.gz: f9d8089df3a3d7a9106ba73aa2a45c61350e0a30abf4501fc5628e43c7d857f23ef7015772fad1cb17772233062004c41ce814a716d2414b6b9be2ec54b8bc20
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ AllCops:
2
+ NewCops: enable
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1.2
1
+ 3.0.1
data/Gemfile CHANGED
@@ -1,5 +1,10 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  gemspec
4
6
 
5
7
  gem 'json'
8
+ gem 'rubocop'
9
+ gem 'rubocop-rake'
10
+ gem 'rubocop-rspec'
data/Gemfile.lock CHANGED
@@ -1,48 +1,80 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- omniauth-boletosimples (0.0.7)
5
- omniauth-oauth2 (~> 1.3.0)
4
+ omniauth-boletosimples (1.0.0)
5
+ omniauth-oauth2 (~> 1.7)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- diff-lcs (1.2.5)
11
- faraday (0.9.1)
10
+ ast (2.4.2)
11
+ diff-lcs (1.4.4)
12
+ faraday (1.3.0)
13
+ faraday-net_http (~> 1.0)
12
14
  multipart-post (>= 1.2, < 3)
13
- hashie (3.4.2)
14
- json (1.8.3)
15
- jwt (1.5.0)
16
- multi_json (1.11.1)
17
- multi_xml (0.5.5)
18
- multipart-post (2.0.0)
19
- oauth2 (1.0.0)
20
- faraday (>= 0.8, < 0.10)
21
- jwt (~> 1.0)
15
+ ruby2_keywords
16
+ faraday-net_http (1.0.1)
17
+ hashie (4.1.0)
18
+ json (2.5.1)
19
+ jwt (2.2.2)
20
+ multi_json (1.15.0)
21
+ multi_xml (0.6.0)
22
+ multipart-post (2.1.1)
23
+ oauth2 (1.4.7)
24
+ faraday (>= 0.8, < 2.0)
25
+ jwt (>= 1.0, < 3.0)
22
26
  multi_json (~> 1.3)
23
27
  multi_xml (~> 0.5)
24
- rack (~> 1.2)
25
- omniauth (1.2.2)
26
- hashie (>= 1.2, < 4)
27
- rack (~> 1.0)
28
- omniauth-oauth2 (1.3.0)
29
- oauth2 (~> 1.0)
30
- omniauth (~> 1.2)
31
- rack (1.6.2)
32
- rake (10.4.2)
33
- rspec (3.3.0)
34
- rspec-core (~> 3.3.0)
35
- rspec-expectations (~> 3.3.0)
36
- rspec-mocks (~> 3.3.0)
37
- rspec-core (3.3.0)
38
- rspec-support (~> 3.3.0)
39
- rspec-expectations (3.3.0)
28
+ rack (>= 1.2, < 3)
29
+ omniauth (2.0.4)
30
+ hashie (>= 3.4.6)
31
+ rack (>= 1.6.2, < 3)
32
+ rack-protection
33
+ omniauth-oauth2 (1.7.1)
34
+ oauth2 (~> 1.4)
35
+ omniauth (>= 1.9, < 3)
36
+ parallel (1.20.1)
37
+ parser (3.0.1.0)
38
+ ast (~> 2.4.1)
39
+ rack (2.2.3)
40
+ rack-protection (2.1.0)
41
+ rack
42
+ rainbow (3.0.0)
43
+ rake (13.0.3)
44
+ regexp_parser (2.1.1)
45
+ rexml (3.2.5)
46
+ rspec (3.10.0)
47
+ rspec-core (~> 3.10.0)
48
+ rspec-expectations (~> 3.10.0)
49
+ rspec-mocks (~> 3.10.0)
50
+ rspec-core (3.10.1)
51
+ rspec-support (~> 3.10.0)
52
+ rspec-expectations (3.10.1)
40
53
  diff-lcs (>= 1.2.0, < 2.0)
41
- rspec-support (~> 3.3.0)
42
- rspec-mocks (3.3.0)
54
+ rspec-support (~> 3.10.0)
55
+ rspec-mocks (3.10.2)
43
56
  diff-lcs (>= 1.2.0, < 2.0)
44
- rspec-support (~> 3.3.0)
45
- rspec-support (3.3.0)
57
+ rspec-support (~> 3.10.0)
58
+ rspec-support (3.10.2)
59
+ rubocop (1.12.1)
60
+ parallel (~> 1.10)
61
+ parser (>= 3.0.0.0)
62
+ rainbow (>= 2.2.2, < 4.0)
63
+ regexp_parser (>= 1.8, < 3.0)
64
+ rexml
65
+ rubocop-ast (>= 1.2.0, < 2.0)
66
+ ruby-progressbar (~> 1.7)
67
+ unicode-display_width (>= 1.4.0, < 3.0)
68
+ rubocop-ast (1.4.1)
69
+ parser (>= 2.7.1.5)
70
+ rubocop-rake (0.5.1)
71
+ rubocop
72
+ rubocop-rspec (2.2.0)
73
+ rubocop (~> 1.0)
74
+ rubocop-ast (>= 1.1.0)
75
+ ruby-progressbar (1.11.0)
76
+ ruby2_keywords (0.0.4)
77
+ unicode-display_width (2.0.0)
46
78
 
47
79
  PLATFORMS
48
80
  ruby
@@ -51,4 +83,10 @@ DEPENDENCIES
51
83
  json
52
84
  omniauth-boletosimples!
53
85
  rake
54
- rspec (~> 3.3.0)
86
+ rspec
87
+ rubocop
88
+ rubocop-rake
89
+ rubocop-rspec
90
+
91
+ BUNDLED WITH
92
+ 2.2.15
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
@@ -1 +1,3 @@
1
- require 'omniauth/boletosimples'
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth/boletosimples'
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'omniauth/boletosimples/version'
2
- require 'omniauth/strategies/boletosimples'
4
+ require 'omniauth/strategies/boletosimples'
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OmniAuth
2
4
  module BoletoSimples
3
- VERSION = "0.0.7"
5
+ VERSION = '1.0.0'
4
6
  end
5
7
  end
@@ -1,21 +1,22 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'omniauth-oauth2'
2
4
 
3
5
  module OmniAuth
4
6
  module Strategies
5
7
  class BoletoSimples < OmniAuth::Strategies::OAuth2
6
- DEFAULT_SCOPE = "profile"
8
+ DEFAULT_SCOPE = 'profile'
7
9
  ENVIRONMENTS = {
8
10
  development: 'http://localhost:5000',
9
11
  sandbox: 'https://sandbox.boletosimples.com.br',
10
- production: 'https://boletosimples.com.br',
11
- }
12
+ production: 'https://boletosimples.com.br'
13
+ }.freeze
12
14
  option :name, 'boletosimples'
13
- option :client_options, {
14
- :token_url => '/api/v1/oauth2/token',
15
- :setup => true
16
- }
15
+ option :client_options,
16
+ token_url: '/api/v1/oauth2/token',
17
+ setup: true
17
18
 
18
- option :authorize_options, [:scope, :response_type]
19
+ option :authorize_options, %i[scope response_type]
19
20
  option :provider_ignores_state, true
20
21
  option :environment, :production
21
22
 
@@ -33,7 +34,7 @@ module OmniAuth
33
34
  cpf: raw_info['cpf'],
34
35
  mother_name: raw_info['mother_name'],
35
36
  father_name: raw_info['father_name'],
36
- sex: raw_info['sex'],
37
+ sex: raw_info['sex']
37
38
  }
38
39
  end
39
40
 
@@ -47,18 +48,9 @@ module OmniAuth
47
48
  address_neighborhood: raw_info['address_neighborhood'],
48
49
  address_postal_code: raw_info['address_postal_code'],
49
50
  phone_number: raw_info['phone_number'],
50
- banking_bank_number: raw_info['banking_bank_number'],
51
- banking_agency_number: raw_info['banking_agency_number'],
52
- banking_agency_digit: raw_info['banking_agency_digit'],
53
- banking_account_number: raw_info['banking_account_number'],
54
- banking_account_digit: raw_info['banking_account_digit'],
55
- banking_person_type: raw_info['banking_person_type'],
56
- banking_person_name: raw_info['banking_person_name'],
57
- banking_cnpj_cpf: raw_info['banking_cnpj_cpf'],
58
51
  business_legal_name: raw_info['business_legal_name'],
59
52
  business_name: raw_info['business_name'],
60
- business_cnpj: raw_info['business_cnpj'],
61
- send_email_on_creation: raw_info['send_email_on_creation']
53
+ business_cnpj: raw_info['business_cnpj']
62
54
  }
63
55
  end
64
56
 
@@ -66,17 +58,24 @@ module OmniAuth
66
58
  environment = options.environment || :production
67
59
  options.client_options[:site] = ENVIRONMENTS[environment.to_sym]
68
60
  options.client_options[:authorize_url] = "#{ENVIRONMENTS[environment.to_sym]}/api/v1/oauth2/authorize"
61
+
62
+ return unless options.user_agent
63
+
69
64
  options.client_options[:connection_opts] = {
70
65
  headers: {
71
- 'User-Agent' => options.user_agent,
66
+ 'User-Agent' => options.user_agent
72
67
  }
73
- } if options.user_agent
68
+ }
74
69
  end
75
70
 
76
71
  def raw_info
77
72
  @raw_info ||= load_identity
78
73
  end
79
74
 
75
+ def callback_url
76
+ options[:redirect_uri] || (full_host + script_name + callback_path)
77
+ end
78
+
80
79
  def authorize_params
81
80
  super.tap do |params|
82
81
  params[:scope] ||= DEFAULT_SCOPE
@@ -84,12 +83,10 @@ module OmniAuth
84
83
  end
85
84
 
86
85
  private
87
- def load_identity
88
- access_token.options[:mode] = :query
89
- access_token.options[:param_name] = :access_token
90
- access_token.options[:grant_type] = :authorization_code
91
- access_token.get('/api/v1/userinfo').parsed
92
- end
86
+
87
+ def load_identity
88
+ access_token.get('/api/v1/userinfo').parsed
89
+ end
93
90
  end
94
91
  end
95
92
  end
@@ -1,5 +1,6 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
3
4
  require 'omniauth/boletosimples/version'
4
5
 
5
6
  Gem::Specification.new do |s|
@@ -16,8 +17,8 @@ Gem::Specification.new do |s|
16
17
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
17
18
  s.require_paths = ['lib']
18
19
 
19
- s.add_runtime_dependency 'omniauth-oauth2', '~> 1.3.0'
20
+ s.add_runtime_dependency 'omniauth-oauth2', '~> 1.7'
20
21
 
21
- s.add_development_dependency 'rspec', '~> 3.3.0'
22
22
  s.add_development_dependency 'rake'
23
- end
23
+ s.add_development_dependency 'rspec'
24
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'omniauth-boletosimples'
3
5
 
@@ -8,45 +10,58 @@ describe OmniAuth::Strategies::BoletoSimples do
8
10
 
9
11
  it_should_behave_like 'an oauth2 strategy'
10
12
 
11
- describe '#client' do
12
- it 'has correct BoletoSimples site' do
13
- subject.setup_phase
14
- expect(subject.client.site).to eq('https://boletosimples.com.br')
15
- end
13
+ it 'has correct BoletoSimples site' do
14
+ subject.setup_phase
15
+ expect(subject.client.site).to eq('https://boletosimples.com.br')
16
+ end
16
17
 
17
- it 'has correct BoletoSimples sandbox site' do
18
- @options = { :environment => :sandbox }
19
- subject.setup_phase
20
- expect(subject.client.site).to eq('https://sandbox.boletosimples.com.br')
21
- end
18
+ it 'has correct BoletoSimples sandbox site' do
19
+ @options = { environment: :sandbox }
20
+ subject.setup_phase
21
+ expect(subject.client.site).to eq('https://sandbox.boletosimples.com.br')
22
+ end
22
23
 
23
- it 'has correct authorize url' do
24
- subject.setup_phase
25
- expect(subject.client.options[:authorize_url]).to eq('https://boletosimples.com.br/api/v1/oauth2/authorize')
26
- end
24
+ it 'has correct authorize url' do
25
+ subject.setup_phase
26
+ expect(subject.client.options[:authorize_url]).to eq('https://boletosimples.com.br/api/v1/oauth2/authorize')
27
+ end
27
28
 
28
- it 'has correct sandbox authorize url' do
29
- @options = { :environment => :sandbox }
30
- subject.setup_phase
31
- expect(subject.client.options[:authorize_url]).to eq('https://sandbox.boletosimples.com.br/api/v1/oauth2/authorize')
32
- end
29
+ it 'has correct sandbox authorize url' do
30
+ @options = { environment: :sandbox }
31
+ subject.setup_phase
32
+ expect(subject.client.options[:authorize_url]).to eq('https://sandbox.boletosimples.com.br/api/v1/oauth2/authorize')
33
+ end
33
34
 
34
- it 'has correct token url' do
35
- expect(subject.client.options[:token_url]).to eq('/api/v1/oauth2/token')
36
- end
35
+ it 'has correct token url' do
36
+ expect(subject.client.options[:token_url]).to eq('/api/v1/oauth2/token')
37
+ end
38
+
39
+ it 'has correct connection_opts' do
40
+ @options = { user_agent: 'email@example.com' }
41
+ subject.setup_phase
42
+ expect(subject.client.options[:connection_opts]).to eq(headers: { "User-Agent": 'email@example.com' })
43
+ end
37
44
 
38
- it 'has correct connection_opts' do
39
- @options = { :user_agent => 'email@example.com' }
40
- subject.setup_phase
41
- expect(subject.client.options[:connection_opts]).to eq({:headers=>{:"User-Agent"=>"email@example.com"}})
45
+ describe '#callback_url' do
46
+ let(:base_url) { 'https://example.com' }
47
+
48
+ it 'has the correct default callback path' do
49
+ allow(subject).to receive(:full_host) { base_url }
50
+ allow(subject).to receive(:script_name) { '' }
51
+ expect(subject.send(:callback_url)).to eq("#{base_url}/auth/boletosimples/callback")
42
52
  end
43
53
 
44
- end
54
+ it 'should set the callback path with script_name if present' do
55
+ allow(subject).to receive(:full_host) { base_url }
56
+ allow(subject).to receive(:script_name) { '/v1' }
57
+ expect(subject.send(:callback_url)).to eq("#{base_url}/v1/v1/auth/boletosimples/callback")
58
+ end
45
59
 
46
- describe '#callback_path' do
47
- it "has the correct callback path" do
48
- expect(subject.callback_path).to eq('/auth/boletosimples/callback')
60
+ it 'should set the callback_path parameter if present' do
61
+ @options = { callback_path: '/auth/foo/callback' }
62
+ allow(subject).to receive(:full_host) { base_url }
63
+ allow(subject).to receive(:script_name) { '' }
64
+ expect(subject.send(:callback_url)).to eq("#{base_url}/auth/foo/callback")
49
65
  end
50
66
  end
51
-
52
67
  end
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/setup'
2
4
  require 'rspec'
3
5
  require 'omniauth'
4
- Dir[File.expand_path('../support/**/*', __FILE__)].each { |f| require f }
6
+ Dir[File.expand_path('support/**/*', __dir__)].sort.each { |f| require f }
5
7
 
6
- RSpec.configure do |config|
8
+ RSpec.configure do |_config|
7
9
  OmniAuth.config.test_mode = true
8
10
  end
@@ -1,21 +1,23 @@
1
- # NOTE it would be useful if this lived in omniauth-oauth2 eventually
1
+ # frozen_string_literal: true
2
+
3
+ # NOTE: it would be useful if this lived in omniauth-oauth2 eventually
2
4
  shared_examples 'an oauth2 strategy' do
3
5
  describe '#client' do
4
6
  it 'should be initialized with symbolized client_options' do
5
- @options = { :client_options => { 'authorize_url' => 'https://example.com' } }
7
+ @options = { client_options: { 'authorize_url' => 'https://example.com' } }
6
8
  expect(subject.client.options[:authorize_url]).to eq('https://example.com')
7
9
  end
8
10
  end
9
11
 
10
12
  describe '#authorize_params' do
11
13
  it 'should include any authorize params passed in the :authorize_params option' do
12
- @options = { :authorize_params => { :foo => 'bar', :baz => 'zip' } }
14
+ @options = { authorize_params: { foo: 'bar', baz: 'zip' } }
13
15
  expect(subject.authorize_params['foo']).to eq('bar')
14
16
  expect(subject.authorize_params['baz']).to eq('zip')
15
17
  end
16
18
 
17
19
  it 'should include top-level options that are marked as :authorize_options' do
18
- @options = { :authorize_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
20
+ @options = { authorize_options: %i[scope foo], scope: 'bar', foo: 'baz' }
19
21
  expect(subject.authorize_params['scope']).to eq('bar')
20
22
  expect(subject.authorize_params['foo']).to eq('baz')
21
23
  end
@@ -23,15 +25,15 @@ shared_examples 'an oauth2 strategy' do
23
25
 
24
26
  describe '#token_params' do
25
27
  it 'should include any token params passed in the :token_params option' do
26
- @options = { :token_params => { :foo => 'bar', :baz => 'zip' } }
28
+ @options = { token_params: { foo: 'bar', baz: 'zip' } }
27
29
  expect(subject.token_params['foo']).to eq('bar')
28
30
  expect(subject.token_params['baz']).to eq('zip')
29
31
  end
30
32
 
31
33
  it 'should include top-level options that are marked as :token_options' do
32
- @options = { :token_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
34
+ @options = { token_options: %i[scope foo], scope: 'bar', foo: 'baz' }
33
35
  expect(subject.token_params['scope']).to eq('bar')
34
36
  expect(subject.token_params['foo']).to eq('baz')
35
37
  end
36
38
  end
37
- end
39
+ end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-boletosimples
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafael Lima
8
8
  - Kivanio Barbosa
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-16 00:00:00.000000000 Z
12
+ date: 2021-04-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: omniauth-oauth2
@@ -17,30 +17,30 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 1.3.0
20
+ version: '1.7'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 1.3.0
27
+ version: '1.7'
28
28
  - !ruby/object:Gem::Dependency
29
- name: rspec
29
+ name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: 3.3.0
34
+ version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "~>"
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: 3.3.0
41
+ version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
- name: rake
43
+ name: rspec
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - ">="
@@ -53,7 +53,7 @@ dependencies:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
- description:
56
+ description:
57
57
  email:
58
58
  - contato@rafael.adm.br
59
59
  - kivanio@gmail.com
@@ -62,6 +62,7 @@ extensions: []
62
62
  extra_rdoc_files: []
63
63
  files:
64
64
  - ".gitignore"
65
+ - ".rubocop.yml"
65
66
  - ".ruby-gemset"
66
67
  - ".ruby-version"
67
68
  - CHANGELOG.md
@@ -83,7 +84,7 @@ homepage: https://github.com/BoletoSimples/omniauth-boletosimples
83
84
  licenses:
84
85
  - MIT
85
86
  metadata: {}
86
- post_install_message:
87
+ post_install_message:
87
88
  rdoc_options: []
88
89
  require_paths:
89
90
  - lib
@@ -98,9 +99,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
99
  - !ruby/object:Gem::Version
99
100
  version: '0'
100
101
  requirements: []
101
- rubyforge_project:
102
- rubygems_version: 2.4.5
103
- signing_key:
102
+ rubygems_version: 3.2.15
103
+ signing_key:
104
104
  specification_version: 4
105
105
  summary: BoletoSimples strategy for OmniAuth
106
106
  test_files: