zuora_connect 2.0.3d → 2.0.3e

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfd7b54383b6874940e04ea6b555727f24de82fa9e5879e4ebd146cd79b1406c
4
- data.tar.gz: ee6840dabf3ebeb17928f2f1ba17d9537dae7ad5d4a0ae61e4c32db41fdc9097
3
+ metadata.gz: b4ef5785c65d1716ad492175066157cca6cc97f04237469f7e985e2d8c56f127
4
+ data.tar.gz: 4bddd005e38fdb052f14e5719f36082a0bf586ddd53facfa8d5c4fe65764f969
5
5
  SHA512:
6
- metadata.gz: ad40f42fb9adf65ee02d14df4cb61e1de48a720c82c776e2a63de0f891a28873d25e25998629e8aeacbbf1db6f70259bea726f87348cb4a7a0f81c17775575ae
7
- data.tar.gz: 549374f0f04473e9346417b4943b7482baf8ef2998c19dec6c9b9198f2e0dba15d9c5bf7e149c3e375dbb2260afdafa5cbda3150b6ba398698c388e4d2884e9a
6
+ metadata.gz: 44d4393dc0e0af6a1164ea7e82bd77a98ffb3dad1be8f10b813d9c912a7724e05f7879cd87604d857bbe6bd1f26e4cb8343873f8a64abed17eb9908931e4e205
7
+ data.tar.gz: 97b8cfc082d665224dd2063438ee3ba785473dc735449fb8a93378ae64a1694e5c3d46cc95774a9c0e1564063fa2d86e6a710ceea4374b875625cbee45529417
@@ -200,7 +200,7 @@ module ZuoraConnect
200
200
  :zuora_entity_ids => self.task_data.dig(LOGIN_TENANT_DESTINATION,'entities').map{|e| e['id']},
201
201
  :zuora_tenant_ids => self.task_data['tenant_ids'],
202
202
  }
203
- params = params.reject{|k,v| !self.attributes.keys.member?(k.to_s) }
203
+ params = params.reject{|k,v| !self.attributes.keys.member?(k.to_s) || self[k] == v}
204
204
  self.update_columns(params) if params.present?
205
205
  end
206
206
 
@@ -67,10 +67,10 @@
67
67
  <input type="hidden" id="name_hash" value="<%= @names.to_s %>" />
68
68
  <input type="hidden" id="app_instance_list" value="<%= @app_instance_ids.to_s %>" />
69
69
 
70
- <% @app_instance_ids.each do |id| %>
70
+ <% @names.each do |id, name| %>
71
71
  <div class="button">
72
- <% label = @names[id].present? ? "#{id} - #{@names[id]}" : id %>
73
- <%= link_to label, root_path(app_instance_ids: params[:app_instance_ids], app_instance_id: id) %>
72
+ <% label = name.present? ? "#{id} - #{name}" : id %>
73
+ <%= link_to label, root_path(app_instance_id: id) %>
74
74
  </div>
75
75
  <% end %>
76
76
  </div>
@@ -106,68 +106,106 @@ module ZuoraConnect
106
106
  ElasticAPM.set_tag(:trace_id, request.uuid) if defined?(ElasticAPM) && ElasticAPM.running?
107
107
  Thread.current[:appinstance] = nil
108
108
 
109
- #Id identity is blank or identity need to be refreshed.
110
- if (session["Identity"].blank? || session["ZuoraCurrentEntity"] != request.headers['ZuoraCurrentEntity']) && request.headers['Zuora-Auth-Token'].present?
111
- puts cookies['ZSession']
112
- puts cookies['ZuoraCurrentEntity']
113
- puts request.headers['ZuoraCurrentEntity']
114
- puts "--------\n\n\n\n\n\n\n\n\n\n\n\n"
115
- puts request.headers['Zuora-Auth-Token']
116
- begin
117
- zuora_client = ZuoraAPI::Login.new(url: "https://#{request.headers["HTTP_X_FORWARDED_HOST"]}", session: cookies['ZSession'])
118
- identity = zuora_client.rest_call(url: zuora_client.rest_endpoint("identity"))
119
- session["Identity"] = identity
120
- session["ZuoraCurrentEntity"] = cookies['ZuoraCurrentEntity']
121
- rescue => ex
122
-
109
+ if request.headers['Zuora-Auth-Token'].present? && request.headers["NEWZUORA"].present?
110
+
111
+ #Debug
112
+ headers = request.headers.env.select do |k, _|
113
+ k.downcase.start_with?('http') ||
114
+ k.in?(ActionDispatch::Http::Headers::CGI_VARIABLES)
115
+ end
116
+ puts headers
117
+
118
+ #Do we need to refresh session identity
119
+ zuora_host = request.headers["HTTP_X_FORWARDED_HOST"] || "apisandbox.zuora.com"
120
+ zuora_client = ZuoraAPI::Login.new(url: "https://#{zuora_host}", session: cookies['ZSession'])
121
+ zuora_entity_id = request.headers['ZuoraCurrentEntity']
122
+ zuora_instance_id = params[:sidebar_launch].to_bool ? nil : (params[:app_instance_id] || session["appInstance"])
123
+
124
+ #Identity blank or current entity different
125
+ if (session["ZuoraCurrentIdentity"].blank? || session["ZuoraCurrentEntity"] != zuora_entity_id)
126
+ begin
127
+ identity, response = zuora_client.rest_call(url: zuora_client.rest_endpoint("identity"))
128
+ session["ZuoraCurrentIdentity"] = identity
129
+ session["ZuoraCurrentEntity"] = identity['entityId']
130
+
131
+ raise "Header entity id does not match identity call entity id" if zuora_entity_id != identity['entityId']
132
+ rescue => ex
133
+ ZuoraConnect.logger.error(ex)
134
+ render "zuora_connect/static/invalid_launch_request"
135
+ return
136
+ end
137
+ end
138
+
139
+ #Find matching app instances.
140
+ if zuora_instance_id.present?
141
+ appinstances = ZuoraConnect::AppInstance.where("zuora_entity_ids ?& array[:entities] = true AND zuora_domain = :host AND id = :id", entities: [zuora_entity_id], host: zuora_client.rest_domain, id: zuora_instance_id).pluck(:id, :name)
142
+ else
143
+ 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)
144
+ end
145
+
146
+ #One deployed instance
147
+ if appinstances.size == 1
148
+ ZuoraConnect.logger.debug("Instance is #{appinstances.to_h.keys.first}")
149
+ session["appInstance"] = appinstances.to_h.keys.first
150
+
151
+ #We have multiple, user must pick
152
+ elsif appinstances.size > 1
153
+ ZuoraConnect.logger.debug("User must select instance. #{@names}")
154
+ @names = appinstances.to_h
155
+ render "zuora_connect/static/launch"
123
156
  return
