dce_lti 0.2.0 → 0.3.0

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
  SHA1:
3
- metadata.gz: 537eafe1ddf43015784d36ac3d0b75b29636d274
4
- data.tar.gz: b1b6c42e830086952c486bb6ef33030b2e1bd9b4
3
+ metadata.gz: 0943e97f6d2613ad998906f27e159dcc604171d8
4
+ data.tar.gz: b7b5e43868381971bb4977435a029306d5352db1
5
5
  SHA512:
6
- metadata.gz: 3507c09883950f002947a628e0fec151c6b046633575d739d3318c9dd67931ac32fd74a143027bce9d4c56f30d97bb1b9cf56268d0d78fddefe9a60bad03a1c3
7
- data.tar.gz: 30f1ae5dbd4e394ba1f9eb3f31104a161666585fbb4998ff59193b17dc56c5e96348689650701bf1484975ec4dfcd3f8296b50a00923d0818892f159d45e33a9
6
+ metadata.gz: f811c1fd2ddebd80675ee7f57dae0207363e8ec4e3c3d979e4496ad60dc403f9abb265025ff3f18d2e4e9049aca11e1a71c4afcc714991b46025ffff1c1a72d3
7
+ data.tar.gz: de233030855e214740d63d92b742802156d9821685bb92aeadc0ff3d5c36cea3592d818d86dafbf7cb91ff364b56402d32242b9bc730db9644063d240e1cb6be
data/README.md CHANGED
@@ -55,6 +55,10 @@ The generated config looks something like (commented defaults omitted):
55
55
  Most basic attributes are configured via ENV. See the generated
56
56
  `config/initializers/dce_lti_config.rb` file.
57
57
 
58
+ `lti.copy_launch_attributes_to_session` is an array of symbols that allows you
59
+ to define attributes to copy to the rails session from the tool provider after
60
+ a successful launch. See `config/initializers/dce_lti_config.rb` for more info.
61
+
58
62
  ### X-Frame Options
59
63
 
60
64
  We install a config file that removes `X-Frame-Options` by default to allow
@@ -143,7 +147,8 @@ can also just invoke `DceLti::Nonce.clean` on your own.
143
147
 
144
148
  ## Contributors
145
149
 
