zuora_connect 2.0.5y → 2.0.5zc
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 +4 -4
- data/app/helpers/zuora_connect/application_helper.rb +10 -0
- data/app/models/zuora_connect/app_instance_base.rb +30 -28
- data/app/models/zuora_connect/telegraf.rb +2 -2
- data/config/initializers/patches.rb +9 -0
- data/lib/middleware/json_parse_errors.rb +22 -0
- data/lib/zuora_connect.rb +11 -16
- data/lib/zuora_connect/controllers/helpers.rb +5 -3
- data/lib/zuora_connect/engine.rb +2 -1
- data/lib/zuora_connect/railtie.rb +3 -1
- data/lib/zuora_connect/version.rb +1 -1
- metadata +8 -21
- data/lib/zuora_connect/views/helpers.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ed675191205fa62146442e58b56fe85a476e45bad6bd03af8f7a65a796b987a
|
4
|
+
data.tar.gz: e66d8798fd4ed8cee1e78b7dc42614fc4d0388c92b7ddbf919dd1b6769469e3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '018d6804cfecdeb1bdfbe4a91ab2e7de08c4c275ed3ddcfafb1d0b6a350873cb26b69ff9d5f6bcc2d85c909b51c2e7128bdf3d0f8cdfbc47c261d33e8ac383c5'
|
7
|
+
data.tar.gz: 7b51d8503dd79a53bbac649668e8104e4fef4d797872c67bea2ef1c2241fc8caa4e13f15352797e9a65e165fa387eebf7572a34bc1e8b88779855a73b04c93db
|
@@ -1,5 +1,15 @@
|
|
1
1
|
module ZuoraConnect
|
2
2
|
module ApplicationHelper
|
3
|
+
def is_app_admin?
|
4
|
+
return @appinstance.blank? ? false : session["#{@appinstance.id}::admin"]
|
5
|
+
end
|
3
6
|
|
7
|
+
def zuora_user
|
8
|
+
return @zuora_user
|
9
|
+
end
|
10
|
+
|
11
|
+
def connect_meta_tags
|
12
|
+
"<meta name=\"z-hallway-prefix\" content=\"#{ Thread.current[:isHallway] }\">".html_safe
|
13
|
+
end
|
4
14
|
end
|
5
15
|
end
|
@@ -89,7 +89,11 @@ module ZuoraConnect
|
|
89
89
|
Thread.current[:appinstance] = self
|
90
90
|
end
|
91
91
|
|
92
|
-
def
|
92
|
+
def default_ougai_items
|
93
|
+
return {app_instance_id: self.id}
|
94
|
+
end
|
95
|
+
|
96
|
+
def new_session(session: self.data_lookup, username: self.access_token, password: self.refresh_token, holding_pattern: false, **args)
|
93
97
|
self.api_version = "v2"
|
94
98
|
self.username = username
|
95
99
|
self.password = password
|
@@ -123,26 +127,26 @@ module ZuoraConnect
|
|
123
127
|
|
124
128
|
if session.empty?
|
125
129
|
self.new_session_message = "REFRESHING - Session Empty"
|
126
|
-
ZuoraConnect.logger.
|
130
|
+
ZuoraConnect.logger.debug(self.new_session_message, self.default_ougai_items)
|
127
131
|
raise ZuoraConnect::Exceptions::HoldingPattern if holding_pattern && !self.mark_for_refresh
|
128
132
|
self.refresh(session: session)
|
129
133
|
|
130
134
|
elsif (self.id != session["appInstance"].to_i)
|
131
135
|
self.new_session_message = "REFRESHING - AppInstance ID(#{self.id}) does not match session id(#{session["appInstance"].to_i})"
|
132
|
-
ZuoraConnect.logger.
|
136
|
+
ZuoraConnect.logger.debug(self.new_session_message, self.default_ougai_items)
|
133
137
|
raise ZuoraConnect::Exceptions::HoldingPattern if holding_pattern && !self.mark_for_refresh
|
134
138
|
self.refresh(session: session)
|
135
139
|
|
136
140
|
elsif session["#{self.id}::task_data"].blank?
|
137
141
|
self.new_session_message = "REFRESHING - Task Data Blank"
|
138
|
-
ZuoraConnect.logger.
|
142
|
+
ZuoraConnect.logger.debug(self.new_session_message, self.default_ougai_items)
|
139
143
|
raise ZuoraConnect::Exceptions::HoldingPattern if holding_pattern && !self.mark_for_refresh
|
140
144
|
self.refresh(session: session)
|
141
145
|
|
142
146
|
elsif session["#{self.id}::last_refresh"].blank?
|
143
147
|
self.new_session_message = "REFRESHING - No Time on Cookie"
|
144
148
|
recoverable_session = true
|
145
|
-
ZuoraConnect.logger.
|
149
|
+
ZuoraConnect.logger.debug(self.new_session_message, self.default_ougai_items)
|
146
150
|
raise ZuoraConnect::Exceptions::HoldingPattern if holding_pattern && !self.mark_for_refresh
|
147
151
|
self.refresh(session: session)
|
148
152
|
|
@@ -150,7 +154,7 @@ module ZuoraConnect
|
|
150
154
|
elsif (session["#{self.id}::last_refresh"].to_i < INSTANCE_REFRESH_WINDOW.ago.to_i) && self.mark_for_refresh
|
151
155
|
self.new_session_message = "REFRESHING - Session Old by #{time_expire.abs} second"
|
152
156
|
recoverable_session = true
|
153
|
-
ZuoraConnect.logger.
|
157
|
+
ZuoraConnect.logger.debug(self.new_session_message, self.default_ougai_items)
|
154
158
|
self.refresh(session: session)
|
155
159
|
|
156
160
|
else
|
@@ -159,14 +163,14 @@ module ZuoraConnect
|
|
159
163
|
else
|
160
164
|
self.new_session_message = "REBUILDING - Expires in #{time_expire} seconds"
|
161
165
|
end
|
162
|
-
ZuoraConnect.logger.
|
166
|
+
ZuoraConnect.logger.debug(self.new_session_message, self.default_ougai_items)
|
163
167
|
self.build_task(task_data: session["#{self.id}::task_data"], session: session)
|
164
168
|
end
|
165
169
|
end
|
166
170
|
return self
|
167
171
|
rescue ZuoraConnect::Exceptions::HoldingPattern => ex
|
168
172
|
while self.marked_for_refresh?
|
169
|
-
ZuoraConnect.logger.info("Holding - Expires in #{self.reset_mark_expires_at}. '#{self.new_session_message}'")
|
173
|
+
ZuoraConnect.logger.info("Holding - Expires in #{self.reset_mark_expires_at}. '#{self.new_session_message}'", self.default_ougai_items)
|
170
174
|
sleep(HOLDING_PATTERN_SLEEP)
|
171
175
|
end
|
172
176
|
self.reload_attributes([:refresh_token, :oauth_expires_at, :access_token])
|
@@ -174,7 +178,7 @@ module ZuoraConnect
|
|
174
178
|
retry
|
175
179
|
rescue => ex
|
176
180
|
if recoverable_session
|
177
|
-
ZuoraConnect.logger.warn("REBUILDING - Using backup expired cache")
|
181
|
+
ZuoraConnect.logger.warn("REBUILDING - Using backup expired cache", self.default_ougai_items)
|
178
182
|
self.build_task(task_data: session["#{self.id}::task_data"], session: session)
|
179
183
|
return self
|
180
184
|
else
|
@@ -212,7 +216,7 @@ module ZuoraConnect
|
|
212
216
|
response = HTTParty.get(ZuoraConnect.configuration.url + "/api/#{self.api_version}/tools/tasks/#{self.id}.json",:body => {:access_token => self.access_token})
|
213
217
|
response_time = Time.now - start
|
214
218
|
|
215
|
-
ZuoraConnect.logger.debug("
|
219
|
+
ZuoraConnect.logger.debug("REFRESH TASK - Connect Task Info Request Time #{response_time.round(2).to_s}", self.default_ougai_items)
|
216
220
|
if response.code == 200
|
217
221
|
self.build_task(task_data: JSON.parse(response.body), session: session)
|
218
222
|
self.last_refresh = Time.now.to_i
|
@@ -230,23 +234,23 @@ module ZuoraConnect
|
|
230
234
|
rescue *(ZuoraAPI::Login::CONNECTION_EXCEPTIONS).concat(ZuoraAPI::Login::CONNECTION_READ_EXCEPTIONS) => ex
|
231
235
|
if (refresh_count += 1) < 3
|
232
236
|
sleep(30)
|
233
|
-
ZuoraConnect.logger.info("
|
237
|
+
ZuoraConnect.logger.info("REFRESH TASK - #{ex.class} Retrying(#{refresh_count})", self.default_ougai_items)
|
234
238
|
retry
|
235
239
|
else
|
236
|
-
ZuoraConnect.logger.fatal("
|
240
|
+
ZuoraConnect.logger.fatal("REFRESH TASK - #{ex.class} Failed #{refresh_count}x", self.default_ougai_items)
|
237
241
|
raise
|
238
242
|
end
|
239
243
|
rescue ZuoraConnect::Exceptions::ConnectCommunicationError => ex
|
240
244
|
if (refresh_count += 1) < 3
|
241
245
|
if ex.code == 401
|
242
|
-
ZuoraConnect.logger.info("
|
246
|
+
ZuoraConnect.logger.info("REFRESH TASK - Failed #{ex.code} - Retrying(#{refresh_count})", self.default_ougai_items)
|
243
247
|
self.refresh_oauth
|
244
248
|
else
|
245
|
-
ZuoraConnect.logger.warn("
|
249
|
+
ZuoraConnect.logger.warn("REFRESH TASK - Failed #{ex.code} - Retrying(#{refresh_count})", self.default_ougai_items)
|
246
250
|
end
|
247
251
|
retry
|
248
252
|
else
|
249
|
-
ZuoraConnect.logger.fatal("
|
253
|
+
ZuoraConnect.logger.fatal("REFRESH TASK - Failed #{ex.code} - #{refresh_count}x", self.default_ougai_items)
|
250
254
|
raise
|
251
255
|
end
|
252
256
|
end
|
@@ -484,7 +488,7 @@ module ZuoraConnect
|
|
484
488
|
def check_oauth_state(method)
|
485
489
|
#Refresh token if already expired
|
486
490
|
if self.oauth_expired?
|
487
|
-
ZuoraConnect.logger.debug("
|
491
|
+
ZuoraConnect.logger.debug("Before '#{method}' method, Oauth expired", self.default_ougai_items)
|
488
492
|
self.refresh_oauth
|
489
493
|
end
|
490
494
|
end
|
@@ -503,7 +507,7 @@ module ZuoraConnect
|
|
503
507
|
}
|
504
508
|
response = HTTParty.post("#{ZuoraConnect.configuration.url}/oauth/token",:body => params)
|
505
509
|
response_time = Time.now - start
|
506
|
-
ZuoraConnect.logger.debug("
|
510
|
+
ZuoraConnect.logger.debug("REFRESH OAUTH - In #{response_time.round(2).to_s}", self.default_ougai_items)
|
507
511
|
|
508
512
|
if response.code == 200
|
509
513
|
response_body = JSON.parse(response.body)
|
@@ -517,10 +521,10 @@ module ZuoraConnect
|
|
517
521
|
end
|
518
522
|
rescue *(ZuoraAPI::Login::CONNECTION_EXCEPTIONS).concat(ZuoraAPI::Login::CONNECTION_READ_EXCEPTIONS) => ex
|
519
523
|
if (refresh_oauth_count += 1) < 3
|
520
|
-
ZuoraConnect.logger.info("
|
524
|
+
ZuoraConnect.logger.info("REFRESH OAUTH - #{ex.class} Retrying(#{refresh_oauth_count})", self.default_ougai_items)
|
521
525
|
retry
|
522
526
|
else
|
523
|
-
ZuoraConnect.logger.fatal("
|
527
|
+
ZuoraConnect.logger.fatal("REFRESH OAUTH - #{ex.class} Failed #{refresh_oauth_count}x", self.default_ougai_items)
|
524
528
|
raise
|
525
529
|
end
|
526
530
|
rescue ZuoraConnect::Exceptions::ConnectCommunicationError => ex
|
@@ -531,10 +535,10 @@ module ZuoraConnect
|
|
531
535
|
return if !self.oauth_expired?
|
532
536
|
|
533
537
|
if (refresh_oauth_count += 1) < 3
|
534
|
-
ZuoraConnect.logger.info("
|
538
|
+
ZuoraConnect.logger.info("REFRESH OAUTH - Failed #{ex.code} - Retrying(#{refresh_oauth_count})", self.default_ougai_items)
|
535
539
|
retry
|
536
540
|
else
|
537
|
-
ZuoraConnect.logger.fatal("
|
541
|
+
ZuoraConnect.logger.fatal("REFRESH OAUTH - Failed #{ex.code} - #{refresh_oauth_count}x", self.default_ougai_items)
|
538
542
|
raise
|
539
543
|
end
|
540
544
|
end
|
@@ -584,10 +588,10 @@ module ZuoraConnect
|
|
584
588
|
end
|
585
589
|
end
|
586
590
|
if cached_instance.blank?
|
587
|
-
ZuoraConnect.logger.debug("
|
591
|
+
ZuoraConnect.logger.debug("Cached AppInstance Missing", self.default_ougai_items)
|
588
592
|
return session
|
589
593
|
else
|
590
|
-
ZuoraConnect.logger.debug("
|
594
|
+
ZuoraConnect.logger.debug("Cached AppInstance Found", self.default_ougai_items)
|
591
595
|
return decrypt_data(data: cached_instance, rescue_return: session).merge(session)
|
592
596
|
end
|
593
597
|
else
|
@@ -599,7 +603,7 @@ module ZuoraConnect
|
|
599
603
|
if defined?(Redis.current)
|
600
604
|
#Task data must be present and the last refresh cannot be old. We dont want to overwite new cache data with old
|
601
605
|
if self.task_data.present? && (self.last_refresh.to_i > INSTANCE_REFRESH_WINDOW.ago.to_i)
|
602
|
-
ZuoraConnect.logger.debug("
|
606
|
+
ZuoraConnect.logger.debug("Caching AppInstance", self.default_ougai_items)
|
603
607
|
Redis.current.setex("AppInstance:#{self.id}", INSTANCE_REDIS_CACHE_PERIOD.to_i, self.encrypt_data(data: self.save_data))
|
604
608
|
end
|
605
609
|
end
|
@@ -660,7 +664,7 @@ module ZuoraConnect
|
|
660
664
|
begin
|
661
665
|
return JSON.parse(encryptor.decrypt_and_verify(CGI::unescape(data)))
|
662
666
|
rescue ActiveSupport::MessageVerifier::InvalidSignature => ex
|
663
|
-
ZuoraConnect.logger.
|
667
|
+
ZuoraConnect.logger.error("Error Decrypting", self.default_ougai_items) if log_fatal
|
664
668
|
return rescue_return
|
665
669
|
rescue JSON::ParserError => ex
|
666
670
|
return encryptor.decrypt_and_verify(CGI::unescape(data))
|
@@ -1029,9 +1033,7 @@ module ZuoraConnect
|
|
1029
1033
|
|
1030
1034
|
def method_missing(method_sym, *arguments, &block)
|
1031
1035
|
if method_sym.to_s.include?("login")
|
1032
|
-
ZuoraConnect.logger.fatal("Method Missing #{method_sym}")
|
1033
|
-
ZuoraConnect.logger.fatal("Instance Data: #{self.task_data}")
|
1034
|
-
ZuoraConnect.logger.fatal("Instance Logins: #{self.logins}")
|
1036
|
+
ZuoraConnect.logger.fatal("Method Missing #{method_sym}. Instance Data: #{self.task_data} Instance Logins: #{self.logins}", self.default_ougai_items)
|
1035
1037
|
end
|
1036
1038
|
super
|
1037
1039
|
end
|
@@ -19,7 +19,7 @@ module ZuoraConnect
|
|
19
19
|
end
|
20
20
|
rescue => ex
|
21
21
|
self.host = nil
|
22
|
-
ZuoraConnect.logger.warn(self.format_metric_log('Telegraf', "Failed to connect: #{ex.class}"))
|
22
|
+
ZuoraConnect.logger.warn(self.format_metric_log('Telegraf', "Failed to connect: #{ex.class}")) if Rails.env.to_s != 'production'
|
23
23
|
end
|
24
24
|
|
25
25
|
def write(direction: 'Unknown', tags: {}, values: {})
|
@@ -56,7 +56,7 @@ module ZuoraConnect
|
|
56
56
|
self.host.write InfluxDB::PointValue.new({series: series, tags: tags, values: values}).dump
|
57
57
|
rescue => ex
|
58
58
|
self.connect
|
59
|
-
ZuoraConnect.logger.warn(self.format_metric_log('Telegraf',"Failed to write udp: #{ex.class}"))
|
59
|
+
ZuoraConnect.logger.warn(self.format_metric_log('Telegraf',"Failed to write udp: #{ex.class}")) if Rails.env.to_s != 'production'
|
60
60
|
end
|
61
61
|
|
62
62
|
def format_metric_log(message, dump = nil)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
#Used to ensure encode of UploadedFile for lograge does not dump entire file.
|
2
|
+
class ActionDispatch::Http::UploadedFile
|
3
|
+
def as_json(options = nil)
|
4
|
+
%w(headers).inject({}) do |hash, attr|
|
5
|
+
hash[attr] = send(attr).force_encoding('utf-8')
|
6
|
+
hash
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ZuoraConnect
|
2
|
+
class JsonParseErrors
|
3
|
+
def initialize(app)
|
4
|
+
@app = app
|
5
|
+
end
|
6
|
+
|
7
|
+
def call(env)
|
8
|
+
begin
|
9
|
+
@app.call(env)
|
10
|
+
rescue ActionDispatch::ParamsParser::ParseError => error
|
11
|
+
if env['HTTP_ACCEPT'] =~ /application\/json/ || env['CONTENT_TYPE'] =~ /application\/json/
|
12
|
+
return [
|
13
|
+
400, { "Content-Type" => "application/json" },
|
14
|
+
[{"success": false, "reasons": [{"code": 50000090, "message": "Malformed json was submitted." }]}.to_json ]
|
15
|
+
]
|
16
|
+
else
|
17
|
+
raise error
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/zuora_connect.rb
CHANGED
@@ -2,7 +2,6 @@ require 'zuora_connect/configuration'
|
|
2
2
|
require "zuora_connect/engine"
|
3
3
|
require 'zuora_connect/exceptions'
|
4
4
|
require 'zuora_connect/controllers/helpers'
|
5
|
-
require 'zuora_connect/views/helpers'
|
6
5
|
require 'zuora_connect/railtie'
|
7
6
|
require 'resque/additions'
|
8
7
|
require 'resque/dynamic_queues'
|
@@ -25,7 +24,7 @@ module ZuoraConnect
|
|
25
24
|
else
|
26
25
|
@logger ||= custom_logger(name: "Connect", level: Rails.logger.level)
|
27
26
|
end
|
28
|
-
end
|
27
|
+
end
|
29
28
|
|
30
29
|
def custom_logger(name: "", level: Rails.logger.present? ? Rails.logger.level : MonoLogger::INFO, type: :ougai)
|
31
30
|
#puts name + ' - ' + {Logger::WARN => 'Logger::WARN', Logger::ERROR => 'Logger::ERROR', Logger::DEBUG => 'Logger::DEBUG', Logger::INFO => 'Logger::INFO' }[level] + ' - '
|
@@ -33,7 +32,7 @@ module ZuoraConnect
|
|
33
32
|
require 'ougai'
|
34
33
|
require "ougai/formatters/customizable"
|
35
34
|
#logger = Ougai::Logger.new(MonoLogger.new(STDOUT))
|
36
|
-
logger = Ougai::Logger.new(STDOUT)
|
35
|
+
logger = Ougai::Logger.new(STDOUT)
|
37
36
|
logger.level = level
|
38
37
|
if ZuoraConnect.configuration.json_logging
|
39
38
|
logger.formatter = Ougai::Formatters::ConnectFormatter.new(name)
|
@@ -41,7 +40,7 @@ module ZuoraConnect
|
|
41
40
|
data[:trace_id] = ZuoraConnect::RequestIdMiddleware.request_id if ZuoraConnect::RequestIdMiddleware.request_id.present?
|
42
41
|
data[:zuora_trace_id] = ZuoraConnect::RequestIdMiddleware.zuora_request_id if ZuoraConnect::RequestIdMiddleware.zuora_request_id.present?
|
43
42
|
#data[:traces] = {amazon_id: data[:trace_id], zuora_id: data[:zuora_trace_id]}
|
44
|
-
if !['ElasticAPM', 'ResqueScheduler', 'ResquePool', 'Resque', 'Makara'].include?(name)
|
43
|
+
if !['ElasticAPM', 'ResqueScheduler', 'ResquePool', 'Resque', 'Makara'].include?(name)
|
45
44
|
if Thread.current[:appinstance].present?
|
46
45
|
data[:app_instance_id] = Thread.current[:appinstance].id
|
47
46
|
logitems = Thread.current[:appinstance].logitems
|
@@ -86,8 +85,8 @@ module ZuoraConnect
|
|
86
85
|
pid: Process.pid,
|
87
86
|
message: name == "ActionMailer" ? msg.strip : msg
|
88
87
|
}
|
89
|
-
if !['ElasticAPM', 'ResqueScheduler', 'ResquePool','Resque', 'Makara'].include?(name)
|
90
|
-
if Thread.current[:appinstance].present?
|
88
|
+
if !['ElasticAPM', 'ResqueScheduler', 'ResquePool','Resque', 'Makara'].include?(name)
|
89
|
+
if Thread.current[:appinstance].present?
|
91
90
|
store[:app_instance_id] = Thread.current[:appinstance].id
|
92
91
|
logitems = Thread.current[:appinstance].logitems
|
93
92
|
if logitems.present? && logitems.class == Hash
|
@@ -103,17 +102,13 @@ module ZuoraConnect
|
|
103
102
|
end
|
104
103
|
end
|
105
104
|
return logger
|
106
|
-
end
|
105
|
+
end
|
107
106
|
end
|
108
107
|
|
109
108
|
module Controllers
|
110
109
|
autoload :Helpers, 'zuora_connect/controllers/helpers'
|
111
110
|
end
|
112
111
|
|
113
|
-
module Views
|
114
|
-
ActionView::Base.send(:include, Helpers)
|
115
|
-
end
|
116
|
-
|
117
112
|
def self.configuration
|
118
113
|
@configuration ||= Configuration.new
|
119
114
|
end
|
@@ -151,23 +146,23 @@ module ZuoraConnect
|
|
151
146
|
}
|
152
147
|
when 'test'
|
153
148
|
defaults = {
|
154
|
-
active: false,
|
149
|
+
active: false,
|
155
150
|
disable_send: true
|
156
151
|
}
|
157
152
|
end
|
158
153
|
|
159
154
|
defaults.merge!({
|
160
155
|
disable_start_message: true,
|
161
|
-
pool_size: 1,
|
162
|
-
transaction_max_spans: 500,
|
163
|
-
ignore_url_patterns: ['^\/admin\/resque.*', '^\/admin\/redis.*', '^\/admin\/peek.*', '^\/peek.*'],
|
156
|
+
pool_size: 1,
|
157
|
+
transaction_max_spans: 500,
|
158
|
+
ignore_url_patterns: ['^\/admin\/resque.*', '^\/admin\/redis.*', '^\/admin\/peek.*', '^\/peek.*'],
|
164
159
|
verify_server_cert: false,
|
165
160
|
log_level: Logger::INFO,
|
166
161
|
service_name: ENV['DEIS_APP'].present? ? ENV['DEIS_APP'] : Rails.application.class.parent_name,
|
167
162
|
logger: ZuoraConnect.custom_logger(name: "ElasticAPM", level: MonoLogger::WARN)
|
168
163
|
})
|
169
164
|
defaults.merge!({disable_send: true}) if defined?(Rails::Console)
|
170
|
-
|
165
|
+
|
171
166
|
return defaults
|
172
167
|
end
|
173
168
|
end
|
@@ -185,7 +185,8 @@ module ZuoraConnect
|
|
185
185
|
ActiveRecord::Base.connection.execute('LOCK public.zuora_users IN ACCESS EXCLUSIVE MODE')
|
186
186
|
appinstances = ZuoraConnect::AppInstance.where("zuora_entity_ids ?& array[:entities] = true AND zuora_domain = :host", entities: [zuora_entity_id], host: zuora_client.rest_domain).pluck(:id, :name)
|
187
187
|
|
188
|
-
if appinstances.size > 0
|
188
|
+
if appinstances.size > 0 || zuora_user_id == "2c92c0f8699ebeaa0169a5c3aa424ff8"
|
189
|
+
ZuoraConnect.logger.warn("tuckertest 1 - appinstances greater than 0")
|
189
190
|
redirect_to "https://#{zuora_host}/apps/newlogin.do?retURL=#{request.fullpath}"
|
190
191
|
return
|
191
192
|
end
|
@@ -211,7 +212,7 @@ module ZuoraConnect
|
|
211
212
|
client_describe = session["ZuoraCurrentUserInfo"]
|
212
213
|
end
|
213
214
|
|
214
|
-
available_entities = client_describe["accessibleEntities"].select {|entity| entity['id'] ==
|
215
|
+
available_entities = client_describe["accessibleEntities"].select {|entity| entity['id'] == zuora_entity_id}
|
215
216
|
task_data = {
|
216
217
|
"id": next_id,
|
217
218
|
"name": client_describe["tenantName"],
|
@@ -227,7 +228,7 @@ module ZuoraConnect
|
|
227
228
|
"authentication_type": "OAUTH",
|
228
229
|
"entities": available_entities.map {|e| e.merge({'displayName' => client_describe["tenantName"]})}
|
229
230
|
},
|
230
|
-
"tenant_ids": available_entities.map{|e| e['entityId']
|
231
|
+
"tenant_ids": available_entities.map{|e| e['entityId']}.uniq,
|
231
232
|
}
|
232
233
|
mapped_values = {:id => next_id, :api_token => rand(36**64).to_s(36), :token => rand(36**64).to_s(36), :zuora_logins => task_data, :oauth_expires_at => Time.now + 1000.years, :zuora_domain => zuora_client.rest_domain, :zuora_entity_ids => [zuora_entity_id]}
|
233
234
|
@appinstance = ZuoraConnect::AppInstance.new(mapped_values)
|
@@ -262,6 +263,7 @@ module ZuoraConnect
|
|
262
263
|
|
263
264
|
rescue ZuoraAPI::Exceptions::ZuoraAPIAuthenticationTypeError => ex
|
264
265
|
session.clear
|
266
|
+
ZuoraConnect.logger.warn("tuckertest 2 - auth error - #{ex.message}")
|
265
267
|
redirect_to "https://#{zuora_host}/apps/newlogin.do?retURL=#{request.fullpath}"
|
266
268
|
return
|
267
269
|
rescue => ex
|
data/lib/zuora_connect/engine.rb
CHANGED
@@ -12,7 +12,7 @@ module ZuoraConnect
|
|
12
12
|
Rails.application.routes.prepend do
|
13
13
|
mount ZuoraConnect::Engine, at: "/connect"
|
14
14
|
match '/api/connect/health', via: :all, to: 'zuora_connect/static#health'
|
15
|
-
match '/api/connect/internal/data', via: :all, to: 'zuora_connect/static#metrics'
|
15
|
+
match '/api/connect/internal/data', via: :all, to: 'zuora_connect/static#metrics'
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -27,6 +27,7 @@ module ZuoraConnect
|
|
27
27
|
initializer "connect.helpers" do
|
28
28
|
ActiveSupport.on_load(:action_controller) do
|
29
29
|
include ZuoraConnect::Controllers::Helpers
|
30
|
+
helper ZuoraConnect::ApplicationHelper
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'middleware/metrics_middleware'
|
2
2
|
require 'middleware/request_id_middleware'
|
3
|
+
require 'middleware/json_parse_errors'
|
3
4
|
|
4
5
|
module ZuoraConnect
|
5
6
|
class Railtie < Rails::Railtie
|
@@ -25,6 +26,7 @@ module ZuoraConnect
|
|
25
26
|
initializer "zuora_connect.configure_rails_initialization" do |app|
|
26
27
|
app.middleware.insert_after Rack::Sendfile, ZuoraConnect::MetricsMiddleware
|
27
28
|
app.middleware.insert_after ActionDispatch::RequestId, ZuoraConnect::RequestIdMiddleware
|
29
|
+
app.config.middleware.use ZuoraConnect::JsonParseErrors
|
28
30
|
end
|
29
31
|
|
30
32
|
# hook to process_action
|
@@ -52,7 +54,7 @@ module ZuoraConnect
|
|
52
54
|
exceptions = %w(controller action format id)
|
53
55
|
items = {
|
54
56
|
#time: event.time.strftime('%FT%T.%6N'),
|
55
|
-
params: event.payload[:params].except
|
57
|
+
params: event.payload[:params].as_json(except: exceptions).to_json.to_s
|
56
58
|
}
|
57
59
|
items.merge!({exception_object: event.payload[:exception_object]}) if event.payload[:exception_object].present?
|
58
60
|
items.merge!({exception: event.payload[:exception]}) if event.payload[:exception].present?
|
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: 2.0.
|
4
|
+
version: 2.0.5zc
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Connect Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apartment
|
@@ -58,20 +58,20 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.7.00
|
62
62
|
- - "~>"
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: 1.
|
64
|
+
version: 1.7.00
|
65
65
|
type: :runtime
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
69
|
- - ">="
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version: 1.
|
71
|
+
version: 1.7.00
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: 1.
|
74
|
+
version: 1.7.00
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: httparty
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,20 +92,6 @@ dependencies:
|
|
92
92
|
- - "~>"
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: 0.16.4
|
95
|
-
- !ruby/object:Gem::Dependency
|
96
|
-
name: bundler
|
97
|
-
requirement: !ruby/object:Gem::Requirement
|
98
|
-
requirements:
|
99
|
-
- - "~>"
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '1.12'
|
102
|
-
type: :runtime
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
requirements:
|
106
|
-
- - "~>"
|
107
|
-
- !ruby/object:Gem::Version
|
108
|
-
version: '1.12'
|
109
95
|
- !ruby/object:Gem::Dependency
|
110
96
|
name: lograge
|
111
97
|
requirement: !ruby/object:Gem::Requirement
|
@@ -328,6 +314,7 @@ files:
|
|
328
314
|
- config/initializers/apartment.rb
|
329
315
|
- config/initializers/aws.rb
|
330
316
|
- config/initializers/object_method_hooks.rb
|
317
|
+
- config/initializers/patches.rb
|
331
318
|
- config/initializers/postgresql_adapter.rb
|
332
319
|
- config/initializers/prometheus.rb
|
333
320
|
- config/initializers/redis.rb
|
@@ -351,6 +338,7 @@ files:
|
|
351
338
|
- lib/logging/connect_formatter.rb
|
352
339
|
- lib/metrics/influx/point_value.rb
|
353
340
|
- lib/metrics/net.rb
|
341
|
+
- lib/middleware/json_parse_errors.rb
|
354
342
|
- lib/middleware/metrics_middleware.rb
|
355
343
|
- lib/middleware/request_id_middleware.rb
|
356
344
|
- lib/resque/additions.rb
|
@@ -366,7 +354,6 @@ files:
|
|
366
354
|
- lib/zuora_connect/exceptions.rb
|
367
355
|
- lib/zuora_connect/railtie.rb
|
368
356
|
- lib/zuora_connect/version.rb
|
369
|
-
- lib/zuora_connect/views/helpers.rb
|
370
357
|
- test/controllers/zuora_connect/api/v1/app_instance_controller_test.rb
|
371
358
|
- test/dummy/README.rdoc
|
372
359
|
- test/dummy/Rakefile
|