qalam_lti_provider_engine 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +146 -0
  4. data/Rakefile +28 -0
  5. data/app/controllers/lti_provider/application_controller.rb +5 -0
  6. data/app/controllers/lti_provider/lti_application_controller.rb +5 -0
  7. data/app/controllers/lti_provider/lti_controller.rb +73 -0
  8. data/app/models/lti_provider/launch.rb +106 -0
  9. data/app/views/layouts/lti_provider/application.html.erb +12 -0
  10. data/app/views/lti_provider/lti/cookie_test.html.erb +4 -0
  11. data/config/lti.yml.example +13 -0
  12. data/config/lti_xml.yml.example +22 -0
  13. data/config/routes.rb +6 -0
  14. data/db/migrate/20130319050003_create_lti_provider_launches.rb +11 -0
  15. data/lib/lti_provider/config.rb +3 -0
  16. data/lib/lti_provider/engine.rb +19 -0
  17. data/lib/lti_provider/lti_application.rb +60 -0
  18. data/lib/lti_provider/lti_config.rb +30 -0
  19. data/lib/lti_provider/lti_xml_config.rb +23 -0
  20. data/lib/lti_provider/version.rb +3 -0
  21. data/lib/lti_provider/xml_config.rb +3 -0
  22. data/lib/lti_provider.rb +20 -0
  23. data/lib/tasks/lti_provider_tasks.rake +4 -0
  24. data/spec/controllers/lti_provider/lti_controller_spec.rb +147 -0
  25. data/spec/dummy/Rakefile +7 -0
  26. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  27. data/spec/dummy/app/controllers/welcome_controller.rb +5 -0
  28. data/spec/dummy/config/application.rb +57 -0
  29. data/spec/dummy/config/boot.rb +10 -0
  30. data/spec/dummy/config/cucumber.yml +8 -0
  31. data/spec/dummy/config/database.yml +25 -0
  32. data/spec/dummy/config/environment.rb +5 -0
  33. data/spec/dummy/config/environments/development.rb +29 -0
  34. data/spec/dummy/config/environments/production.rb +65 -0
  35. data/spec/dummy/config/environments/test.rb +33 -0
  36. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  37. data/spec/dummy/config/initializers/inflections.rb +15 -0
  38. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  39. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  40. data/spec/dummy/config/initializers/session_store.rb +8 -0
  41. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  42. data/spec/dummy/config/locales/en.yml +5 -0
  43. data/spec/dummy/config/lti.yml +13 -0
  44. data/spec/dummy/config/lti_xml.yml +24 -0
  45. data/spec/dummy/config/routes.rb +4 -0
  46. data/spec/dummy/config.ru +4 -0
  47. data/spec/dummy/db/migrate/20130319050206_create_lti_provider_launches.lti_provider.rb +12 -0
  48. data/spec/dummy/db/schema.rb +24 -0
  49. data/spec/dummy/public/404.html +26 -0
  50. data/spec/dummy/public/422.html +26 -0
  51. data/spec/dummy/public/500.html +25 -0
  52. data/spec/dummy/public/favicon.ico +0 -0
  53. data/spec/dummy/public/robots.txt +5 -0
  54. data/spec/dummy/script/rails +6 -0
  55. data/spec/models/lti_provider/launch_spec.rb +70 -0
  56. data/spec/spec_helper.rb +57 -0
  57. metadata +353 -0
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+
3
+ describe LtiProvider::Launch do
4
+ describe ".initialize_from_request" do
5
+ let(:provider) do
6
+ p = double('provider')
7
+ allow(p).to receive_messages(
8
+ to_params: {
9
+ 'custom_canvas_course_id' => 1,
10
+ 'custom_canvas_user_id' => 2,
11
+ 'oauth_nonce' => 'nonce',
12
+ 'tool_consumer_instance_guid' => "123abc",
13
+ },
14
+ launch_presentation_return_url: "http://example.com",
15
+ consumer_key: "key",
16
+ consumer_secret: "secret",
17
+ valid_request?: true,
18
+ request_oauth_timestamp: Time.now
19
+ )
20
+ p
21
+ end
22
+
23
+ let(:request) do
24
+ r = double('request')
25
+ allow(r).to receive_messages(env: {'HTTP_REFERER' => "http://example.com"})
26
+ r
27
+ end
28
+
29
+ subject(:launch) { LtiProvider::Launch.initialize_from_request(provider, request) }
30
+
31
+ it "parses params" do
32
+ expect(subject.course_id).to eq 1
33
+ expect(subject.tool_consumer_instance_guid).to eq '123abc'
34
+ expect(subject.user_id).to eq 2
35
+ expect(subject.nonce).to eq 'nonce'
36
+ expect(subject.account_id).to be_nil
37
+ expect(subject.canvas_url).to eq 'http://example.com'
38
+ end
39
+ end
40
+
41
+ describe "xml_config" do
42
+ let(:lti_launch_url) { "http://example.com/launch" }
43
+ let(:doc) { Nokogiri::XML(xml) }
44
+
45
+ subject(:xml) { LtiProvider::Launch.xml_config(lti_launch_url) }
46
+
47
+ it { is_expected.to match(/\<\?xml/) }
48
+
49
+ it "includes the launch URL" do
50
+ expect(doc.xpath('//blti:launch_url').text).to match lti_launch_url
51
+ end
52
+
53
+ it "includes the course_navigation option and url + text properties" do
54
+ nav = doc.xpath('//lticm:options[@name="course_navigation"]')
55
+ expect(nav.xpath('lticm:property[@name="url"]').text).to eq 'http://override.example.com/launch'
56
+ expect(nav.xpath('lticm:property[@name="text"]').text).to eq "Dummy"
57
+ expect(nav.xpath('lticm:property[@name="visibility"]').text).to eq "admins"
58
+ end
59
+
60
+ it "includes account_navigation" do
61
+ nav = doc.xpath('//lticm:options[@name="account_navigation"]')
62
+ expect(nav).to be_present
63
+ end
64
+
65
+ it "includes no user_navigation" do
66
+ nav = doc.xpath('//lticm:options[@name="user_navigation"]')
67
+ expect(nav).to be_empty
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,57 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+ require File.expand_path("../dummy/config/environment", __FILE__)
4
+ require 'rspec/rails'
5
+ require 'webmock/rspec'
6
+ require 'nokogiri'
7
+ require 'byebug'
8
+
9
+ # Requires supporting ruby files with custom matchers and macros, etc,
10
+ # in spec/support/ and its subdirectories.
11
+ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
12
+
13
+ module LtiProvider
14
+ module UrlHelpers
15
+ def lti_provider
16
+ ::LtiProvider::Engine.routes.url_helpers
17
+ end
18
+
19
+ def main_app
20
+ ::Dummy::Application.routes.url_helpers
21
+ end
22
+ end
23
+ end
24
+
25
+ RSpec.configure do |config|
26
+ # ## Mock Framework
27
+ #
28
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
29
+ #
30
+ # config.mock_with :mocha
31
+ # config.mock_with :flexmock
32
+ # config.mock_with :rr
33
+
34
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
35
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
36
+
37
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
38
+ # examples within a transaction, remove the following line or assign false
39
+ # instead of true.
40
+ config.use_transactional_fixtures = true
41
+
42
+ # If true, the base class of anonymous controllers will be inferred
43
+ # automatically. This will be the default behavior in future versions of
44
+ # rspec-rails.
45
+ config.infer_base_class_for_anonymous_controllers = false
46
+
47
+ # Automatically infer an example group's spec type from the file location
48
+ config.infer_spec_type_from_file_location!
49
+
50
+ # Run specs in random order to surface order dependencies. If you find an
51
+ # order dependency and want to debug it, you can fix the order by providing
52
+ # the seed, which is printed after each run.
53
+ # --seed 1234
54
+ config.order = "random"
55
+
56
+ config.include LtiProvider::UrlHelpers, type: :controller
57
+ end
metadata ADDED
@@ -0,0 +1,353 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: qalam_lti_provider_engine
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.6
5
+ platform: ruby
6
+ authors:
7
+ - Dave Donahue
8
+ - Adam Anderson
9
+ - Simon Williams
10
+ - Ahmed Abdelhamid
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2021-05-22 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rails
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: '4.2'
23
+ - - "<"
24
+ - !ruby/object:Gem::Version
25
+ version: '5.3'
26
+ type: :runtime
27
+ prerelease: false
28
+ version_requirements: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '4.2'
33
+ - - "<"
34
+ - !ruby/object:Gem::Version
35
+ version: '5.3'
36
+ - !ruby/object:Gem::Dependency
37
+ name: ims-lti
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '1.2'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.2'
50
+ - !ruby/object:Gem::Dependency
51
+ name: sqlite3
52
+ requirement: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ - !ruby/object:Gem::Dependency
65
+ name: nokogiri
66
+ requirement: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ type: :development
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ - !ruby/object:Gem::Dependency
93
+ name: rspec-its
94
+ requirement: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ - !ruby/object:Gem::Dependency
107
+ name: rspec-rails
108
+ requirement: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ type: :development
114
+ prerelease: false
115
+ version_requirements: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ - !ruby/object:Gem::Dependency
121
+ name: rspec-rails-mocha
122
+ requirement: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ type: :development
128
+ prerelease: false
129
+ version_requirements: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ - !ruby/object:Gem::Dependency
135
+ name: shoulda-matchers
136
+ requirement: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ type: :development
142
+ prerelease: false
143
+ version_requirements: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ - !ruby/object:Gem::Dependency
149
+ name: webmock
150
+ requirement: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ type: :development
156
+ prerelease: false
157
+ version_requirements: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ - !ruby/object:Gem::Dependency
163
+ name: debugger
164
+ requirement: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ type: :development
170
+ prerelease: false
171
+ version_requirements: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ - !ruby/object:Gem::Dependency
177
+ name: guard-rspec
178
+ requirement: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ type: :development
184
+ prerelease: false
185
+ version_requirements: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - ">="
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ - !ruby/object:Gem::Dependency
191
+ name: rb-fsevent
192
+ requirement: !ruby/object:Gem::Requirement
193
+ requirements:
194
+ - - ">="
195
+ - !ruby/object:Gem::Version
196
+ version: '0'
197
+ type: :development
198
+ prerelease: false
199
+ version_requirements: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - ">="
202
+ - !ruby/object:Gem::Version
203
+ version: '0'
204
+ - !ruby/object:Gem::Dependency
205
+ name: byebug
206
+ requirement: !ruby/object:Gem::Requirement
207
+ requirements:
208
+ - - ">="
209
+ - !ruby/object:Gem::Version
210
+ version: '0'
211
+ type: :development
212
+ prerelease: false
213
+ version_requirements: !ruby/object:Gem::Requirement
214
+ requirements:
215
+ - - ">="
216
+ - !ruby/object:Gem::Version
217
+ version: '0'
218
+ - !ruby/object:Gem::Dependency
219
+ name: listen
220
+ requirement: !ruby/object:Gem::Requirement
221
+ requirements:
222
+ - - "~>"
223
+ - !ruby/object:Gem::Version
224
+ version: 3.0.6
225
+ type: :development
226
+ prerelease: false
227
+ version_requirements: !ruby/object:Gem::Requirement
228
+ requirements:
229
+ - - "~>"
230
+ - !ruby/object:Gem::Version
231
+ version: 3.0.6
232
+ description:
233
+ email:
234
+ - adam.anderson@12spokes.com
235
+ - simon@instructure.com
236
+ - a.hamid@nezam.io
237
+ executables: []
238
+ extensions: []
239
+ extra_rdoc_files: []
240
+ files:
241
+ - MIT-LICENSE
242
+ - README.md
243
+ - Rakefile
244
+ - app/controllers/lti_provider/application_controller.rb
245
+ - app/controllers/lti_provider/lti_application_controller.rb
246
+ - app/controllers/lti_provider/lti_controller.rb
247
+ - app/models/lti_provider/launch.rb
248
+ - app/views/layouts/lti_provider/application.html.erb
249
+ - app/views/lti_provider/lti/cookie_test.html.erb
250
+ - config/lti.yml.example
251
+ - config/lti_xml.yml.example
252
+ - config/routes.rb
253
+ - db/migrate/20130319050003_create_lti_provider_launches.rb
254
+ - lib/lti_provider.rb
255
+ - lib/lti_provider/config.rb
256
+ - lib/lti_provider/engine.rb
257
+ - lib/lti_provider/lti_application.rb
258
+ - lib/lti_provider/lti_config.rb
259
+ - lib/lti_provider/lti_xml_config.rb
260
+ - lib/lti_provider/version.rb
261
+ - lib/lti_provider/xml_config.rb
262
+ - lib/tasks/lti_provider_tasks.rake
263
+ - spec/controllers/lti_provider/lti_controller_spec.rb
264
+ - spec/dummy/Rakefile
265
+ - spec/dummy/app/controllers/application_controller.rb
266
+ - spec/dummy/app/controllers/welcome_controller.rb
267
+ - spec/dummy/config.ru
268
+ - spec/dummy/config/application.rb
269
+ - spec/dummy/config/boot.rb
270
+ - spec/dummy/config/cucumber.yml
271
+ - spec/dummy/config/database.yml
272
+ - spec/dummy/config/environment.rb
273
+ - spec/dummy/config/environments/development.rb
274
+ - spec/dummy/config/environments/production.rb
275
+ - spec/dummy/config/environments/test.rb
276
+ - spec/dummy/config/initializers/backtrace_silencers.rb
277
+ - spec/dummy/config/initializers/inflections.rb
278
+ - spec/dummy/config/initializers/mime_types.rb
279
+ - spec/dummy/config/initializers/secret_token.rb
280
+ - spec/dummy/config/initializers/session_store.rb
281
+ - spec/dummy/config/initializers/wrap_parameters.rb
282
+ - spec/dummy/config/locales/en.yml
283
+ - spec/dummy/config/lti.yml
284
+ - spec/dummy/config/lti_xml.yml
285
+ - spec/dummy/config/routes.rb
286
+ - spec/dummy/db/migrate/20130319050206_create_lti_provider_launches.lti_provider.rb
287
+ - spec/dummy/db/schema.rb
288
+ - spec/dummy/public/404.html
289
+ - spec/dummy/public/422.html
290
+ - spec/dummy/public/500.html
291
+ - spec/dummy/public/favicon.ico
292
+ - spec/dummy/public/robots.txt
293
+ - spec/dummy/script/rails
294
+ - spec/models/lti_provider/launch_spec.rb
295
+ - spec/spec_helper.rb
296
+ homepage: https://github.com/ahmedhamid13/qalam_lti_provider
297
+ licenses:
298
+ - MIT
299
+ metadata: {}
300
+ post_install_message:
301
+ rdoc_options: []
302
+ require_paths:
303
+ - lib
304
+ required_ruby_version: !ruby/object:Gem::Requirement
305
+ requirements:
306
+ - - ">="
307
+ - !ruby/object:Gem::Version
308
+ version: '0'
309
+ required_rubygems_version: !ruby/object:Gem::Requirement
310
+ requirements:
311
+ - - ">="
312
+ - !ruby/object:Gem::Version
313
+ version: '0'
314
+ requirements: []
315
+ rubygems_version: 3.2.15
316
+ signing_key:
317
+ specification_version: 4
318
+ summary: LtiProvider is a mountable engine for handling the LTI launch and exposing
319
+ LTI parameters in your rails app.
320
+ test_files:
321
+ - spec/controllers/lti_provider/lti_controller_spec.rb
322
+ - spec/dummy/Rakefile
323
+ - spec/dummy/app/controllers/application_controller.rb
324
+ - spec/dummy/app/controllers/welcome_controller.rb
325
+ - spec/dummy/config/application.rb
326
+ - spec/dummy/config/boot.rb
327
+ - spec/dummy/config/cucumber.yml
328
+ - spec/dummy/config/database.yml
329
+ - spec/dummy/config/environment.rb
330
+ - spec/dummy/config/environments/development.rb
331
+ - spec/dummy/config/environments/production.rb
332
+ - spec/dummy/config/environments/test.rb
333
+ - spec/dummy/config/initializers/backtrace_silencers.rb
334
+ - spec/dummy/config/initializers/inflections.rb
335
+ - spec/dummy/config/initializers/mime_types.rb
336
+ - spec/dummy/config/initializers/secret_token.rb
337
+ - spec/dummy/config/initializers/session_store.rb
338
+ - spec/dummy/config/initializers/wrap_parameters.rb
339
+ - spec/dummy/config/locales/en.yml
340
+ - spec/dummy/config/lti.yml
341
+ - spec/dummy/config/lti_xml.yml
342
+ - spec/dummy/config/routes.rb
343
+ - spec/dummy/config.ru
344
+ - spec/dummy/db/migrate/20130319050206_create_lti_provider_launches.lti_provider.rb
345
+ - spec/dummy/db/schema.rb
346
+ - spec/dummy/public/404.html
347
+ - spec/dummy/public/422.html
348
+ - spec/dummy/public/500.html
349
+ - spec/dummy/public/favicon.ico
350
+ - spec/dummy/public/robots.txt
351
+ - spec/dummy/script/rails
352
+ - spec/models/lti_provider/launch_spec.rb
353
+ - spec/spec_helper.rb