finapps_core 2.0.5 → 2.0.6

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
2
  SHA1:
3
- metadata.gz: 1314ddfbd9ff74692398f160775f37eb95fea522
4
- data.tar.gz: f35d567b3a9cb5377e2b1c17500745a55d05878a
3
+ metadata.gz: d572a8ff17d98bcb1ce97450aabb466546643c43
4
+ data.tar.gz: a817625334d11a4913d77dbc5301525ac652416b
5
5
  SHA512:
6
- metadata.gz: 7285d2858e9db560ce841bab335a4bd762f914b263a640167a9469824b8d25e2f605d8f86018ab808c8b798bf90544fd69f12db8a764f90678939ba1266d9a24
7
- data.tar.gz: bb6a5288ce228de689ef6fbd09c4b63a5849d6393aa67202735093b1e8740d80a5c86fd7c3829ea9056804fd19f8bbbc7d41115add35acb4eaf7cee3545dcfee
6
+ metadata.gz: 7cc72f84ff5c4f4051d56f8a8a59d6313c3516b1541287ca438f04af2658e2c5056bb41845dbbd10a173fd5df9e594ebeb3acb50b4e99fb3949a88f6b53b3d65
7
+ data.tar.gz: abbde216bd6238f0ebd250ece49ffc7265746baa786635c5cdd14c26eee6de4848073eb5181786c661b64e143196f7ab719a2c5cbca85b88bff07f9c79fc56ec
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- finapps_core (2.0.4)
4
+ finapps_core (2.0.5)
5
5
  faraday (~> 0.11, >= 0.11.0)
6
- faraday_middleware (~> 0.11, >= 0.11.0)
6
+ faraday_middleware (~> 0.11, >= 0.11.0.1)
7
7
  rash (~> 0.4, >= 0.4.0)
8
8
  typhoeus (~> 1.1, >= 1.1.2)
9
9
 
@@ -87,7 +87,7 @@ DEPENDENCIES
87
87
  bundler (~> 1.14, >= 1.14.3)
88
88
  codeclimate-test-reporter (~> 1.0, >= 1.0.5)
89
89
  finapps_core!
90
- rake (~> 12.0.0, >= 12.0.0)
90
+ rake (~> 12.0, >= 12.0.0)
91
91
  rspec (~> 3.5, >= 3.5.0)
92
92
  rubocop (~> 0.47, >= 0.47.1)
93
93
  simplecov (~> 0.11, >= 0.11.2)
data/finapps_core.gemspec CHANGED
@@ -20,19 +20,19 @@ Gem::Specification.new do |spec|
20
20
  spec.test_files = Dir['spec/**/*.rb']
21
21
  spec.require_paths = ['lib']
22
22
 
23
- spec.add_runtime_dependency 'faraday', '~> 0.11', '>= 0.11.0'
24
- spec.add_runtime_dependency 'faraday_middleware', '~> 0.11', '>= 0.11.0'
25
- spec.add_runtime_dependency 'typhoeus', '~> 1.1', '>= 1.1.2'
26
- spec.add_runtime_dependency 'rash', '~> 0.4', '>= 0.4.0'
23
+ spec.add_runtime_dependency 'faraday', '~> 0.11', '>= 0.11.0'
24
+ spec.add_runtime_dependency 'faraday_middleware', '~> 0.11', '>= 0.11.0.1'
25
+ spec.add_runtime_dependency 'typhoeus', '~> 1.1', '>= 1.1.2'
26
+ spec.add_runtime_dependency 'rash', '~> 0.4', '>= 0.4.0'
27
27
 
28
- spec.add_development_dependency 'bundler', '~> 1.14', '>= 1.14.3'
29
- spec.add_development_dependency 'rake', '~> 12.0.0', '>= 12.0.0'
30
- spec.add_development_dependency 'rspec', '~> 3.5', '>= 3.5.0'
31
- spec.add_development_dependency 'webmock', '~> 2.3', '>= 2.3.2'
32
- spec.add_development_dependency 'sinatra', '~> 1.4', '>= 1.4.7'
33
- spec.add_development_dependency 'simplecov', '~> 0.11', '>= 0.11.2'
34
- spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0', '>= 1.0.5'
35
- spec.add_development_dependency 'rubocop', '~> 0.47','>= 0.47.1'
28
+ spec.add_development_dependency 'bundler', '~> 1.14', '>= 1.14.3'
29
+ spec.add_development_dependency 'rake', '~> 12.0', '>= 12.0.0'
30
+ spec.add_development_dependency 'rspec', '~> 3.5', '>= 3.5.0'
31
+ spec.add_development_dependency 'webmock', '~> 2.3', '>= 2.3.2'
32
+ spec.add_development_dependency 'sinatra', '~> 1.4', '>= 1.4.7'
33
+ spec.add_development_dependency 'simplecov', '~> 0.11', '>= 0.11.2'
34
+ spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0', '>= 1.0.5'
35
+ spec.add_development_dependency 'rubocop', '~> 0.47', '>= 0.47.1'
36
36
 
