zuora_connect 3.1.1 → 3.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/zuora_connect/static_controller.rb +38 -4
- data/app/models/zuora_connect/app_instance_base.rb +33 -33
- data/config/routes.rb +1 -0
- data/lib/middleware/metrics_middleware.rb +1 -1
- data/lib/tasks/zuora_connect_tasks.rake +12 -9
- data/lib/zuora_connect/version.rb +1 -1
- data/lib/zuora_connect.rb +7 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 669d11bc2e10ece9fb5f4d014b412739545cf7d17c6858b0588f8d6c566be41e
|
4
|
+
data.tar.gz: a077b09e7c4e5e3bdb10742c99100a11842d6d5bb31ca520a97d44c8e9ac51c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b043fa5b788040e781843eb2c2f20aba5a7b2d1f8d014e89ac31aa3574a451473dd1d89a08d479f71215f6f386d288e5fdb315316fcf31de8121d39224778d7c
|
7
|
+
data.tar.gz: f151cb64ecddc869299c25f9a1012601ededb097e469fd86a060ca0c8b82e074559df24724600880a8afea9f3995550c9c504af311d1e24248fbdcfaa6013197
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module ZuoraConnect
|
2
2
|
class StaticController < ApplicationController
|
3
|
-
before_action :authenticate_connect_app_request, :except => [:health, :initialize_app, :provision, :instance_user]
|
4
|
-
before_action :clear_connect_app_session, :only => [:health, :initialize_app, :provision, :instance_user]
|
5
|
-
after_action :persist_connect_app_session, :except => [:health, :initialize_app, :provision, :instance_user]
|
3
|
+
before_action :authenticate_connect_app_request, :except => [:health, :initialize_app, :provision, :instance_user, :instance_drop]
|
4
|
+
before_action :clear_connect_app_session, :only => [:health, :initialize_app, :provision, :instance_user, :instance_drop]
|
5
|
+
after_action :persist_connect_app_session, :except => [:health, :initialize_app, :provision, :instance_user, :instance_drop]
|
6
6
|
|
7
7
|
skip_before_action :verify_authenticity_token, :only => [:initialize_app, :provision]
|
8
|
-
http_basic_authenticate_with name: ENV['PROVISION_USER'], password: ENV['PROVISION_SECRET'], :only => [:provision, :instance_user]
|
8
|
+
http_basic_authenticate_with name: ENV['PROVISION_USER'], password: ENV['PROVISION_SECRET'], :only => [:provision, :instance_user, :instance_drop]
|
9
9
|
|
10
10
|
|
11
11
|
def health
|
@@ -119,6 +119,40 @@ module ZuoraConnect
|
|
119
119
|
}, status: 500
|
120
120
|
end
|
121
121
|
|
122
|
+
def instance_drop
|
123
|
+
ZuoraConnect::AppInstance.read_master_db do
|
124
|
+
instance_id = params[:id]
|
125
|
+
@appinstance = ZuoraConnect::AppInstance.find(instance_id)
|
126
|
+
if @appinstance.drop_instance
|
127
|
+
ZuoraConnect::AppInstance.destroy(instance_id)
|
128
|
+
msg = Apartment::Tenant.drop(instance_id)
|
129
|
+
|
130
|
+
if msg.error_message.present?
|
131
|
+
render json: { "message" => msg.error_message }, status: :bad_request
|
132
|
+
else
|
133
|
+
render json: {
|
134
|
+
status: 200,
|
135
|
+
message: 'Success',
|
136
|
+
app_instance_id: instance_id
|
137
|
+
}, status: 200
|
138
|
+
end
|
139
|
+
else
|
140
|
+
render json: { "message" => @appinstance.drop_message }, status: :bad_request
|
141
|
+
end
|
142
|
+
end
|
143
|
+
rescue StandardError => e
|
144
|
+
message = 'Failed to drop instance'
|
145
|
+
if performed?
|
146
|
+
Rails.logger.error("#{message}: #{performed?}", e)
|
147
|
+
else
|
148
|
+
Rails.logger.error(message, e)
|
149
|
+
render json: {
|
150
|
+
status: 500,
|
151
|
+
message: message
|
152
|
+
}, status: 500
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
122
156
|
private
|
123
157
|
|
124
158
|
def clear_connect_app_session
|
@@ -353,8 +353,10 @@ module ZuoraConnect
|
|
353
353
|
end
|
354
354
|
|
355
355
|
def fetch_connect_data(session: {})
|
356
|
+
refresh_count ||= 0
|
356
357
|
self.check_oauth_state
|
357
|
-
|
358
|
+
request_url = ZuoraConnect.configuration.url + "/api/#{self.api_version}/tools/tasks/#{self.id}.json"
|
359
|
+
response = HTTParty.get(request_url,:body => {:access_token => self.access_token})
|
358
360
|
|
359
361
|
if response.code == 200
|
360
362
|
begin
|
@@ -367,45 +369,43 @@ module ZuoraConnect
|
|
367
369
|
self.set_backup_creds
|
368
370
|
self.save(validate: false) if self.changed?
|
369
371
|
else
|
370
|
-
raise ZuoraConnect::Exceptions::ConnectCommunicationError.new("Error
|
372
|
+
raise ZuoraConnect::Exceptions::ConnectCommunicationError.new("Error communicating with Connect for '#{request_url}' with #{response.code}", response.body, response.code)
|
373
|
+
end
|
374
|
+
rescue *(ZuoraAPI::Login::CONNECTION_EXCEPTIONS + ZuoraAPI::Login::CONNECTION_READ_EXCEPTIONS) => ex
|
375
|
+
refresh_count += 1
|
376
|
+
if refresh_count < 3
|
377
|
+
sleep(10)
|
378
|
+
ZuoraConnect.logger.debug("REFRESH TASK - Connection Failure Retrying(#{refresh_count})", ex, self.default_ougai_items)
|
379
|
+
retry
|
380
|
+
else
|
381
|
+
ZuoraConnect.logger.fatal("REFRESH TASK - Connection Failed", ex)
|
382
|
+
raise
|
383
|
+
end
|
384
|
+
rescue ZuoraConnect::Exceptions::ConnectCommunicationError => ex
|
385
|
+
refresh_count += 1
|
386
|
+
if refresh_count < 3
|
387
|
+
ZuoraConnect.logger.debug("REFRESH TASK - Communication Failure Retrying(#{refresh_count})", ex, self.default_ougai_items)
|
388
|
+
self.refresh_oauth if ex.code == 401
|
389
|
+
retry
|
390
|
+
else
|
391
|
+
ZuoraConnect.logger.fatal("REFRESH TASK - Communication Failed #{ex.code}", ex, self.default_ougai_items)
|
392
|
+
raise
|
371
393
|
end
|
372
394
|
end
|
373
395
|
|
374
|
-
|
375
396
|
def refresh(session: {})
|
376
397
|
refresh_count ||= 0
|
377
398
|
skip_connect ||= ZuoraConnect.configuration.skip_connect
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
self.build_task(task_data: self.zuora_logins, session: session)
|
384
|
-
end
|
385
|
-
self.last_refresh = Time.now.to_i
|
386
|
-
self.cache_app_instance
|
387
|
-
self.reset_mark_for_refresh
|
388
|
-
rescue *(ZuoraAPI::Login::CONNECTION_EXCEPTIONS + ZuoraAPI::Login::CONNECTION_READ_EXCEPTIONS) => ex
|
389
|
-
refresh_count += 1
|
390
|
-
if refresh_count < 3
|
391
|
-
sleep(10)
|
392
|
-
ZuoraConnect.logger.debug("REFRESH TASK - Connection Failure Retrying(#{refresh_count})", ex, self.default_ougai_items)
|
393
|
-
retry
|
394
|
-
else
|
395
|
-
ZuoraConnect.logger.fatal("REFRESH TASK - Connection Failed", ex)
|
396
|
-
raise
|
397
|
-
end
|
398
|
-
rescue ZuoraConnect::Exceptions::ConnectCommunicationError => ex
|
399
|
-
refresh_count += 1
|
400
|
-
if refresh_count < 3
|
401
|
-
ZuoraConnect.logger.debug("REFRESH TASK - Communication Failure Retrying(#{refresh_count})", ex, self.default_ougai_items)
|
402
|
-
self.refresh_oauth if ex.code == 401
|
403
|
-
retry
|
404
|
-
else
|
405
|
-
ZuoraConnect.logger.fatal("REFRESH TASK - Communication Failed #{ex.code}", ex, self.default_ougai_items)
|
406
|
-
raise
|
407
|
-
end
|
399
|
+
#Check how app was deployed
|
400
|
+
if !self.auto_deployed? && (!skip_connect || self['zuora_logins'].blank?)
|
401
|
+
self.fetch_connect_data(session: session)
|
402
|
+
else
|
403
|
+
self.build_task(task_data: self.zuora_logins, session: session)
|
408
404
|
end
|
405
|
+
self.last_refresh = Time.now.to_i
|
406
|
+
self.cache_app_instance
|
407
|
+
self.reset_mark_for_refresh
|
408
|
+
|
409
409
|
rescue => ex
|
410
410
|
refresh_count += 1
|
411
411
|
if self['zuora_logins'].present? && refresh_count < 3
|
data/config/routes.rb
CHANGED
@@ -42,7 +42,7 @@ module ZuoraConnect
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def call(env)
|
45
|
-
@bad_headers = ["
|
45
|
+
@bad_headers = ["HTTP_X_FORWARDED_HOST", "HTTP_X_FORWARDED_PORT", "HTTP_X_FORWARDED_PROTO", "HTTP_X_FORWARDED_SCHEME", "HTTP_X_FORWARDED_SSL"]
|
46
46
|
if !ActionDispatch::Request::HTTP_METHODS.include?(env["REQUEST_METHOD"].upcase)
|
47
47
|
[405, {"Content-Type" => "text/plain"}, ["Method Not Allowed"]]
|
48
48
|
else
|
@@ -2,15 +2,18 @@ namespace :db do
|
|
2
2
|
desc 'Also create shared_extensions Schema'
|
3
3
|
task :extensions => :environment do
|
4
4
|
# Create Schema
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp" SCHEMA shared_extensions;'
|
11
|
-
}
|
5
|
+
ActiveRecord::Base.connection.execute 'CREATE SCHEMA IF NOT EXISTS shared_extensions;'
|
6
|
+
# Enable Hstore
|
7
|
+
ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS HSTORE SCHEMA shared_extensions;'
|
8
|
+
# Enable UUID-OSSP
|
9
|
+
ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp" SCHEMA shared_extensions;'
|
12
10
|
end
|
13
11
|
end
|
14
12
|
|
15
|
-
Rake::Task["db:create"].enhance
|
16
|
-
Rake::Task["db:
|
13
|
+
Rake::Task["db:create"].enhance do
|
14
|
+
Rake::Task["db:extensions"].invoke
|
15
|
+
end
|
16
|
+
|
17
|
+
Rake::Task["db:test:purge"].enhance do
|
18
|
+
Rake::Task["db:extensions"].invoke
|
19
|
+
end
|
data/lib/zuora_connect.rb
CHANGED
@@ -65,13 +65,15 @@ module ZuoraConnect
|
|
65
65
|
case Rails.env.to_s
|
66
66
|
when 'production'
|
67
67
|
defaults = {
|
68
|
-
server_url: "
|
68
|
+
server_url: "https://apm-server.logging.svc.cluster.local:8200",
|
69
|
+
secret_token:'afhfkulsahgcanriu2c7n8638w59cb67572YCAFAF38839095253',
|
69
70
|
transaction_sample_rate: 0.20,
|
70
71
|
capture_body: 'errors'
|
71
72
|
}
|
72
73
|
when 'staging'
|
73
74
|
defaults = {
|
74
|
-
server_url: "
|
75
|
+
server_url: "https://apm-server.logging.svc.cluster.local:8200",
|
76
|
+
secret_token:'afhfkulsahgcanriu2c7n8638w59cb67572YCAFAF38839095253',
|
75
77
|
transaction_sample_rate: 1.0
|
76
78
|
}
|
77
79
|
when 'development'
|
@@ -90,9 +92,10 @@ module ZuoraConnect
|
|
90
92
|
disable_start_message: true,
|
91
93
|
pool_size: 1,
|
92
94
|
transaction_max_spans: 500,
|
93
|
-
|
95
|
+
ignore_url_patterns: ['^\/admin\/resque.*', '^\/admin\/redis.*', '^\/admin\/peek.*', '^\/peek.*'],
|
94
96
|
verify_server_cert: false,
|
95
|
-
log_level: Logger::
|
97
|
+
log_level: Logger::WARN,
|
98
|
+
service_version: ENV['Z_APPLICATION_VERSION'].present? ? ENV['Z_APPLICATION_VERSION'] : '0.0.0',
|
96
99
|
service_name: ENV['DEIS_APP'].present? ? ENV['DEIS_APP'] : ZuoraConnect.app_name,
|
97
100
|
logger: ZuoraObservability::Logger.custom_logger(name: "ElasticAPM", level: Logger::WARN)
|
98
101
|
})
|
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.1.
|
4
|
+
version: 3.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Connect Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apartment
|