157
+ else
158
+ #Create new app instance
159
+ raise "Do not support new instance creation right now."
124
160
  end
125
161
  end
126
162
 
127
- if params[:app_instance_ids].present? && !params[:app_instance_id].present?
128
- begin
129
- app_instance_ids = JSON.parse(Base64.urlsafe_decode64(params[:app_instance_ids]))
130
- if app_instance_ids.length == 1
131
- verify_with_navbar
163
+ if params[:app_instance_ids].present?
164
+ if !params[:app_instance_id].present?
165
+ begin
166
+ app_instance_ids = JSON.parse(Base64.urlsafe_decode64(params[:app_instance_ids]))
167
+ if app_instance_ids.length == 1
168
+ verify_with_navbar
169
+ instances = JSON.parse(Base64.urlsafe_decode64(CGI.parse(URI.parse(session[params[:app_instance_ids]]["url"]).query)["app_instance_ids"][0]))
170
+ if instances.include?(app_instance_ids[0])
171
+ @appinstance = ZuoraConnect::AppInstance.find(app_instance_ids[0])
172
+ @appinstance.new_session(session: {})
173
+ @appinstance.cache_app_instance
174
+ session["appInstance"] = app_instance_ids[0]
175
+ else
176
+ ZuoraConnect.logger.error("Launch Error: Param Instance didnt match session data")
177
+ render "zuora_connect/static/invalid_launch_request"
178
+ return
179
+ end
180
+ else
181
+ select_instance
182
+ return
183
+ end
184
+ rescue => ex
185
+ ZuoraConnect.logger.error(ex)
186
+ render "zuora_connect/static/invalid_launch_request"
187
+ return
188
+ end
189
+ elsif params[:app_instance_id].present?
190
+ begin
132
191
  instances = JSON.parse(Base64.urlsafe_decode64(CGI.parse(URI.parse(session[params[:app_instance_ids]]["url"]).query)["app_instance_ids"][0]))
133
- if instances.include?(app_instance_ids[0])
134
- @appinstance = ZuoraConnect::AppInstance.find(app_instance_ids[0])
192
+ if instances.include?(params[:app_instance_id].to_i)
193
+ @appinstance = ZuoraConnect::AppInstance.find(params[:app_instance_id].to_i)
135
194
  @appinstance.new_session(session: {})
136
195
  @appinstance.cache_app_instance
137
- session["appInstance"] = app_instance_ids[0]
196
+ session["appInstance"] = params[:app_instance_id].to_i
138
197
  else
139
- ZuoraConnect.logger.error("Launch Error: Param Instance didnt match session data")
140
198
  render "zuora_connect/static/invalid_launch_request"
141
199
  return
142
200
  end
143
- else
144
- select_instance
145
- return
146
- end
147
- rescue => ex
148
- ZuoraConnect.logger.error(ex)
149
- render "zuora_connect/static/invalid_launch_request"
150
- return
151
- end
152
-
153
- elsif params[:app_instance_ids].present? && params[:app_instance_id].present?
154
- begin
155
- instances = JSON.parse(Base64.urlsafe_decode64(CGI.parse(URI.parse(session[params[:app_instance_ids]]["url"]).query)["app_instance_ids"][0]))
156
- if instances.include?(params[:app_instance_id].to_i)
157
- @appinstance = ZuoraConnect::AppInstance.find(params[:app_instance_id].to_i)
158
- @appinstance.new_session(session: {})
159
- @appinstance.cache_app_instance
160
- session["appInstance"] = params[:app_instance_id].to_i
161
- else
201
+ rescue => ex
202
+ ZuoraConnect.logger.error(ex)
162
203
  render "zuora_connect/static/invalid_launch_request"
163
204
  return
164
205
  end
165
- rescue => ex
166
- ZuoraConnect.logger.error(ex)
167
- render "zuora_connect/static/invalid_launch_request"
168
- return
169
206
  end
170
207
  end
208
+
171
209
  start_time = Time.now
172
210
  if ZuoraConnect.configuration.mode == "Production"
173
211
  if request["data"] && /^([A-Za-z0-9+\/\-\_]{4})*([A-Za-z0-9+\/]{4}|[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{2}==)$/.match(request["data"].to_s)
@@ -1,3 +1,3 @@
1
1
  module ZuoraConnect
2
- VERSION = "2.0.3d"
2
+ VERSION = "2.0.3e"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zuora_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3d
4
+ version: 2.0.3e
5
5
  platform: ruby
6
6
  authors:
7
7
  - Connect Team