37
37
  spec.extra_rdoc_files = %w(README.md LICENSE)
38
38
  spec.rdoc_options = %w(--line-numbers --inline-source --title finapps-ruby-core --main README.md)
@@ -6,9 +6,9 @@ module FinAppsCore
6
6
  class TenantAuthentication < Faraday::Middleware
7
7
  KEY = 'X-FinApps-Token' unless defined? KEY
8
8
 
9
- def initialize(app, identifier, token)
9
+ def initialize(app, token)
10
10
  super(app)
11
- @header_value = "#{identifier.to_s.strip}=#{token.to_s.strip}"
11
+ @header_value = token.to_s.strip
12
12
  end
13
13
 
14
14
  def call(env)
@@ -1,4 +1,8 @@
1
1
  # frozen_string_literal: true
2
+ require_relative './configuration.rb'
3
+ require_relative './connection.rb'
4
+ require_relative '../utils/loggeable'
5
+
2
6
  module FinAppsCore
3
7
  module REST
4
8
  # base client functionality
@@ -11,7 +15,7 @@ module FinAppsCore
11
15
  attr_reader :config
12
16
 
13
17
  def initialize(options, logger=nil)
14
- @config = FinAppsCore::REST::Configuration.new options
18
+ @config = ::FinAppsCore::REST::Configuration.new options
15
19
  @logger = logger
16
20
  end
17
21
 
@@ -5,15 +5,14 @@ module FinAppsCore
5
5
  class Configuration # :nodoc:
6
6
  using ObjectExtensions
7
7
 
8
- attr_accessor :host,
9
- :tenant_identifier, :tenant_token,
10
- :user_identifier, :user_token,
11
- :proxy, :timeout, :retry_limit, :log_level
8
+ attr_accessor :tenant_token, :user_identifier, :user_token,
9
+ :host, :proxy, :timeout, :retry_limit,
10
+ :log_level
12
11
 
13
12
  def initialize(options={})
14
- non_nil_options = options.select {|_, value| !value.nil? }
15
- FinAppsCore::REST::Defaults::DEFAULTS.merge(non_nil_options)
13
+ FinAppsCore::REST::Defaults::DEFAULTS.merge(remove_empty_options(options))
16
14
  .each {|key, value| public_send("#{key}=", value) }
15
+
17
16
  raise FinAppsCore::InvalidArgumentsError.new "Invalid argument. {host: #{host}}" unless valid_host?
18
17
  raise FinAppsCore::InvalidArgumentsError.new "Invalid argument. {timeout: #{timeout}}" unless timeout.integer?
19
18
  end
@@ -27,6 +26,10 @@ module FinAppsCore
27
26
  def valid_host?
28
27
  host.start_with?('http://', 'https://')
29
28
  end
29
+
30
+ def remove_empty_options(hash)
31
+ hash.select {|_, value| !value.nil? }
32
+ end
30
33
  end
31
34
  end
32
35
  end
@@ -13,7 +13,7 @@ module FinAppsCore
13
13
  Faraday.new(options) do |conn|
14
14
  conn.request :accept_json
15
15
  conn.request :user_agent
16
- conn.request :tenant_authentication, config.tenant_identifier, config.tenant_token
16
+ conn.request :tenant_authentication, config.tenant_token
17
17
  conn.request :json
18
18
  conn.request :retry
19
19
  conn.request :multipart
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module FinAppsCore
3
- VERSION = '2.0.5'
3
+ VERSION = '2.0.6'
4
4
  end
@@ -1,31 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
  RSpec.describe FinAppsCore::Middleware::NoEncodingBasicAuthentication do
3
- let(:valid_credentials) { VALID_CREDENTIALS }
4
3
  let(:key) { FinAppsCore::Middleware::NoEncodingBasicAuthentication::KEY }
5
4
 
6
5
  describe '#call' do
7
- fake_app = proc {|env| env }
6
+ app = proc {|env| env }
8
7
 
9
8
  context 'when credentials were provided' do
10
- let(:middleware) do
11
- FinAppsCore::Middleware::NoEncodingBasicAuthentication.new(fake_app, VALID_CREDENTIALS[:token])
12
- end
13
- let(:expected_header) { "Basic #{valid_credentials[:token]}" }
9
+ let(:middleware) { FinAppsCore::Middleware::NoEncodingBasicAuthentication.new(app, VALID_CREDENTIALS[:token]) }
10
+ let(:expected_header_value) { "Basic #{VALID_CREDENTIALS[:token]}" }
14
11
 
15
12
  context 'when header was not previously set' do
16
13
  let(:request_env) { {request_headers: {}} }
17
- subject(:actual_header) { middleware.call(request_env)[:request_headers][key] }
14
+ subject(:result) { middleware.call(request_env) }
18
15
 
