canvas_sync 0.27.3 → 0.27.5
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/controllers/canvas_sync/api/v1/live_events_controller.rb +3 -1
- data/lib/canvas_sync/jobs/report_starter.rb +1 -1
- data/lib/canvas_sync/jobs/report_sync_task.rb +1 -1
- data/lib/canvas_sync/version.rb +1 -1
- data/spec/canvas_sync/live_events/live_events_controller_spec.rb +16 -0
- data/spec/spec_helper.rb +3 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d6f24c18ebf86f750d70099ea3e005f7036a757b37585c6b90e8cb8118320a6d
|
|
4
|
+
data.tar.gz: 1228fee5adaec59e4fbd29b464950d2a1a60e0f4d3d0fd2dfacdacb36ae800e8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dad20a38ebc24dfb459f6993ad9a24e02a40f5a6c68c4403df3bb90500b0676857e07fb93a582fcd5b28c0a78501d823143c3364e93fbb9a3d9f40134a9af2da
|
|
7
|
+
data.tar.gz: fefc18626e5222c0402a399ca8caf3c131e9cebe0ce16df6233ce3cba9904839f0ffc7ccebe3deee2cd7695c2db33735957662935340695a63592385449a91ca
|
|
@@ -46,7 +46,9 @@ module CanvasSync::Api
|
|
|
46
46
|
event = JSON.parse(request.raw_post) rescue nil
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
jwt = params[:_json] || request.raw_post
|
|
50
|
+
jwt = jwt.strip.gsub(/^"(.*)"$/, '\1') if jwt.is_a?(String) # Strip quotes if quoted
|
|
51
|
+
event ||= JSON::JWT.decode(jwt, dataservices_jwks)
|
|
50
52
|
event = event.to_h.with_indifferent_access
|
|
51
53
|
|
|
52
54
|
Rails.logger.debug("Processing event type: #{event['metadata']['event_name']}")
|
|
@@ -51,7 +51,7 @@ module CanvasSync
|
|
|
51
51
|
def process(file)
|
|
52
52
|
processor_class_name = options[:legacy_report_starter][:processor]
|
|
53
53
|
processor_class = processor_class_name.constantize
|
|
54
|
-
account_id = options[:account_id] ||
|
|
54
|
+
account_id = options[:account_id] || context[:account_id] || "self"
|
|
55
55
|
|
|
56
56
|
# The old processor signature: process(file_path, options, report_id)
|
|
57
57
|
# Note: The third param was report_id in ReportProcessorJob but was account_id in practice
|
|
@@ -216,7 +216,7 @@ module CanvasSync
|
|
|
216
216
|
|
|
217
217
|
case report_status["status"].downcase
|
|
218
218
|
when "complete"
|
|
219
|
-
ProcessJob.perform_later(report_status["attachment"]["url"])
|
|
219
|
+
report_task.class::ProcessJob.perform_later(report_status["attachment"]["url"])
|
|
220
220
|
when "error", "deleted"
|
|
221
221
|
max_tries = options[:report_max_tries] || batch_context[:report_max_tries] || report_task.max_tries || MAX_TRIES
|
|
222
222
|
report_attempt = batch_context[:report_attempt]
|
data/lib/canvas_sync/version.rb
CHANGED
|
@@ -50,5 +50,21 @@ RSpec.describe CanvasSync::Api::V1::LiveEventsController, type: :controller do
|
|
|
50
50
|
post :process_event, params: { "_json" => event.to_json }
|
|
51
51
|
expect(response).to_not be_successful
|
|
52
52
|
end
|
|
53
|
+
|
|
54
|
+
it "supports application/jwt" do
|
|
55
|
+
expect(controller).to receive(:dispatch_event)
|
|
56
|
+
expect(controller).to receive(:validate_tenant!)
|
|
57
|
+
request.headers['Content-Type'] = 'application/jwt'
|
|
58
|
+
post :process_event, body: JSON::JWT.new(event).sign(jwk).to_s
|
|
59
|
+
expect(response).to be_successful
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "supports application/jwt (quoted)" do
|
|
63
|
+
expect(controller).to receive(:dispatch_event)
|
|
64
|
+
expect(controller).to receive(:validate_tenant!)
|
|
65
|
+
request.headers['Content-Type'] = 'application/jwt'
|
|
66
|
+
post :process_event, body: %["#{JSON::JWT.new(event).sign(jwk).to_s}"]
|
|
67
|
+
expect(response).to be_successful
|
|
68
|
+
end
|
|
53
69
|
end
|
|
54
70
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -7,6 +7,9 @@ Bundler.require :default, :development
|
|
|
7
7
|
Combustion::Application.configure do
|
|
8
8
|
config.enable_reloading = true # Required for with_model
|
|
9
9
|
end
|
|
10
|
+
|
|
11
|
+
# Register application/jwt MIME type for testing
|
|
12
|
+
Mime::Type.register "application/jwt", :jwt
|
|
10
13
|
Combustion.initialize! :active_record, :active_job
|
|
11
14
|
|
|
12
15
|
require 'rspec/rails'
|