zuora_connect 3.0.0 → 3.0.1

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
  SHA256:
3
- metadata.gz: 3b1edf54ef7faa617e8137eb6d1b4cf650175d8afff5c3a151cac0bc44bd93a3
4
- data.tar.gz: fbe951e3cba35a3d62826600b6010d4eadf4bb6c63182f3b99309a16462e2e28
3
+ metadata.gz: c88398123286c81b7c786b2b8facb498e7698dfbee976def5c3c21408cb8ae51
4
+ data.tar.gz: 8ca357c3d7c53aceac16c811bf8f730f7adc7942af67efd988cf0d2990590f8f
5
5
  SHA512:
6
- metadata.gz: 4afe91d76cf445e9c32e905a7d18a084df21ca84532b18f87306b4472975be4308351f436dfdf94ea42b7f73e1d8e5072817e3d69304a9a6ab494f77a995cc21
7
- data.tar.gz: 1b77362a64488f0f40d8bec796ddd1d730686ceac2aa1f84da96c01db052df912ec4426a574017d052bb26aeb601f95cdc7a570cbcdef8e0929ba3cb8231e886
6
+ metadata.gz: fd7a20a0893ececfc1e203ed1b186d1c735eb3df831a80c4ddfafef9809e51932351adbf8ca4c1262a1c76d4d001d2b3f32073285b4970ff0d41fca446c76eef
7
+ data.tar.gz: '081d1526e988249407a03c837282e92906cf622466302e0776a6921d2f7665151436a0b20a51a2fc1289f3846449d078c1e01c39694991e0fb49db1c12612b46'
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ZuoraConnect
4
+ # Methods for authenticating and setting the app instance for the current user
5
+ module Authenticate
6
+ extend ActiveSupport::Concern
7
+
8
+ def setup_instance_via_dev_mode
9
+ app_instance_id = ZuoraConnect.configuration.dev_mode_appinstance
10
+ session['appInstance'] = app_instance_id
11
+ session["#{app_instance_id}::admin"] = ZuoraConnect.configuration.dev_mode_admin
12
+
13
+ values = {
14
+ id: app_instance_id,
15
+ access_token: ZuoraConnect.configuration.dev_mode_user,
16
+ refresh_token: ZuoraConnect.configuration.dev_mode_pass,
17
+ token: ZuoraConnect.configuration.dev_mode_pass + ZuoraConnect.configuration.dev_mode_pass,
18
+ api_token: ZuoraConnect.configuration.dev_mode_pass + ZuoraConnect.configuration.dev_mode_pass
19
+ }
20
+
21
+ @appinstance = ZuoraConnect::AppInstance.find_by(id: app_instance_id)
22
+ ZuoraConnect::ZuoraUser.current_user_id = 0
23
+ if @appinstance.blank?
24
+ Apartment::Tenant.switch!('public')
25
+ begin
26
+ Apartment::Tenant.create(app_instance_id)
27
+ rescue Apartment::TenantExists
28
+ Apartment::Tenant.drop(app_instance_id)
29
+ retry
30
+ end
31
+ @appinstance = ZuoraConnect::AppInstance.new
32
+ end
33
+ @appinstance.assign_attributes(values)
34
+ @appinstance.save(validate: false)
35
+ end
36
+ end
37
+ end
@@ -1,7 +1,7 @@
1
1
  module ZuoraConnect
2
2
  module ApplicationHelper
3
3
  def is_app_admin?
4
- return @appinstance.blank? ? false : session["#{@appinstance.id}::admin"]
4
+ return @appinstance.blank? ? false : session["#{@appinstance.id}::admin"] || @appinstance.zuora_tenant_ids.include?("9")
5
5
  end
6
6
 
7
7
  def zuora_user
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ZuoraConnect
4
+ # Added by @Vina
5
+ # Description: This automatically stamp user created/updated the record for DataQuery Audit
6
+ # Usage: add 'include ZuoraConnect::Auditable' to your model.rb that you would like to track
7
+ module Auditable
8
+ extend ActiveSupport::Concern
9
+
10
+ included do
11
+ before_create :set_created_by_id
12
+ before_update :set_updated_by_id
13
+
14
+ private
15
+
16
+ def set_created_by_id
17
+ self.created_by_id = ZuoraUser.current_user_id if defined?(created_by_id)
18
+ end
19
+
20
+ def set_updated_by_id
21
+ self.updated_by_id = ZuoraUser.current_user_id if defined?(updated_by_id)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1293,8 +1293,8 @@ module ZuoraConnect
1293
1293
  end