19
- it('generates a header') { expect(actual_header).to eq(expected_header) }
16
+ it('generates a header') { expect(result[:request_headers][key]).to eq(expected_header_value) }
20
17
  end
21
18
 
22
19
  context 'when header was previously set' do
23
- let(:existing_header) { {FinAppsCore::Middleware::NoEncodingBasicAuthentication::KEY => 'foo'} }
24
- let(:request_env) { {request_headers: existing_header} }
25
- subject(:actual_header) { middleware.call(request_env)[:request_headers][key] }
20
+ let(:request_env) { {request_headers: {key => 'foo'}} }
21
+ subject(:result) { middleware.call(request_env) }
26
22
 
27
- it('does not override existing header') { expect(actual_header).to eq('foo') }
28
- it('does not generate a header') { expect(actual_header).to_not eq(expected_header) }
23
+ it('does not override existing header') { expect(result[:request_headers][key]).to eq('foo') }
24
+ it('does not generate a header') { expect(result[:request_headers][key]).to_not eq(expected_header_value) }
29
25
  end
30
26
  end
31
27
  end
@@ -7,12 +7,8 @@ RSpec.describe FinAppsCore::Middleware::TenantAuthentication do
7
7
  fake_app = proc {|env| env }
8
8
 
9
9
  context 'when company credentials were provided' do
10
- let(:middleware) do
11
- FinAppsCore::Middleware::TenantAuthentication.new(fake_app,
12
- VALID_CREDENTIALS[:identifier],
13
- VALID_CREDENTIALS[:token])
14
- end
15
- let(:expected_header) { "#{valid_tenant_options[:identifier]}=#{valid_tenant_options[:token]}" }
10
+ let(:middleware) { FinAppsCore::Middleware::TenantAuthentication.new(fake_app, VALID_CREDENTIALS[:token]) }
11
+ let(:expected_header) { valid_tenant_options[:token] }
16
12
 
17
13
  context 'when header was not previously set' do
18
14
  let(:request_env) { {request_headers: {}} }
@@ -1,9 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  RSpec.describe FinAppsCore::REST::BaseClient do
3
- let(:valid_tenant_options) do
4
- {tenant_identifier: VALID_CREDENTIALS[:identifier],
5
- tenant_token: VALID_CREDENTIALS[:token]}
6
- end
3
+ let(:valid_tenant_options) { {tenant_token: VALID_CREDENTIALS[:token]} }
7
4
  subject { FinAppsCore::REST::BaseClient.new(valid_tenant_options) }
8
5
 
9
6
  RESPONSE = 0
@@ -1,18 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
  class FakeClass
3
- include ::FinAppsCore::Utils::ParameterFilter
3
+ include FinAppsCore::Utils::ParameterFilter
4
4
  end
5
5
 
6
6
  RSpec.describe FinAppsCore::Utils::ParameterFilter do
7
7
  describe '#skip_sensitive_data' do
8
8
  context 'when provided with sensitive data' do
9
9
  let(:unfiltered_params) do
10
- {password: 'FinApps@123', password_confirm: 'FinApps@123', token: '123456',
11
- login: 'sammysosa', username: 'johnny', name: 'george'}
10
+ {
11
+ password: 'FinApps@123',
12
+ password_confirm: 'FinApps@123',
13
+ token: '123456',
14
+ login: 'sammysosa',
15
+ username: 'johnny',
16
+ name: 'george'
17
+ }
12
18
  end
13
19
  let(:filtered_params) do
14
- {password: '[REDACTED]', password_confirm: '[REDACTED]', token: '[REDACTED]',
15
- login: '[REDACTED]', username: '[REDACTED]', name: 'george'}
20
+ {
21
+ password: '[REDACTED]',
22
+ password_confirm: '[REDACTED]',
23
+ token: '[REDACTED]',
24
+ login: '[REDACTED]',
25
+ username: '[REDACTED]',
26
+ name: 'george'
27
+ }
16
28
  end
17
29
 
18
30
  it 'filters out sensitive values' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: finapps_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erich Quintero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-08 00:00:00.000000000 Z
11
+ date: 2017-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '0.11'
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 0.11.0
42
+ version: 0.11.0.1
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: '0.11'
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 0.11.0
52
+ version: 0.11.0.1
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: typhoeus
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -116,7 +116,7 @@ dependencies:
116
116
  requirements:
117
117
  - - "~>"
118
118
  - !ruby/object:Gem::Version
119
- version: 12.0.0
119
+ version: '12.0'
120
120
  - - ">="
121
121
  - !ruby/object:Gem::Version
122
122
  version: 12.0.0
@@ -126,7 +126,7 @@ dependencies:
126
126
  requirements:
127
127
  - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: 12.0.0
129
+ version: '12.0'
130
130
  - - ">="
131
131
  - !ruby/object:Gem::Version
132
132
  version: 12.0.0