Sha256: 2d5df745d3887507bacfd7d71cfa0750e6c7a69fe3bb40846d6b9c328f8b4ec3
Contents?: true
Size: 1.49 KB
Versions: 20
Compression:
Stored size: 1.49 KB
Contents
require "spec_helper" require "json/jwt" RSpec.describe CanvasSync::Api::V1::LiveEventsController, type: :controller do routes { CanvasSync::Engine.routes } let(:event) { { "metadata" => { event_name: "user_created", }, "payload" => { user_id: 42660000000000001, }, }.with_indifferent_access } describe "#transform_ids!" do it "transforms sharded IDs to local IDs" do controller.send(:transform_ids!, event) expect(event[:payload][:user_id]).to eql 1 expect(event[:payload][:sharded_user_id]).to eql 42660000000000001 end xit "it does not transform cross-shard IDs" do # TODO end end describe "#process_dataservices_event" do let(:private_key) { OpenSSL::PKey::RSA.new(2048) } let(:jwk) { JSON::JWK.new(private_key) } let(:jwks) { JSON::JWK::Set.new([jwk]) } before :each do allow(controller).to receive(:dataservices_jwks).and_return(jwks) end let(:event_data) { event.to_json } it "triggers a background job" do expect(controller).to receive(:dispatch_event) expect(controller).to receive(:validate_tenant!) post :process_event, params: { "_json" => JSON::JWT.new(event).sign(jwk).to_s } expect(response).to be_successful end it "does not allow unsigned events" do expect(controller).to_not receive(:validate_tenant!) post :process_event, params: { "_json" => event.to_json } expect(response).to_not be_successful end end end
Version data entries
20 entries across 20 versions & 1 rubygems