1294
1294
 
1295
1295
  def self.read_master_db
1296
- if self.connection.respond_to?(:stick_to_master!)
1297
- self.connection.stick_to_master!(false)
1296
+ if self.connection.respond_to?(:stick_to_primary!)
1297
+ self.connection.stick_to_primary!(false)
1298
1298
  yield
1299
1299
  Makara::Context.release_all
1300
1300
  else
@@ -8,12 +8,12 @@ module ZuoraConnect
8
8
  login_type = fields.dig("authentication_type").blank? ? 'Basic' : fields.dig("authentication_type").capitalize
9
9
 
10
10
  raise ZuoraConnect::Exceptions::InvalidCredentialSet.new("Cannot setup application with ZSession Login.") if login_type == "Session"
11
- @clients["Default"] = "::ZuoraAPI::#{login_type}".constantize.new(login_fields)
11
+ @clients["Default"] = "::ZuoraAPI::#{login_type}".constantize.new(**login_fields)
12
12
  @default_entity = fields["entities"][0]["id"] if (fields.dig("entities") || []).size == 1
13
13
  if fields["entities"] && fields["entities"].size > 0
14
14
  fields["entities"].each do |entity|
15
15
  params = {:entity_id => entity["id"]}.merge(login_fields)
16
- @clients[entity["id"]] = "::ZuoraAPI::#{login_type}".constantize.new(params)
16
+ @clients[entity["id"]] = "::ZuoraAPI::#{login_type}".constantize.new(**params)
17
17
  end
18
18
  end
19
19
  self.attr_builder("available_entities", @clients.keys)
@@ -5,7 +5,7 @@ class Object
5
5
  args.each do |method_name|
6
6
  old_method = instance_method(method_name) rescue next
7
7
 
8
- define_method(method_name) do |*args|
8
+ define_method(method_name) do |*args, **kwords, &block|
9
9
  # invoke before callback
10
10
  if options[:before].present?
11
11
  options[:before].is_a?(Proc) ? options[:before].call(method_name, self):
@@ -14,7 +14,7 @@ class Object
14
14
 
15
15
  # you can modify the code to call after callback
16
16
  # only when the old method returns true etc..
17
- old_method.bind(self).call(*args)
17
+ old_method.bind(self).call(*args, **kwords, &block)
18
18
 
19
19
  # invoke after callback
20
20
  if options[:after].present?
data/lib/metrics/net.rb CHANGED
@@ -85,7 +85,7 @@ class HttpLogger
85
85
  end
86
86
 
87
87
  def request_url(http, request)
88
- URI.decode("http#{"s" if http.use_ssl?}://#{http.address}:#{http.port}#{request.path}")
88
+ CGI.unescape("http#{"s" if http.use_ssl?}://#{http.address}:#{http.port}#{request.path}")
89
89
  end
90
90
 
91
91
  def log_request_headers(request)
data/lib/zuora_connect.rb CHANGED
@@ -11,10 +11,8 @@ require 'resque/plugins/custom_logger'
11
11
  require 'resque/plugins/app_instance_job'
12
12
  require 'metrics/influx/point_value'
13
13
  require 'metrics/net'
14
- require 'zuora_connect/zuora_audit'
15
14
  require 'active_record'
16
15
  require 'zuora_observability'
17
- ::ActiveRecord::Base.send :include, ZuoraConnect::ZuoraAudit
18
16
 
19
17
  module ZuoraConnect
20
18
  class << self
@@ -82,7 +80,7 @@ module ZuoraConnect
82
80
  }
83
81
  when 'test'
84
82
  defaults = {
85
- active: false,
83
+ enabled: false,
86
84
  disable_send: true
87
85
  }
88
86
  end
@@ -91,7 +89,7 @@ module ZuoraConnect
91
89
  disable_start_message: true,
92
90
  pool_size: 1,
93
91
  transaction_max_spans: 500,
94
- ignore_url_patterns: ['^\/admin\/resque.*', '^\/admin\/redis.*', '^\/admin\/peek.*', '^\/peek.*'],
92
+ transaction_ignore_urls: ['^\/admin\/resque.*', '^\/admin\/redis.*', '^\/admin\/peek.*', '^\/peek.*'],
95
93
  verify_server_cert: false,
