Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class RegistrationFailureInvalidContentsTest < Inferno::Test
description %(
The [UDAP IG Section 3.1](https://hl7.org/fhir/us/udap-security/STU1/registration.html#software-statement) states:
> The unique client URI used for the iss claim SHALL match the uriName entry in the Subject Alternative Name
> extension of the client app operator’s X.509 certificate, and SHALL uniquely identify a single client app
> extension of the client app operator’s X.509 certificate, and SHALL uniquelys identify a single client app
> operator and application over time

The [UDAP IG Section 3.2.3](https://hl7.org/fhir/us/udap-security/STU1/registration.html#request-body) states:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

RSpec.describe UDAPSecurityTestKit::AuthorizationCodeRedirectTest, :request do
let(:suite_id) { 'udap_security' }
let(:test) { Inferno::Repositories::Tests.new.find('udap_authorization_code_redirect') }
let(:session_data_repo) { Inferno::Repositories::SessionData.new }
let(:test) { find_test(suite, 'udap_authorization_code_redirect') }
let(:url) { 'http://example.com/fhir' }
let(:results_repo) { Inferno::Repositories::Results.new }
let(:requests_repo) { Inferno::Repositories::Requests.new }
let(:test_session) { repo_create(:test_session, test_suite_id: 'udap_security') }
let(:url) { 'http://example.com/fhir' }
let(:inputs) do
{
udap_fhir_base_url: url,
Expand All @@ -23,22 +21,6 @@
}
end

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|
type = runnable.config.input_type(name)
type = 'text' if type == 'radio'
session_data_repo.save(
test_session_id: test_session.id,
name:,
value:,
type:
)
end
Inferno::TestRunner.new(test_session:, test_run:).run(runnable)
end

context "when optional 'scope' and 'aud' inputs are omitted" do
it 'waits and then passes when it receives a request with the correct state' do
allow(test).to receive(:parent).and_return(Inferno::TestGroup)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

RSpec.describe UDAPSecurityTestKit::AuthorizationCodeTokenExchangeTest do
let(:suite_id) { 'udap_security' }
let(:runnable) { Inferno::Repositories::Tests.new.find('udap_authorization_code_token_exchange') }
let(:session_data_repo) { Inferno::Repositories::SessionData.new }
let(:results_repo) { Inferno::Repositories::Results.new }
let(:test_session) { repo_create(:test_session, test_suite_id: 'udap_security') }
let(:runnable) { find_test(suite, 'udap_authorization_code_token_exchange') }
let(:udap_auth_code_flow_client_cert_pem) do
UDAPSecurityTestKit::DefaultCertFileLoader.load_test_client_cert_pem_file
end
Expand Down Expand Up @@ -40,20 +37,6 @@ def create_redirect_request(url)
)
end

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

it 'passes if the token response has a 200 status' do
create_redirect_request('http://example.com/redirect?code=CODE')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,7 @@

RSpec.describe UDAPSecurityTestKit::AuthorizationEndpointFieldTest do
let(:suite_id) { 'udap_security' }
let(:runnable) { Inferno::Repositories::Tests.new.find('udap_authorization_endpoint_field') }
let(:session_data_repo) { Inferno::Repositories::SessionData.new }
let(:results_repo) { Inferno::Repositories::Results.new }
let(:test_session) { repo_create(:test_session, test_suite_id: 'udap_security') }

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(:runnable) { find_test(suite, 'udap_authorization_endpoint_field') }

it 'skips if grant_types_supported field is not present' do
config = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@

RSpec.describe UDAPSecurityTestKit::ClientCredentialsTokenExchangeTest do
let(:suite_id) { 'udap_security' }
let(:runnable) { Inferno::Repositories::Tests.new.find('udap_client_credentials_token_exchange') }
let(:session_data_repo) { Inferno::Repositories::SessionData.new }
let(:results_repo) { Inferno::Repositories::Results.new }
let(:test_session) { repo_create(:test_session, test_suite_id: 'udap_security') }
let(:runnable) { find_test(suite, 'udap_client_credentials_token_exchange') }
let(:udap_client_credentials_flow_client_cert_pem) do
UDAPSecurityTestKit::DefaultCertFileLoader.load_test_client_cert_pem_file
end
Expand All @@ -17,7 +14,6 @@

let(:base_url) { 'http://example.com/fhir' }
let(:udap_token_endpoint) { 'http://example.com/token' }

let(:input) do
{
udap_token_endpoint:,
Expand All @@ -28,20 +24,6 @@
}
end

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

it 'passes if the token response has a 200 status' do
stub_request(:post, udap_token_endpoint)
.to_return(status: 200, body: {}.to_json)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,9 @@

RSpec.describe UDAPSecurityTestKit::GrantTypesSupportedFieldTest do
let(:suite_id) { 'udap_security' }
let(:runnable) { Inferno::Repositories::Tests.new.find('udap_grant_types_supported_field') }
let(:session_data_repo) { Inferno::Repositories::SessionData.new }
let(:results_repo) { Inferno::Repositories::Results.new }
let(:test_session) { repo_create(:test_session, test_suite_id: 'udap_security') }
let(:runnable) { find_test(suite, 'udap_grant_types_supported_field') }
let(:required_flow_type) { [''] }

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

context 'when the server can support any authorization flow(s)' do
it 'fails if field is not present' do
config = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,7 @@

RSpec.describe UDAPSecurityTestKit::RegEndpointJWTSigningAlgValuesSupportedFieldTest do
let(:suite_id) { 'udap_security' }
let(:runnable) { Inferno::Repositories::Tests.new.find('udap_reg_endpoint_jwt_signing_alg_values_supported_field') }
let(:session_data_repo) { Inferno::Repositories::SessionData.new }
let(:results_repo) { Inferno::Repositories::Results.new }
let(:test_session) { repo_create(:test_session, test_suite_id: 'udap_security') }

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(:runnable) { find_test(suite, 'udap_reg_endpoint_jwt_signing_alg_values_supported_field') }

it 'omits if field is not present' do
config = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,7 @@

RSpec.describe UDAPSecurityTestKit::RegistrationEndpointFieldTest do
let(:suite_id) { 'udap_security' }
let(:runnable) { Inferno::Repositories::Tests.new.find('udap_registration_endpoint_field') }
let(:session_data_repo) { Inferno::Repositories::SessionData.new }
let(:results_repo) { Inferno::Repositories::Results.new }
let(:test_session) { repo_create(:test_session, test_suite_id: 'udap_security') }

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(:runnable) { find_test(suite, 'udap_registration_endpoint_field') }

it 'fails if field is not present' do
config = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@

RSpec.describe UDAPSecurityTestKit::RegistrationFailureInvalidContentsTest do
let(:suite_id) { 'udap_security' }
let(:runnable) { Inferno::Repositories::Tests.new.find('udap_registration_failure_invalid_contents') }
let(:session_data_repo) { Inferno::Repositories::SessionData.new }
let(:results_repo) { Inferno::Repositories::Results.new }
let(:test_session) { repo_create(:test_session, test_suite_id: 'udap_security') }
let(:runnable) { find_test(suite, 'udap_registration_failure_invalid_contents') }
let(:udap_client_cert_pem) do
UDAPSecurityTestKit::DefaultCertFileLoader.load_test_client_cert_pem_file
end
Expand All @@ -28,31 +25,19 @@
udap_jwt_signing_alg:,
udap_registration_requested_scope:,
udap_registration_grant_type:,
udap_registration_certifications:
udap_registration_certifications:,
udap_auth_code_flow_client_registration_status: 'update',
udap_auth_code_flow_cert_iss: 'https://inferno.healthit.gov'
}
end

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

it 'fails if response status is not 400' do
stub_request(:post, udap_registration_endpoint)
.to_return(status: 200, body: {}.to_json)

result = run(runnable, input)

expect(result.result).to eq('fail')
expect(result.result).to eq('fail'), result.result_message
end

it 'passes when response status is 400' do
Expand All @@ -61,6 +46,6 @@ def run(runnable, inputs = {})

result = run(runnable, input)

expect(result.result).to eq('pass')
expect(result.result).to eq('pass'), result.result_message
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@

RSpec.describe UDAPSecurityTestKit::RegistrationFailureInvalidJWTSignatureTest do
let(:suite_id) { 'udap_security' }
let(:runnable) { Inferno::Repositories::Tests.new.find('udap_registration_failure_invalid_jwt_signature') }
let(:session_data_repo) { Inferno::Repositories::SessionData.new }
let(:results_repo) { Inferno::Repositories::Results.new }
let(:test_session) { repo_create(:test_session, test_suite_id: 'udap_security') }
let(:runnable) { find_test(suite, 'udap_registration_failure_invalid_jwt_signature') }
let(:udap_client_cert_pem) do
UDAPSecurityTestKit::DefaultCertFileLoader.load_test_client_cert_pem_file
end
Expand All @@ -17,6 +14,15 @@
let(:udap_registration_requested_scope) { 'system/*' }
let(:udap_registration_grant_type) { 'client_credentials' }
let(:udap_registration_certifications) { '' }
let(:udap_auth_code_flow_client_registration_status) { 'update' }
let(:udap_auth_code_flow_client_cert_pem) do
UDAPSecurityTestKit::DefaultCertFileLoader.load_test_client_cert_pem_file
end

let(:udap_auth_code_flow_client_private_key) do
UDAPSecurityTestKit::DefaultCertFileLoader.load_test_client_private_key_file
end

let(:input) do
{
udap_client_cert_pem:,
Expand All @@ -25,31 +31,19 @@
udap_jwt_signing_alg:,
udap_registration_requested_scope:,
udap_registration_grant_type:,
udap_registration_certifications:
udap_registration_certifications:,
udap_auth_code_flow_client_registration_status:,
udap_auth_code_flow_client_private_key:
}
end

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

it 'fails if response status is not 400' do
stub_request(:post, udap_registration_endpoint)
.to_return(status: 200, body: {}.to_json)

result = run(runnable, input)

expect(result.result).to eq('fail')
expect(result.result).to eq('fail'), result.result_message
end

it 'passes when response status is 400' do
Expand All @@ -58,6 +52,6 @@ def run(runnable, inputs = {})

result = run(runnable, input)

expect(result.result).to eq('pass')
expect(result.result).to eq('pass'), result.result_message
end
end
Loading