Skip to content

Commit

Permalink
Add access_token to rspec tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elsaperelli committed Oct 10, 2024
1 parent 86c3c51 commit da71451
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
16 changes: 16 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ PATH
specs:
inferno_template (0.0.1)
inferno_core (~> 0.4.38)
smart_app_launch_test_kit (~> 0.4.3)

GEM
remote: https://rubygems.org/
Expand All @@ -15,11 +16,13 @@ GEM
zeitwerk (~> 2.3)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
aes_key_wrap (1.1.0)
base62-rb (0.3.1)
base64 (0.2.0)
bcp47 (0.3.3)
i18n
bigdecimal (3.1.8)
bindata (2.5.0)
blueprinter (0.25.2)
byebug (11.1.3)
coderay (1.1.3)
Expand Down Expand Up @@ -130,6 +133,7 @@ GEM
http-accept (1.7.0)
http-cookie (1.0.6)
domain_name (~> 0.5)
httpclient (2.8.3)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
inferno_core (0.4.38)
Expand Down Expand Up @@ -162,6 +166,11 @@ GEM
irb (1.13.1)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
json-jwt (1.15.3.1)
activesupport (>= 4.2)
aes_key_wrap
bindata
httpclient
jwt (2.8.1)
base64
kramdown (2.4.0)
Expand Down Expand Up @@ -255,6 +264,11 @@ GEM
connection_pool (>= 2.3.0)
rack (>= 2.2.4)
redis-client (>= 0.19.0)
smart_app_launch_test_kit (0.4.4)
inferno_core (>= 0.4.2)
json-jwt (~> 1.15.3)
jwt (~> 2.6)
tls_test_kit (~> 0.2.0)
sqlite3 (1.7.3)
mini_portile2 (~> 2.8.0)
sqlite3 (1.7.3-aarch64-linux)
Expand All @@ -272,6 +286,8 @@ GEM
strscan (3.1.0)
thor (1.2.2)
tilt (2.3.0)
tls_test_kit (0.2.2)
inferno_core (>= 0.4.2)
tty-color (0.6.0)
tty-markdown (0.7.2)
kramdown (>= 1.16.2, < 3.0)
Expand Down
15 changes: 8 additions & 7 deletions spec/inferno_template/patient_group_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
RSpec.describe InfernoTemplate::PatientGroup do
let(:suite) { Inferno::Repositories::TestSuites.new.find('inferno_template_test_suite') }
let(:group) { suite.groups[1] }
let(:group) { suite.groups[1].groups[1] }
let(:session_data_repo) { Inferno::Repositories::SessionData.new }
let(:test_session) { repo_create(:test_session, test_suite_id: 'inferno_template_test_suite') }
let(:url) { 'http://example.com/fhir' }
let(:access_token) { 'SAMPLE_TOKEN' }
let(:success_outcome) do
{
outcomes: [{
Expand Down Expand Up @@ -43,7 +44,7 @@ def run(runnable, inputs = {})
stub_request(:get, "#{url}/Patient/#{patient_id}")
.to_return(status: 200, body: resource.to_json)

result = run(test, url: url, patient_id: patient_id)
result = run(test, url: url, patient_id: patient_id, access_token: access_token)

expect(result.result).to eq('pass')
end
Expand All @@ -53,7 +54,7 @@ def run(runnable, inputs = {})
stub_request(:get, "#{url}/Patient/#{patient_id}")
.to_return(status: 201, body: resource.to_json)

result = run(test, url: url, patient_id: patient_id)
result = run(test, url: url, patient_id: patient_id, access_token: access_token)

expect(result.result).to eq('fail')
expect(result.result_message).to match(/200/)
Expand All @@ -64,7 +65,7 @@ def run(runnable, inputs = {})
stub_request(:get, "#{url}/Patient/#{patient_id}")
.to_return(status: 200, body: resource.to_json)

result = run(test, url: url, patient_id: patient_id)
result = run(test, url: url, patient_id: patient_id, access_token: access_token)

expect(result.result).to eq('fail')
expect(result.result_message).to match(/Patient/)
Expand All @@ -75,7 +76,7 @@ def run(runnable, inputs = {})
stub_request(:get, "#{url}/Patient/#{patient_id}")
.to_return(status: 200, body: resource.to_json)

result = run(test, url: url, patient_id: patient_id)
result = run(test, url: url, patient_id: patient_id, access_token: access_token)

expect(result.result).to eq('fail')
expect(result.result_message).to match(/resource with id/)
Expand All @@ -98,7 +99,7 @@ def run(runnable, inputs = {})
response_body: resource.to_json
)

result = run(test, url: url)
result = run(test, url: url, access_token: access_token)

expect(result.result).to eq('pass')
end
Expand All @@ -116,7 +117,7 @@ def run(runnable, inputs = {})
response_body: resource.to_json
)

result = run(test, url: url)
result = run(test, url: url, access_token: access_token)

expect(result.result).to eq('fail')
end
Expand Down

0 comments on commit da71451

Please sign in to comment.