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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 778924d69dbb2a1f29a6e9b5101851ebda4042536949619b1aa5a2ebdd0f1f69
4
- data.tar.gz: 06ce5ef0c498612f864dd54f817cb24200b9f64d6dcce644ab235ba784bd4d79
3
+ metadata.gz: d6f24c18ebf86f750d70099ea3e005f7036a757b37585c6b90e8cb8118320a6d
4
+ data.tar.gz: 1228fee5adaec59e4fbd29b464950d2a1a60e0f4d3d0fd2dfacdacb36ae800e8
5
5
  SHA512:
6
- metadata.gz: 571f4296981c5fd72386d6b58d68864f719340da7862b4a5720a5d21d7ba5d146c23e1cfaf2f88b33c55bf80b0b02dd174a22e49519eecea8793b82d7c95b883
7
- data.tar.gz: 484661a54a3b0fbeee189b9ee64e9554e6baa455da0ef3ed641327c71ba7cfbb40ddcab8394c23f4992f6d98447afe5c7abf58c56f225ef0fdf2689f7f8dfb1c
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
- event ||= JSON::JWT.decode(params[:_json], dataservices_jwks)
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] || batch_context[:account_id] || "self"
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]
@@ -1,3 +1,3 @@
1
1
  module CanvasSync
2
- VERSION = "0.27.3".freeze
2
+ VERSION = "0.27.5".freeze
3
3
  end
@@ -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'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canvas_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.3
4
+ version: 0.27.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Instructure CustomDev