From f3da80a0ef281d7e51fec83274cd5cfadb9ab8a1 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Tue, 28 Jan 2025 11:15:07 -0500 Subject: [PATCH] Update services specs for removed errors expectation --- spec/services/saml_request_validator_spec.rb | 125 +++++-------------- 1 file changed, 32 insertions(+), 93 deletions(-) diff --git a/spec/services/saml_request_validator_spec.rb b/spec/services/saml_request_validator_spec.rb index 4a5bbf833d6..42619fd20ed 100644 --- a/spec/services/saml_request_validator_spec.rb +++ b/spec/services/saml_request_validator_spec.rb @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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