add data services index action

closes PLAT-4744

Test Plan:
 - see that the index action returns a list

Change-Id: I92cc07c5476c7dd48202f38b62e09df6aa591b62
Reviewed-on: https://gerrit.instructure.com/206435
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
Tested-by: Jenkins
QA-Review: Marc Phillips <mphillips@instructure.com>
Product-Review: Marc Phillips <mphillips@instructure.com>
This commit is contained in:
Xander Moffatt 2019-08-22 17:44:31 -06:00 committed by Marc Phillips
parent ae81fee438
commit 352d132257
7 changed files with 37 additions and 5 deletions

View File

@ -66,7 +66,8 @@ module Lti
ACTION_SCOPE_MATCHERS = {
create: all_of(TokenScopes::LTI_CREATE_DATA_SERVICE_SUBSCRIPTION_SCOPE),
show: all_of(TokenScopes::LTI_SHOW_DATA_SERVICE_SUBSCRIPTION_SCOPE),
update: all_of(TokenScopes::LTI_UPDATE_DATA_SERVICE_SUBSCRIPTION_SCOPE)
update: all_of(TokenScopes::LTI_UPDATE_DATA_SERVICE_SUBSCRIPTION_SCOPE),
index: all_of(TokenScopes::LTI_LIST_DATA_SERVICE_SUBSCRIPTION_SCOPE)
}.freeze.with_indifferent_access
rescue_from Lti::SubscriptionsValidator::InvalidContextType do
@ -153,6 +154,21 @@ module Lti
forward_service_response(response)
end
# @API List all Data Services Event Subscriptions
#
# This endpoint returns a paginated list with a default limit of 100 items per result set.
# You can retrieve the next result set by setting a 'StartKey' header in your next request
# with the value of the 'EndKey' header in the response.
#
# Example use of a 'StartKey' header object:
# { "Id":"71d6dfba-0547-477d-b41d-db8cb528c6d1","OwnerId":"domain.instructure.com" }
#
# @returns DataServiceSubscription
def index
response = Services::LiveEventsSubscriptionService.index(jwt_body)
forward_service_response(response)
end
private
def scopes_matcher

View File

@ -2349,6 +2349,7 @@ CanvasRails::Application.routes.draw do
post "/accounts/:account_id/data_services", action: :create, as: :data_services_create
get "/accounts/:account_id/data_services/:id", action: :show, as: :data_services_show
put "/accounts/:account_id/data_services/:id", action: :update, as: :data_services_update
get "/accounts/:account_id/data_services", action: :index, as: :data_services_index
end
# Names and Roles Provisioning (NRPS) v2 Service

View File

@ -57,7 +57,8 @@ module Schemas::Lti
"https://canvas.instructure.com/lti/public_jwk/scope/update",
"https://canvas.instructure.com/lti/data_services/scope/create",
"https://canvas.instructure.com/lti/data_services/scope/show",
"https://canvas.instructure.com/lti/data_services/scope/update"
"https://canvas.instructure.com/lti/data_services/scope/update",
"https://canvas.instructure.com/lti/data_services/scope/list"
].freeze
}
}.freeze,

View File

@ -81,7 +81,7 @@ module Services
request(:delete, "/api/subscriptions/#{subscription_id}", options)
end
def index(jwt_body, opts)
def index(jwt_body, opts = {})
options = { headers: headers(jwt_body, opts) }
request(:get, '/api/subscriptions', options)
end

View File

@ -31,6 +31,7 @@ class TokenScopes
LTI_CREATE_DATA_SERVICE_SUBSCRIPTION_SCOPE = "https://canvas.instructure.com/lti/data_services/scope/create".freeze
LTI_SHOW_DATA_SERVICE_SUBSCRIPTION_SCOPE = "https://canvas.instructure.com/lti/data_services/scope/show".freeze
LTI_UPDATE_DATA_SERVICE_SUBSCRIPTION_SCOPE = "https://canvas.instructure.com/lti/data_services/scope/update".freeze
LTI_LIST_DATA_SERVICE_SUBSCRIPTION_SCOPE = "https://canvas.instructure.com/lti/data_services/scope/list".freeze
LTI_SCOPES = {
LTI_AGS_LINE_ITEM_SCOPE => I18n.t("Can create and view assignment data in the gradebook associated with the tool."),
LTI_AGS_LINE_ITEM_READ_ONLY_SCOPE => I18n.t("Can view assignment data in the gradebook associated with the tool."),
@ -40,7 +41,8 @@ class TokenScopes
LTI_UPDATE_PUBLIC_JWK_SCOPE => I18n.t("Can update public jwk for LTI services."),
LTI_CREATE_DATA_SERVICE_SUBSCRIPTION_SCOPE => I18n.t("Can create subscription to data service data."),
LTI_SHOW_DATA_SERVICE_SUBSCRIPTION_SCOPE => I18n.t("Can show subscription to data service data."),
LTI_UPDATE_DATA_SERVICE_SUBSCRIPTION_SCOPE => I18n.t("Can update subscription to data service data.")
LTI_UPDATE_DATA_SERVICE_SUBSCRIPTION_SCOPE => I18n.t("Can update subscription to data service data."),
LTI_LIST_DATA_SERVICE_SUBSCRIPTION_SCOPE => I18n.t("Can list subscriptions to data service data.")
}.freeze
LTI_AGS_SCOPES = [ LTI_AGS_LINE_ITEM_SCOPE, LTI_AGS_LINE_ITEM_READ_ONLY_SCOPE, LTI_AGS_RESULT_READ_ONLY_SCOPE, LTI_AGS_SCORE_SCOPE ].freeze

View File

@ -60,7 +60,7 @@ describe Lti::DataServicesController do
let(:expected_mime_type) { described_class::MIME_TYPE }
let(:scope_to_remove) { "https://canvas.instructure.com/lti/data_services/scope/show"}
let(:params_overrides) do
{ subscription: subscription, account_id: root_account.id, id: 'testid' }
{ account_id: root_account.id, id: 'testid' }
end
end
end
@ -75,4 +75,15 @@ describe Lti::DataServicesController do
end
end
end
describe '#index' do
it_behaves_like 'lti services' do
let(:action) { :index }
let(:expected_mime_type) { described_class::MIME_TYPE }
let(:scope_to_remove) { "https://canvas.instructure.com/lti/data_services/scope/list"}
let(:params_overrides) do
{ account_id: root_account.id }
end
end
end
end

View File

@ -36,6 +36,7 @@ shared_context 'advantage services context' do
https://canvas.instructure.com/lti/data_services/scope/create
https://canvas.instructure.com/lti/data_services/scope/show
https://canvas.instructure.com/lti/data_services/scope/update
https://canvas.instructure.com/lti/data_services/scope/list
).join(' ')
end
let(:access_token_signing_key) { Canvas::Security.encryption_key }