Skip to content

Commit

Permalink
Update services specs for removed errors expectation
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Jan 28, 2025
1 parent e3e84fa commit f3da80a
Showing 1 changed file with 32 additions and 93 deletions.
125 changes: 32 additions & 93 deletions spec/services/saml_request_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,12 @@

context 'when it has block_encryption turned on' do
before { sp.update!(block_encryption: 'aes256-cbc') }
let(:errors) do
{
service_provider: [t('errors.messages.no_cert_registered')],
}
end
let(:error_details) do
{
service_provider: {
no_cert_registered: true,
},
}
end

it 'returns an error' do
expect(response.to_h).to include(
errors:,
error_details:,
success: false,
errors: nil,
error_details: { service_provider: { no_cert_registered: true } },
)
end
end
Expand Down Expand Up @@ -118,14 +107,10 @@
let(:sp) { ServiceProvider.find_by(issuer: 'foo') }

it 'returns FormResponse with success: false' do
errors = {
service_provider: [t('errors.messages.unauthorized_service_provider')],
}

expect(response.to_h).to include(
success: false,
errors: errors,
error_details: hash_including(*errors.keys),
errors: nil,
error_details: { service_provider: { unauthorized_service_provider: true } },
**extra,
)
end
Expand All @@ -135,14 +120,10 @@
let(:name_id_format) { Saml::Idp::Constants::NAME_ID_FORMAT_EMAIL }

it 'returns FormResponse with success: false' do
errors = {
nameid_format: [t('errors.messages.unauthorized_nameid_format')],
}

expect(response.to_h).to include(
success: false,
errors: errors,
error_details: hash_including(*errors.keys),
errors: nil,
error_details: { nameid_format: { unauthorized_nameid_format: true } },
**extra,
)
end
Expand Down Expand Up @@ -221,14 +202,10 @@
Saml::Idp::Constants::PASSWORD_AUTHN_CONTEXT_CLASSREFS.each do |password_context|
let(:authn_context) { [password_context] }
it 'returns FormResponse with success: false for unknown authn context' do
errors = {
authn_context: [t('errors.messages.unauthorized_authn_context')],
}

expect(response.to_h).to include(
success: false,
errors: errors,
error_details: hash_including(*errors.keys),
errors: nil,
error_details: { authn_context: { unauthorized_authn_context: true } },
**extra,
)
end
Expand All @@ -240,14 +217,10 @@
let(:authn_context) { ['IAL1'] }

it 'returns FormResponse with success: false' do
errors = {
authn_context: [t('errors.messages.unauthorized_authn_context')],
}

expect(response.to_h).to include(
success: false,
errors: errors,
error_details: hash_including(*errors.keys),
errors: nil,
error_details: { authn_context: { unauthorized_authn_context: true } },
**extra,
)
end
Expand All @@ -273,14 +246,10 @@
let(:authn_context) { [ial_value] }

it 'returns FormResponse with success: false' do
errors = {
authn_context: [t('errors.messages.unauthorized_authn_context')],
}

expect(response.to_h).to include(
success: false,
errors: errors,
error_details: hash_including(*errors.keys),
errors: nil,
error_details: { authn_context: { unauthorized_authn_context: true } },
**extra,
)
end
Expand All @@ -291,14 +260,10 @@
let(:authn_context) { [Saml::Idp::Constants::IALMAX_AUTHN_CONTEXT_CLASSREF] }

it 'returns FormResponse with success: false' do
errors = {
authn_context: [t('errors.messages.unauthorized_authn_context')],
}

expect(response.to_h).to include(
success: false,
errors: errors,
error_details: hash_including(*errors.keys),
errors: nil,
error_details: { authn_context: { unauthorized_authn_context: true } },
**extra,
)
end
Expand Down Expand Up @@ -331,14 +296,10 @@
end

it 'fails with an unauthorized error' do
errors = {
authn_context: [t('errors.messages.unauthorized_authn_context')],
}

expect(response.to_h).to include(
success: false,
errors: errors,
error_details: hash_including(*errors.keys),
errors: nil,
error_details: { authn_context: { unauthorized_authn_context: true } },
**extra,
)
end
Expand Down Expand Up @@ -390,15 +351,13 @@
let(:authn_context) { ['IAL1'] }

it 'returns FormResponse with success: false' do
errors = {
authn_context: [t('errors.messages.unauthorized_authn_context')],
service_provider: [t('errors.messages.unauthorized_service_provider')],
}

expect(response.to_h).to include(
success: false,
errors: errors,
error_details: hash_including(*errors.keys),
errors: nil,
error_details: {
authn_context: { unauthorized_authn_context: true },
service_provider: { unauthorized_service_provider: true },
},
**extra,
)
end
Expand All @@ -408,14 +367,10 @@
let(:name_id_format) { Saml::Idp::Constants::NAME_ID_FORMAT_EMAIL }

it 'returns FormResponse with success: false with unauthorized nameid format' do
errors = {
nameid_format: [t('errors.messages.unauthorized_nameid_format')],
}

expect(response.to_h).to include(
success: false,
errors: errors,
error_details: hash_including(*errors.keys),
errors: nil,
error_details: { nameid_format: { unauthorized_nameid_format: true } },
**extra,
)
end
Expand Down Expand Up @@ -453,14 +408,10 @@
before { sp.update!(ial: 1) }

it 'returns FormResponse with success false' do
errors = {
authn_context: [t('errors.messages.unauthorized_authn_context')],
}

expect(response.to_h).to include(
success: false,
errors: errors,
error_details: hash_including(*errors.keys),
errors: nil,
error_details: { authn_context: { unauthorized_authn_context: true } },
**extra,
)
end
Expand All @@ -472,14 +423,10 @@
before { sp.update!(ial: 1) }

it 'returns FormResponse with success false' do
errors = {
authn_context: [t('errors.messages.unauthorized_authn_context')],
}

expect(response.to_h).to include(
success: false,
errors: errors,
error_details: hash_including(*errors.keys),
errors: nil,
error_details: { authn_context: { unauthorized_authn_context: true } },
**extra,
)
end
Expand All @@ -490,14 +437,10 @@
let(:authn_context) { ['C1'] }

it 'returns FormResponse with success false' do
errors = {
authn_context: [t('errors.messages.unauthorized_authn_context')],
}

expect(response.to_h).to include(
success: false,
errors: errors,
error_details: hash_including(*errors.keys),
errors: nil,
error_details: { authn_context: { unauthorized_authn_context: true } },
**extra,
)
end
Expand All @@ -507,14 +450,10 @@
let(:authn_context) { ['Fa.Ke.Va.Lu.E0'] }

it 'returns FormResponse with success false' do
errors = {
authn_context: [t('errors.messages.unauthorized_authn_context')],
}

expect(response.to_h).to include(
success: false,
errors: errors,
error_details: hash_including(*errors.keys),
errors: nil,
error_details: { authn_context: { unauthorized_authn_context: true } },
**extra,
)
end
Expand Down

0 comments on commit f3da80a

Please sign in to comment.