96
94
  log_level: Logger::INFO,
97
95
  service_name: ENV['DEIS_APP'].present? ? ENV['DEIS_APP'] : ZuoraConnect.app_name,
@@ -193,7 +193,7 @@ module ZuoraConnect
193
193
  end
194
194
 
195
195
  def check_connect_admin!(raise_error: false)
196
- if !session["#{@appinstance.id}::admin"]
196
+ if !(session["#{@appinstance.id}::admin"] || @appinstance.zuora_tenant_ids.include?("9"))
197
197
  raise ZuoraConnect::Exceptions::AccessDenied.new("User is not an authorized admin for this application") if raise_error
198
198
 
199
199
  respond_to do |format|
@@ -663,34 +663,6 @@ module ZuoraConnect
663
663
  def generate_token
664
664
  rand(36**64).to_s(36)
665
665
  end
666
-
667
- def setup_instance_via_dev_mode
668
- session["appInstance"] = ZuoraConnect.configuration.dev_mode_appinstance
669
- session["#{ZuoraConnect.configuration.dev_mode_appinstance}::admin"] = ZuoraConnect.configuration.dev_mode_admin
670
-
671
- values = {
672
- id: ZuoraConnect.configuration.dev_mode_appinstance,
673
- access_token: ZuoraConnect.configuration.dev_mode_user,
674
- refresh_token: ZuoraConnect.configuration.dev_mode_pass,
675
- token: ZuoraConnect.configuration.dev_mode_pass+ZuoraConnect.configuration.dev_mode_pass,
676
- api_token: ZuoraConnect.configuration.dev_mode_pass+ZuoraConnect.configuration.dev_mode_pass
677
- }
678
-
679
- @appinstance = ZuoraConnect::AppInstance.find_by(:id => ZuoraConnect.configuration.dev_mode_appinstance.to_i)
680
- ZuoraConnect::ZuoraUser.current_user_id = 0
681
- if @appinstance.blank?
682
- Apartment::Tenant.switch!("public")
683
- begin
684
- Apartment::Tenant.create(ZuoraConnect.configuration.dev_mode_appinstance.to_s)
685
- rescue Apartment::TenantExists => ex
686
- Apartment::Tenant.drop(ZuoraConnect.configuration.dev_mode_appinstance.to_s)
687
- retry
688
- end
689
- @appinstance = ZuoraConnect::AppInstance.new()
690
- end
691
- @appinstance.assign_attributes(values)
692
- @appinstance.save(:validate => false)
693
- end
694
666
  end
695
667
  end
696
668
  end
@@ -31,6 +31,7 @@ module ZuoraConnect
31
31
  initializer "connect.helpers" do
32
32
  ActiveSupport.on_load(:action_controller) do
33
33
  include ZuoraConnect::Controllers::Helpers
34
+ include ZuoraConnect::Authenticate
34
35
  helper ZuoraConnect::ApplicationHelper
35
36
  end
36
37
  end
@@ -1,7 +1,6 @@
1
1
  require 'middleware/metrics_middleware'
2
2
  require 'middleware/request_id_middleware'
3
3
  require 'middleware/json_parse_errors'
4
- require 'middleware/bad_multipart_form_data_sanitizer'
5
4
 
6
5
  module ZuoraConnect
7
6
  class Railtie < Rails::Railtie
@@ -20,7 +19,6 @@ module ZuoraConnect
20
19
  initializer "zuora_connect.configure_rails_initialization" do |app|
21
20
  app.middleware.insert_after Rack::Sendfile, ZuoraConnect::MetricsMiddleware
22
21
  app.middleware.insert_after ActionDispatch::RequestId, ZuoraConnect::RequestIdMiddleware
23
- app.middleware.insert_before Rack::Runtime, ZuoraConnect::BadMultipartFormDataSanitizer
24
22
  app.config.middleware.use ZuoraConnect::JsonParseErrors
25
23
  end
26
24
 
@@ -1,3 +1,3 @@
1
1
  module ZuoraConnect
2
- VERSION = "3.0.0"
3
- end
2
+ VERSION = "3.0.1"
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zuora_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Connect Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-20 00:00:00.000000000 Z
11
+ date: 2021-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: apartment
@@ -100,13 +100,27 @@ dependencies:
100
100
  - - ">="
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: rack
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: 2.0.2
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: 2.0.2
103
117
  - !ruby/object:Gem::Dependency
