Skip to content

Commit

Permalink
Move allow_cors to a module instead of monkey patch
Browse files Browse the repository at this point in the history
  • Loading branch information
tstrass committed Dec 6, 2024
1 parent a3a4e1f commit 874382d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 26 deletions.
4 changes: 3 additions & 1 deletion lib/davinci_dtr_test_kit/dtr_full_ehr_suite.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
require_relative 'ext/inferno_core/runnable'
require_relative 'client_groups/dinner_static/dtr_full_ehr_questionnaire_workflow_group'
require_relative 'client_groups/dinner_adaptive/dtr_full_ehr_adaptive_dinner_questionnaire_workflow_group'
require_relative 'auth_groups/oauth2_authentication_group'
require_relative 'endpoints/cors'
require_relative 'endpoints/mock_authorization/simple_token_endpoint'
require_relative 'endpoints/mock_payer/full_ehr_questionnaire_package_endpoint'
require_relative 'endpoints/mock_payer/full_ehr_next_question_endpoint'
require_relative 'version'

module DaVinciDTRTestKit
class DTRFullEHRSuite < Inferno::TestSuite
extend CORS

id :dtr_full_ehr
title 'Da Vinci DTR Full EHR Test Suite'
description File.read(File.join(__dir__, 'docs', 'dtr_full_ehr_suite_description_v201.md'))
Expand Down
4 changes: 3 additions & 1 deletion lib/davinci_dtr_test_kit/dtr_payer_server_suite.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
require_relative 'ext/inferno_core/runnable'
require_relative 'payer_server_groups/payer_server_static_group'
require_relative 'payer_server_groups/payer_server_adaptive_group'
require_relative 'tags'
require_relative 'endpoints/cors'
require_relative 'endpoints/mock_authorization/simple_token_endpoint'
require_relative 'endpoints/mock_payer/questionnaire_package_proxy_endpoint'
require_relative 'endpoints/mock_payer/next_question_proxy_endpoint'
require_relative 'version'

module DaVinciDTRTestKit
class DTRPayerServerSuite < Inferno::TestSuite
extend CORS

id :dtr_payer_server
title 'Da Vinci DTR Payer Server Test Suite'
description File.read(File.join(__dir__, 'docs', 'dtr_payer_server_suite_description_v201.md'))
Expand Down
5 changes: 3 additions & 2 deletions lib/davinci_dtr_test_kit/dtr_smart_app_suite.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require_relative 'ext/inferno_core/runnable'
require_relative 'auth_groups/oauth2_authentication_group'
require_relative 'client_groups/resp_assist_device/dtr_smart_app_questionnaire_workflow_group'
require_relative 'client_groups/dinner_static/dtr_smart_app_questionnaire_workflow_group'
require_relative 'client_groups/dinner_adaptive/dtr_smart_app_questionnaire_workflow_group'
require_relative 'endpoints/cors'
require_relative 'endpoints/mock_authorization'
require_relative 'endpoints/mock_authorization/authorize_endpoint'
require_relative 'endpoints/mock_authorization/token_endpoint'
Expand All @@ -15,7 +15,8 @@

module DaVinciDTRTestKit
class DTRSmartAppSuite < Inferno::TestSuite
Inferno::Application['logger'].level = Logger::ERROR
extend CORS

id :dtr_smart_app
title 'Da Vinci DTR SMART App Test Suite'
description File.read(File.join(__dir__, 'docs', 'dtr_smart_app_suite_description_v201.md'))
Expand Down
20 changes: 20 additions & 0 deletions lib/davinci_dtr_test_kit/endpoints/cors.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module DaVinciDTRTestKit
module CORS
PRE_FLIGHT_HANDLER = proc do
[
200,
{
'Access-Control-Allow-Origin' => '*',
'Access-Control-Allow-Headers' => 'Content-Type, Authorization'
},
['']
]
end

def allow_cors(*paths)
paths.each do |path|
route(:options, path, PRE_FLIGHT_HANDLER)
end
end
end
end
22 changes: 0 additions & 22 deletions lib/davinci_dtr_test_kit/ext/inferno_core/runnable.rb

This file was deleted.

0 comments on commit 874382d

Please sign in to comment.