zuora_connect 3.0.0.pre.y → 3.0.1.pre.d
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/zuora_connect/authenticate.rb +37 -0
- data/app/helpers/zuora_connect/application_helper.rb +1 -1
- data/app/models/concerns/zuora_connect/auditable.rb +25 -0
- data/app/models/zuora_connect/app_instance_base.rb +2 -2
- data/app/models/zuora_connect/login.rb +2 -2
- data/config/initializers/object_method_hooks.rb +2 -2
- data/lib/metrics/net.rb +1 -1
- data/lib/zuora_connect.rb +2 -4
- data/lib/zuora_connect/controllers/helpers.rb +1 -29
- data/lib/zuora_connect/engine.rb +1 -0
- data/lib/zuora_connect/version.rb +2 -2
- metadata +4 -3
- data/lib/zuora_connect/zuora_audit.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8b3b4c908df4b86092fd22f150ba750db352f3cb4326872968c75340502d874
|
4
|
+
data.tar.gz: b4c4720d6ea4b42ada745e4a799b2155a801e41b360def0c2b7bef215b6b7a74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8e1d30cee3f916747c57b0ca1b5710bf34e770ca93421d69ac1d20bf56ff2621583d28c92df0e0523d2f3afcb9f384130ff0f2745334d8dd5d4c96920974aa1
|
7
|
+
data.tar.gz: 8be5213e0ca5e98dd40f4ce7e6bfaf6a89da14817dcacc4727c1508b15f62625d0cf39a0ab8bf831b989d7c6229022b499de37dba9454ff11581ac795c70b956
|
@@ -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?(:
|
1297
|
-
self.connection.
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
data/lib/zuora_connect/engine.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module ZuoraConnect
|
2
|
-
VERSION = "3.0.
|
3
|
-
end
|
2
|
+
VERSION = "3.0.1-d"
|
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.
|
4
|
+
version: 3.0.1.pre.d
|
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
|
11
|
+
date: 2021-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apartment
|
@@ -346,12 +346,14 @@ files:
|
|
346
346
|
- app/assets/javascripts/zuora_connect/application.js
|
347
347
|
- app/assets/stylesheets/zuora_connect/api/v1/app_instance.css
|
348
348
|
- app/assets/stylesheets/zuora_connect/application.css
|
349
|
+
- app/controllers/concerns/zuora_connect/authenticate.rb
|
349
350
|
- app/controllers/zuora_connect/admin/tenant_controller.rb
|
350
351
|
- app/controllers/zuora_connect/api/v1/app_instance_controller.rb
|
351
352
|
- app/controllers/zuora_connect/application_controller.rb
|
352
353
|
- app/controllers/zuora_connect/static_controller.rb
|
353
354
|
- app/helpers/zuora_connect/api/v1/app_instance_helper.rb
|
354
355
|
- app/helpers/zuora_connect/application_helper.rb
|
356
|
+
- app/models/concerns/zuora_connect/auditable.rb
|
355
357
|
- app/models/zuora_connect/app_instance.rb
|
356
358
|
- app/models/zuora_connect/app_instance_base.rb
|
357
359
|
- app/models/zuora_connect/login.rb
|
@@ -411,7 +413,6 @@ files:
|
|
411
413
|
- lib/zuora_connect/exceptions.rb
|
412
414
|
- lib/zuora_connect/railtie.rb
|
413
415
|
- lib/zuora_connect/version.rb
|
414
|
-
- lib/zuora_connect/zuora_audit.rb
|
415
416
|
homepage:
|
416
417
|
licenses: []
|
417
418
|
metadata: {}
|
@@ -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
|