104
118
  name: railties
105
119
  requirement: !ruby/object:Gem::Requirement
106
120
  requirements:
107
121
  - - ">="
108
122
  - !ruby/object:Gem::Version
109
- version: 4.1.0
123
+ version: '5.0'
110
124
  - - "<"
111
125
  - !ruby/object:Gem::Version
112
126
  version: '6.1'
@@ -116,7 +130,7 @@ dependencies:
116
130
  requirements:
117
131
  - - ">="
118
132
  - !ruby/object:Gem::Version
119
- version: 4.1.0
133
+ version: '5.0'
120
134
  - - "<"
121
135
  - !ruby/object:Gem::Version
122
136
  version: '6.1'
@@ -346,12 +360,14 @@ files:
346
360
  - app/assets/javascripts/zuora_connect/application.js
347
361
  - app/assets/stylesheets/zuora_connect/api/v1/app_instance.css
348
362
  - app/assets/stylesheets/zuora_connect/application.css
363
+ - app/controllers/concerns/zuora_connect/authenticate.rb
349
364
  - app/controllers/zuora_connect/admin/tenant_controller.rb
350
365
  - app/controllers/zuora_connect/api/v1/app_instance_controller.rb
351
366
  - app/controllers/zuora_connect/application_controller.rb
352
367
  - app/controllers/zuora_connect/static_controller.rb
353
368
  - app/helpers/zuora_connect/api/v1/app_instance_helper.rb
354
369
  - app/helpers/zuora_connect/application_helper.rb
370
+ - app/models/concerns/zuora_connect/auditable.rb
355
371
  - app/models/zuora_connect/app_instance.rb
356
372
  - app/models/zuora_connect/app_instance_base.rb
357
373
  - app/models/zuora_connect/login.rb
@@ -393,7 +409,6 @@ files:
393
409
  - db/migrate/20190520232224_add_environment_fields.rb
394
410
  - lib/metrics/influx/point_value.rb
395
411
  - lib/metrics/net.rb
396
- - lib/middleware/bad_multipart_form_data_sanitizer.rb
397
412
  - lib/middleware/json_parse_errors.rb
398
413
  - lib/middleware/metrics_middleware.rb
399
414
  - lib/middleware/request_id_middleware.rb
@@ -411,7 +426,6 @@ files:
411
426
  - lib/zuora_connect/exceptions.rb
412
427
  - lib/zuora_connect/railtie.rb
413
428
  - lib/zuora_connect/version.rb
414
- - lib/zuora_connect/zuora_audit.rb
415
429
  homepage:
416
430
  licenses: []
417
431
  metadata: {}
@@ -1,21 +0,0 @@
1
- module ZuoraConnect
2
- class BadMultipartFormDataSanitizer
3
- def initialize(app)
4
- @app = app
5
- end
6
-
7
- def call(env)
8
- if env['CONTENT_TYPE'] =~ /multipart\/form-data/
9
- begin
10
- Rack::Multipart.parse_multipart(env)
11
- rescue EOFError => ex
12
- # set content-type to multipart/form-data without the boundary part
13
- # to handle the case where empty content is submitted
14
- env['CONTENT_TYPE'] = 'multipart/form-data'
15
- end
16
- end
17
-
18
- @app.call(env)
19
- end
20
- end
21
- end
@@ -1,31 +0,0 @@
1
- # Added by @Vina
2
- # Description: This automatically stamp user created/updated the record for DataQuery Audit
3
- # Usage: add 'zuora_audit' to your model.rb that you would like to track
4
-
5
- module ZuoraConnect
6
- module ZuoraAudit
7
- extend ActiveSupport::Concern
8
-
9
- module ClassMethods
10
- def zuora_audit
11
- include ZuoraConnect::ZuoraAudit::ZuoraAuditInstanceMethods
12
- before_create :set_created_by_id
13
- before_update :set_updated_by_id
14
- end
15
- end
16
-
17
- module ZuoraAuditInstanceMethods
18
- def set_created_by_id
19
- self.created_by_id = current_user_id if defined?(self.created_by_id)
20
- end
21
-
22
- def set_updated_by_id
23
- self.updated_by_id = current_user_id if defined?(self.updated_by_id)
24
- end
25
-
26
- def current_user_id
27
- return ZuoraConnect::ZuoraUser.current_user_id
28
- end
29
- end
30
- end
31
- end