generated from inferno-framework/inferno-template
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FI-3064: Fix v2 scope check in EHR Launch with Patient Scopes (#558)
* add passing patient scope test specs * add spec for separate read and search scopes * support receiving read and search scopes separately * remove old spec
- Loading branch information
1 parent
f6ce4f5
commit 34e8874
Showing
4 changed files
with
110 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
spec/onc_certification_g10_test_kit/patient_scope_test_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
RSpec.describe ONCCertificationG10TestKit::PatientScopeTest do | ||
def run(runnable, inputs = {}) | ||
test_run_params = { test_session_id: test_session.id }.merge(runnable.reference_hash) | ||
test_run = Inferno::Repositories::TestRuns.new.create(test_run_params) | ||
inputs.each do |name, value| | ||
session_data_repo.save( | ||
test_session_id: test_session.id, | ||
name:, | ||
value:, | ||
type: runnable.config.input_type(name) | ||
) | ||
end | ||
Inferno::TestRunner.new(test_session:, test_run:).run(runnable) | ||
end | ||
|
||
let(:test_session) { repo_create(:test_session, test_suite_id: 'g10_certification') } | ||
let(:session_data_repo) { Inferno::Repositories::SessionData.new } | ||
let(:test) { described_class } | ||
|
||
context 'with v1 scopes' do | ||
let(:received_scopes) { 'launch openid fhirUser patient/Patient.read' } | ||
|
||
it 'passes when a patient scope is received' do | ||
result = run(test, received_scopes:) | ||
|
||
expect(result.result).to eq('pass') | ||
end | ||
|
||
it 'fails when a patient scope is not received' do | ||
received_scopes.gsub!('patient/', 'user/') | ||
result = run(test, received_scopes:) | ||
|
||
expect(result.result).to eq('fail') | ||
expect(result.result_message).to match(/No scope matching/) | ||
end | ||
end | ||
|
||
context 'with v2 scopes' do | ||
let(:received_scopes) { 'launch openid fhirUser patient/Patient.rs' } | ||
|
||
before do | ||
allow_any_instance_of(test).to receive(:scope_version).and_return(:v2) | ||
end | ||
|
||
it 'passes when patient read and search scopes are received together' do | ||
result = run(test, received_scopes:) | ||
|
||
expect(result.result).to eq('pass') | ||
end | ||
|
||
it 'passes when patient read and search scopes are received separately' do | ||
received_scopes.gsub!('.rs', '.r') | ||
received_scopes.concat(' patient/Patient.s') | ||
|
||
result = run(test, received_scopes:) | ||
|
||
expect(result.result).to eq('pass') | ||
end | ||
|
||
it 'fails when a patient read and search scopes are not received' do | ||
received_scopes.gsub!('patient/', 'user/') | ||
result = run(test, received_scopes:) | ||
|
||
expect(result.result).to eq('fail') | ||
expect(result.result_message).to match(/No scope matching/) | ||
end | ||
|
||
it 'fails if both read and search scopes are not received' do | ||
received_scopes.gsub!('.rs', '.r') | ||
|
||
result = run(test, received_scopes:) | ||
|
||
expect(result.result).to eq('fail') | ||
expect(result.result_message).to match(/No scope matching/) | ||
end | ||
end | ||
end |
46 changes: 0 additions & 46 deletions
46
spec/onc_certification_g10_test_kit/smart_ehr_patient_launch_group_spec.rb
This file was deleted.
Oops, something went wrong.
46 changes: 0 additions & 46 deletions
46
spec/onc_certification_g10_test_kit/smart_ehr_patient_launch_group_stu2_spec.rb
This file was deleted.
Oops, something went wrong.