canvas_sync 0.27.3 → 0.27.4

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: 737cc77b1803668c25294c6b0a0c669183e9a3e4d18ce315cb6833637787d6b4
4
+ data.tar.gz: 7fb94e9a30ab33104f2298710097a25c47366baf8fa62b87ac8d8e139bcf7e11
5
5
  SHA512:
6
- metadata.gz: 571f4296981c5fd72386d6b58d68864f719340da7862b4a5720a5d21d7ba5d146c23e1cfaf2f88b33c55bf80b0b02dd174a22e49519eecea8793b82d7c95b883
7
- data.tar.gz: 484661a54a3b0fbeee189b9ee64e9554e6baa455da0ef3ed641327c71ba7cfbb40ddcab8394c23f4992f6d98447afe5c7abf58c56f225ef0fdf2689f7f8dfb1c
6
+ metadata.gz: 895e11f4343aa7f6448c714ef952478a68329f9aa3c673f665443c27a744081f350f5cfe5d9be77f14c477bb9e7a41f2c70f4f0fb7c0c7268d5d9593c534ab6d
7
+ data.tar.gz: 79460516a9f5cc75627702d1b2b67e790350e9703adc1c2f5da33ba97b92c3b6ed1066bb1231fe009dbfacbd7b5795db01b29576472f5a49bee4325414fb645b
@@ -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']}")
@@ -1,3 +1,3 @@
1
1
  module CanvasSync
2
- VERSION = "0.27.3".freeze
2
+ VERSION = "0.27.4".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.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Instructure CustomDev