Add ability to delete all subscriptions by tool_proxy
fixes PLAT-2460 This will need to be tested in conjunction with a commit in the live-events-subscription project Test plan: * Start the subscription service * With the canvas api or in a rails console create a bunch of subscriptions using the same tool proxy * Using the rails console issue the following command passing in the tool proxy res = Services::LiveEventsSubscriptionService.destroy_all_tool_proxy_subscriptions(tp) * Ensure that canvas makes the right request to the subscription service and that the subscription service returns a 200 Change-Id: Ied5527d46db50bec14de0455907b209cb1375df2 Reviewed-on: https://gerrit.instructure.com/108834 Tested-by: Jenkins Reviewed-by: Matthew Wheeler <mwheeler@instructure.com> QA-Review: August Thornton <august@instructure.com> Product-Review: Andrew Butterfield <abutterfield@instructure.com>
This commit is contained in:
parent
0e85a7d9aa
commit
6c76c96a4b
|
@ -36,6 +36,11 @@ module Services
|
||||||
request(:delete, "/api/subscriptions/#{subscription_id}", options)
|
request(:delete, "/api/subscriptions/#{subscription_id}", options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def destroy_all_tool_proxy_subscriptions(tool_proxy)
|
||||||
|
options = { headers: headers(tool_proxy_jwt_body(tool_proxy)) }
|
||||||
|
request(:delete, "/api/subscriptions", options)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def request(method, endpoint, options = {})
|
def request(method, endpoint, options = {})
|
||||||
Canvas.timeout_protection("live-events-subscription-service-session", raise_on_timeout: true) do
|
Canvas.timeout_protection("live-events-subscription-service-session", raise_on_timeout: true) do
|
||||||
|
|
|
@ -81,6 +81,21 @@ module Services
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '.destroy_all_tool_proxy_subscriptions' do
|
||||||
|
it 'makes the expected request' do
|
||||||
|
tool_proxy.stubs(:context).returns(root_account_context)
|
||||||
|
HTTParty.expects(:send).with do |method, endpoint, options|
|
||||||
|
expect(method).to eq(:delete)
|
||||||
|
expect(endpoint).to eq('http://example.com/api/subscriptions')
|
||||||
|
jwt = Canvas::Security::ServicesJwt.new(options[:headers]['Authorization'].gsub('Bearer ',''), false).original_token
|
||||||
|
expect(jwt["DeveloperKey"]).to eq('10000000000003')
|
||||||
|
expect(jwt["RootAccountId"]).to eq('10000000000004')
|
||||||
|
expect(jwt["sub"]).to eq('ltiToolProxy:151b52cd-d670-49fb-bf65-6a327e3aaca0')
|
||||||
|
end
|
||||||
|
LiveEventsSubscriptionService.destroy_all_tool_proxy_subscriptions(tool_proxy)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '.destroy_tool_proxy_subscription' do
|
describe '.destroy_tool_proxy_subscription' do
|
||||||
it 'makes the expected request' do
|
it 'makes the expected request' do
|
||||||
tool_proxy.stubs(:context).returns(root_account_context)
|
tool_proxy.stubs(:context).returns(root_account_context)
|
||||||
|
|
Loading…
Reference in New Issue