146
- * Dan Collis-Puro - @djcp
150
+ * Dan Collis-Puro - [djcp](https://github.com/djcp)
151
+ * Rebecca Nesson - [rebeccanesson](https://github.com/rebeccanesson)
147
152
 
148
153
  ## License
149
154
 
@@ -1,14 +1,5 @@
1
1
  module DceLti
2
2
  module SessionHelpers
3
- ATTRIBUTES_TO_EXTRACT_FOR_SESSION = %i|
4
- context_id
5
- context_label
6
- context_title
7
- resource_link_id
8
- resource_link_title
9
- tool_consumer_instance_guid
10
- |
11
-
12
3
  def valid_lti_request?(request)
13
4
  tool_provider.valid_request?(request) &&
14
5
  Nonce.valid?(tool_provider.oauth_nonce) &&
@@ -47,7 +38,7 @@ tool_consumer_instance_guid
47
38
  end
48
39
 
49
40
  def captured_attributes_from(tool_provider)
50
- ATTRIBUTES_TO_EXTRACT_FOR_SESSION.inject({}) do |attributes, att|
41
+ Engine.config.copy_launch_attributes_to_session.inject({}) do |attributes, att|
51
42
  attributes.merge(att => tool_provider.send(att))
52
43
  end
53
44
  end
@@ -4,6 +4,16 @@ require 'pg'
4
4
  module DceLti
5
5
  class Engine < ::Rails::Engine
6
6
  def self.setup
7
+ config.copy_launch_attributes_to_session = %i|
8
+ context_id
9
+ context_label
10
+ context_title
11
+ resource_link_id
12
+ resource_link_title
13
+ tool_consumer_instance_guid
14
+ launch_presentation_return_url
15
+ |
16
+
7
17
  config.provider_title = (ENV['LTI_PROVIDER_TITLE'] || 'DCE LTI Provider')
8
18
  config.provider_description = (ENV['LTI_PROVIDER_DESCRIPTION'] || 'A description of this')
9
19
 
@@ -1,3 +1,3 @@
1
1
  module DceLti
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -33,13 +33,15 @@ module DceLti
33
33
  end
34
34
 
35
35
  it 'evaluates custom lambdas with controller context correctly' do
36
+ allow(controller).to receive(:awesome_method)
37
+
36
38
  tool_config_extensions = ->(controller, tool_config) {
37
39
  tool_config.extend ::IMS::LTI::Extensions::Canvas::ToolConfig
38
- tool_config.canvas_domain!(controller.request.host)
40
+ tool_config.canvas_domain!(controller.awesome_method)
39
41
  }
40
42
  with_overridden_lti_config_of({tool_config_extensions: tool_config_extensions}) do
41
43
  get :index, { format: :xml, use_route: :dce_lti }
42
- expect(response.body).to include 'test.host'
44
+ expect(controller).to have_received(:awesome_method)
43
45
  end
44
46
  end
45
47
 
@@ -29,6 +29,20 @@ module DceLti
29
29
  expect(Nonce).to have_received(:valid?).with(nonce)
30
30
  end
31
31
 
32
+ it 'has configurable captured session attributes' do
33
+ attributes_to_capture = [:foobar]
34
+ tool_provider = stub_successful_tool_provider
35
+
36
+ with_overridden_lti_config_of(
37
+ lti_config.merge(copy_launch_attributes_to_session: attributes_to_capture)
38
+ ) do
39
+
40
+ post_to_create_with_params
41
+
42
+ expect(tool_provider).to have_received(:foobar)
43
+ end
44
+ end
45
+
32
46
  it 'uses a proc for consumer_key and consumer_secret if configured' do
33
47
  tool_provider = stub_successful_tool_provider
34
48
  consumer_key = 'a key'
@@ -10,6 +10,20 @@ DceLti::Engine.setup do |lti|
10
10
  lti.consumer_secret = (ENV['LTI_CONSUMER_SECRET'] || 'consumer_secret')
11
11
  lti.consumer_key = (ENV['LTI_CONSUMER_KEY'] || 'consumer_key')
12
12
 
13
+ # `lti.copy_launch_attributes_to_session` is an array of attributes to copy
14
+ # to the default rails session from the IMS::LTI::ToolProvider instance after
15
+ # a successful launch. The default attributes are defined in
16
+ # `DceLti::Engine.setup`, and the possible canvas-lms attributes are defined
17
+ # in:
18
+ #
19
+ # https://github.com/instructure/ims-lti/blob/master/lib/ims/lti/launch_params.rb#L9
20
+ # https://github.com/instructure/ims-lti/blob/master/lib/ims/lti/tool_provider.rb
21
+ #
22
+ # and in the spec as well:
23
+ # http://www.imsglobal.org/LTI/v1p1p1/ltiIMGv1p1p1.html#_Toc330273026
24
+ #
25
+ # lti.copy_launch_attributes_to_session.push(:additional_attribute_to_capture)
26
+
13
27
  # The consumer_secret and consumer_key should be a lambda that will be
14
28
  # evaluated in the context of your application. You might use a service
15
29
  # object or model proper to find key and secret pairs. Example:
@@ -2873,3 +2873,58 @@ Completed 200 OK in 3ms (Views: 0.4ms | ActiveRecord: 0.6ms)
2873
2873
   (0.2ms) SELECT version FROM "schema_migrations"
2874
2874
   (3.2ms) INSERT INTO "schema_migrations" (version) VALUES ('20141008172001')
2875
2875
   (3.3ms) INSERT INTO "schema_migrations" (version) VALUES ('20141003180140')
2876
+  (106.9ms) DROP DATABASE IF EXISTS "dce_lti_dummy_test"
2877
+  (330.2ms) CREATE DATABASE "dce_lti_dummy_test" ENCODING = 'utf8'
2878
+ SQL (0.2ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
2879
+  (7.2ms) CREATE TABLE "dce_lti_nonces" ("id" serial primary key, "nonce" character varying(255), "created_at" timestamp, "updated_at" timestamp)
2880
+  (3.3ms) CREATE UNIQUE INDEX "index_dce_lti_nonces_on_nonce" ON "dce_lti_nonces" USING btree ("nonce")
2881
+  (6.7ms) CREATE TABLE "dce_lti_users" ("id" serial primary key, "lti_user_id" character varying(255), "lis_person_contact_email_primary" character varying(255), "lis_person_name_family" character varying(255), "lis_person_name_full" character varying(255), "lis_person_name_given" character varying(255), "lis_person_sourcedid" character varying(255), "user_image" character varying(255), "roles" character varying(255)[] DEFAULT '{}', "created_at" timestamp, "updated_at" timestamp)
2882
+  (1.3ms) CREATE TABLE "schema_migrations" ("version" character varying(255) NOT NULL) 
2883
+  (5.7ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
2884
+  (0.2ms) SELECT version FROM "schema_migrations"
2885
+  (2.4ms) INSERT INTO "schema_migrations" (version) VALUES ('20141008172001')
2886
+  (2.3ms) INSERT INTO "schema_migrations" (version) VALUES ('20141003180140')
2887
+  (106.2ms) DROP DATABASE IF EXISTS "dce_lti_dummy_test"
2888
+  (233.4ms) CREATE DATABASE "dce_lti_dummy_test" ENCODING = 'utf8'
2889
+ SQL (0.2ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
2890
+  (10.1ms) CREATE TABLE "dce_lti_nonces" ("id" serial primary key, "nonce" character varying(255), "created_at" timestamp, "updated_at" timestamp)
2891
+  (7.2ms) CREATE UNIQUE INDEX "index_dce_lti_nonces_on_nonce" ON "dce_lti_nonces" USING btree ("nonce")
2892
+  (13.2ms) CREATE TABLE "dce_lti_users" ("id" serial primary key, "lti_user_id" character varying(255), "lis_person_contact_email_primary" character varying(255), "lis_person_name_family" character varying(255), "lis_person_name_full" character varying(255), "lis_person_name_given" character varying(255), "lis_person_sourcedid" character varying(255), "user_image" character varying(255), "roles" character varying(255)[] DEFAULT '{}', "created_at" timestamp, "updated_at" timestamp)
2893
+  (2.8ms) CREATE TABLE "schema_migrations" ("version" character varying(255) NOT NULL) 
2894
+  (7.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
2895
+  (0.3ms) SELECT version FROM "schema_migrations"
2896
+  (2.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20141008172001')
2897
+  (2.5ms) INSERT INTO "schema_migrations" (version) VALUES ('20141003180140')
2898
+  (104.7ms) DROP DATABASE IF EXISTS "dce_lti_dummy_test"
2899
+  (239.6ms) CREATE DATABASE "dce_lti_dummy_test" ENCODING = 'utf8'
2900
+ SQL (0.2ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
2901
+  (9.8ms) CREATE TABLE "dce_lti_nonces" ("id" serial primary key, "nonce" character varying(255), "created_at" timestamp, "updated_at" timestamp)
2902
+  (5.8ms) CREATE UNIQUE INDEX "index_dce_lti_nonces_on_nonce" ON "dce_lti_nonces" USING btree ("nonce")
2903
+  (6.8ms) CREATE TABLE "dce_lti_users" ("id" serial primary key, "lti_user_id" character varying(255), "lis_person_contact_email_primary" character varying(255), "lis_person_name_family" character varying(255), "lis_person_name_full" character varying(255), "lis_person_name_given" character varying(255), "lis_person_sourcedid" character varying(255), "user_image" character varying(255), "roles" character varying(255)[] DEFAULT '{}', "created_at" timestamp, "updated_at" timestamp)
2904
+  (1.5ms) CREATE TABLE "schema_migrations" ("version" character varying(255) NOT NULL) 
2905
+  (3.4ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
2906
+  (0.2ms) SELECT version FROM "schema_migrations"
2907
+  (1.1ms) INSERT INTO "schema_migrations" (version) VALUES ('20141008172001')
2908
+  (1.1ms) INSERT INTO "schema_migrations" (version) VALUES ('20141003180140')
2909
+  (106.0ms) DROP DATABASE IF EXISTS "dce_lti_dummy_test"
2910
+  (227.1ms) CREATE DATABASE "dce_lti_dummy_test" ENCODING = 'utf8'
2911
+ SQL (0.2ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
2912
+  (10.0ms) CREATE TABLE "dce_lti_nonces" ("id" serial primary key, "nonce" character varying(255), "created_at" timestamp, "updated_at" timestamp)
2913
+  (7.1ms) CREATE UNIQUE INDEX "index_dce_lti_nonces_on_nonce" ON "dce_lti_nonces" USING btree ("nonce")
2914
+  (13.2ms) CREATE TABLE "dce_lti_users" ("id" serial primary key, "lti_user_id" character varying(255), "lis_person_contact_email_primary" character varying(255), "lis_person_name_family" character varying(255), "lis_person_name_full" character varying(255), "lis_person_name_given" character varying(255), "lis_person_sourcedid" character varying(255), "user_image" character varying(255), "roles" character varying(255)[] DEFAULT '{}', "created_at" timestamp, "updated_at" timestamp)
2915
+  (2.8ms) CREATE TABLE "schema_migrations" ("version" character varying(255) NOT NULL) 
2916
+  (7.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
2917
+  (0.2ms) SELECT version FROM "schema_migrations"
2918
+  (2.4ms) INSERT INTO "schema_migrations" (version) VALUES ('20141008172001')
2919
+  (2.4ms) INSERT INTO "schema_migrations" (version) VALUES ('20141003180140')
2920
+  (105.4ms) DROP DATABASE IF EXISTS "dce_lti_dummy_test"
2921
+  (340.1ms) CREATE DATABASE "dce_lti_dummy_test" ENCODING = 'utf8'
2922
+ SQL (0.4ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
2923
+  (17.6ms) CREATE TABLE "dce_lti_nonces" ("id" serial primary key, "nonce" character varying(255), "created_at" timestamp, "updated_at" timestamp)
2924
+  (3.4ms) CREATE UNIQUE INDEX "index_dce_lti_nonces_on_nonce" ON "dce_lti_nonces" USING btree ("nonce")
2925
+  (6.7ms) CREATE TABLE "dce_lti_users" ("id" serial primary key, "lti_user_id" character varying(255), "lis_person_contact_email_primary" character varying(255), "lis_person_name_family" character varying(255), "lis_person_name_full" character varying(255), "lis_person_name_given" character varying(255), "lis_person_sourcedid" character varying(255), "user_image" character varying(255), "roles" character varying(255)[] DEFAULT '{}', "created_at" timestamp, "updated_at" timestamp)
2926
+  (1.4ms) CREATE TABLE "schema_migrations" ("version" character varying(255) NOT NULL) 
2927
+  (3.4ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
2928
+  (0.2ms) SELECT version FROM "schema_migrations"
2929
+  (1.0ms) INSERT INTO "schema_migrations" (version) VALUES ('20141008172001')
2930
+  (1.1ms) INSERT INTO "schema_migrations" (version) VALUES ('20141003180140')