diff --git a/app/forms/webauthn_visit_form.rb b/app/forms/webauthn_visit_form.rb index 96f4f9e2bd7..a263dd56322 100644 --- a/app/forms/webauthn_visit_form.rb +++ b/app/forms/webauthn_visit_form.rb @@ -41,10 +41,9 @@ def check_params(params) return unless error if @platform_authenticator - errors.add error, translate_platform_authenticator_error(error), - type: :"#{translate_platform_authenticator_error(error).split('.').last}" + errors.add error, translate_platform_authenticator_error(error), type: :invalid else - errors.add error, translate_error(error), type: :"#{translate_error(error).split('.').last}" + errors.add error, translate_error(error), type: :invalid end end diff --git a/app/services/form_response.rb b/app/services/form_response.rb index a2b86a77d09..c7c2f5dc98c 100644 --- a/app/services/form_response.rb +++ b/app/services/form_response.rb @@ -19,7 +19,7 @@ def success? def to_h hash = { success: success } - hash[:errors] = errors.presence if !serialize_error_details_only? + hash[:errors] = (!defined?(@error_details) && errors).presence if !serialize_error_details_only? hash[:error_details] = flatten_details(error_details) if error_details.present? hash.merge!(extra) hash diff --git a/spec/controllers/account_reset/cancel_controller_spec.rb b/spec/controllers/account_reset/cancel_controller_spec.rb index e97a28913e3..beebab93c85 100644 --- a/spec/controllers/account_reset/cancel_controller_spec.rb +++ b/spec/controllers/account_reset/cancel_controller_spec.rb @@ -32,7 +32,6 @@ expect(@analytics).to have_logged_event( 'Account Reset: cancel', success: false, - errors: { token: [t('errors.account_reset.cancel_token_invalid', app_name: APP_NAME)] }, error_details: { token: { cancel_token_invalid: true }, }, @@ -48,7 +47,6 @@ expect(@analytics).to have_logged_event( 'Account Reset: cancel', success: false, - errors: { token: [t('errors.account_reset.cancel_token_missing', app_name: APP_NAME)] }, error_details: { token: { blank: true } }, user_id: 'anonymous-uuid', ) @@ -92,7 +90,6 @@ 'Account Reset: cancel token validation', user_id: 'anonymous-uuid', success: false, - errors: { token: [t('errors.account_reset.cancel_token_invalid', app_name: APP_NAME)] }, error_details: { token: { cancel_token_invalid: true }, }, diff --git a/spec/controllers/account_reset/delete_account_controller_spec.rb b/spec/controllers/account_reset/delete_account_controller_spec.rb index 94b847b35d5..b4ba6dfce7b 100644 --- a/spec/controllers/account_reset/delete_account_controller_spec.rb +++ b/spec/controllers/account_reset/delete_account_controller_spec.rb @@ -6,7 +6,6 @@ let(:invalid_token_message) do t('errors.account_reset.granted_token_invalid', app_name: APP_NAME) end - let(:invalid_token_error) { { token: [invalid_token_message] } } before { stub_analytics } describe '#delete' do @@ -45,7 +44,6 @@ 'Account Reset: delete', user_id: 'anonymous-uuid', success: false, - errors: invalid_token_error, error_details: { token: { granted_token_invalid: true } }, mfa_method_counts: {}, identity_verified: false, @@ -63,7 +61,6 @@ 'Account Reset: delete', user_id: 'anonymous-uuid', success: false, - errors: { token: [t('errors.account_reset.granted_token_missing', app_name: APP_NAME)] }, error_details: { token: { blank: true } }, mfa_method_counts: {}, identity_verified: false, @@ -91,7 +88,6 @@ 'Account Reset: delete', user_id: user.uuid, success: false, - errors: { token: [t('errors.account_reset.granted_token_expired', app_name: APP_NAME)] }, error_details: { token: { granted_token_expired: true } }, mfa_method_counts: {}, identity_verified: false, @@ -179,7 +175,6 @@ 'Account Reset: granted token validation', user_id: 'anonymous-uuid', success: false, - errors: invalid_token_error, error_details: { token: { granted_token_invalid: true } }, ) expect(response).to redirect_to(root_url) @@ -199,7 +194,6 @@ 'Account Reset: granted token validation', user_id: user.uuid, success: false, - errors: { token: [t('errors.account_reset.granted_token_expired', app_name: APP_NAME)] }, error_details: { token: { granted_token_expired: true } }, ) expect(response).to redirect_to(root_url) diff --git a/spec/controllers/concerns/two_factor_authenticatable_methods_spec.rb b/spec/controllers/concerns/two_factor_authenticatable_methods_spec.rb index 8bd4e65e97d..d83d4ecd833 100644 --- a/spec/controllers/concerns/two_factor_authenticatable_methods_spec.rb +++ b/spec/controllers/concerns/two_factor_authenticatable_methods_spec.rb @@ -184,7 +184,6 @@ expect(@analytics).to have_logged_event( 'Multi-Factor Authentication', success: false, - errors: { code: ['pattern_mismatch'] }, error_details: { code: { pattern_mismatch: true } }, multi_factor_auth_method: TwoFactorAuthenticatable::AuthMethod::SMS, enabled_mfa_methods_count: 1, diff --git a/spec/controllers/event_disavowal_controller_spec.rb b/spec/controllers/event_disavowal_controller_spec.rb index 3ca8d2d91ee..0f0f8bb309e 100644 --- a/spec/controllers/event_disavowal_controller_spec.rb +++ b/spec/controllers/event_disavowal_controller_spec.rb @@ -48,7 +48,6 @@ build_analytics_hash( user_id: event.user.uuid, success: false, - errors: { event: [t('event_disavowals.errors.event_already_disavowed')] }, error_details: { event: { event_already_disavowed: true } }, ), ) @@ -64,7 +63,6 @@ build_analytics_hash( user_id: event.user.uuid, success: false, - errors: { event: [t('event_disavowals.errors.event_already_disavowed')] }, error_details: { event: { event_already_disavowed: true } }, ), ) @@ -102,13 +100,6 @@ build_analytics_hash( user_id: event.user.uuid, success: false, - errors: { - password: [ - t( - 'errors.attributes.password.too_short.other', count: Devise.password_length.first - ), - ], - }, error_details: { password: { too_short: true } }, ), ) @@ -127,7 +118,6 @@ build_analytics_hash( user_id: event.user.uuid, success: false, - errors: { password: ['Password must be at least 12 characters long'] }, error_details: { password: { too_short: true } }, ), ) @@ -151,7 +141,6 @@ build_analytics_hash( user_id: event.user.uuid, success: false, - errors: { event: [t('event_disavowals.errors.event_already_disavowed')] }, error_details: { event: { event_already_disavowed: true } }, ), ) @@ -173,9 +162,6 @@ 'Event disavowal token invalid', build_analytics_hash( success: false, - errors: { - user: [t('event_disavowals.errors.no_account')], - }, error_details: { user: { blank: true }, }, @@ -185,12 +171,11 @@ end end - def build_analytics_hash(success: true, errors: nil, error_details: nil, user_id: nil) + def build_analytics_hash(success: true, error_details: nil, user_id: nil) { event_created_at: event.created_at, disavowed_device_last_used_at: event.device&.last_used_at, success:, - errors:, error_details:, event_id: event.id, event_type: event.event_type, diff --git a/spec/controllers/idv/by_mail/enter_code_controller_spec.rb b/spec/controllers/idv/by_mail/enter_code_controller_spec.rb index 24102dbc1ea..7126a4c95f4 100644 --- a/spec/controllers/idv/by_mail/enter_code_controller_spec.rb +++ b/spec/controllers/idv/by_mail/enter_code_controller_spec.rb @@ -163,7 +163,6 @@ end describe '#create' do - let(:otp_code_error_message) { { otp: [t('errors.messages.confirmation_code_incorrect')] } } let(:success_properties) { { success: true } } context 'user does not have a pending profile' do @@ -382,7 +381,6 @@ expect(@analytics).to have_logged_event( 'IdV: enter verify by mail code submitted', success: false, - errors: otp_code_error_message, pending_in_person_enrollment: false, fraud_check_failed: false, letter_count: 1, @@ -416,7 +414,6 @@ it 'redirects to the rate limited index page to show errors' do analytics_args = { success: false, - errors: otp_code_error_message, pending_in_person_enrollment: false, fraud_check_failed: false, letter_count: 1, @@ -450,11 +447,11 @@ failed_gpo_submission_events = @analytics.events['IdV: enter verify by mail code submitted'] - .reject { |event_attributes| event_attributes[:errors].blank? } + .reject { |event_attributes| event_attributes[:error_details].blank? } successful_gpo_submission_events = @analytics.events['IdV: enter verify by mail code submitted'] - .select { |event_attributes| event_attributes[:errors].blank? } + .select { |event_attributes| event_attributes[:error_details].blank? } expect(failed_gpo_submission_events.count).to eq(max_attempts - 1) expect(successful_gpo_submission_events.count).to eq(1) diff --git a/spec/controllers/idv/how_to_verify_controller_spec.rb b/spec/controllers/idv/how_to_verify_controller_spec.rb index d5a450e99be..29fb81ae104 100644 --- a/spec/controllers/idv/how_to_verify_controller_spec.rb +++ b/spec/controllers/idv/how_to_verify_controller_spec.rb @@ -171,7 +171,6 @@ step: 'how_to_verify', analytics_id: 'Doc Auth', error_details: { selection: { blank: true } }, - errors: { selection: ['Select a way to verify your identity.'] }, success: false, } end @@ -191,7 +190,6 @@ analytics_id: 'Doc Auth', selection:, error_details: { selection: { inclusion: true } }, - errors: { selection: ['Select a way to verify your identity.'] }, success: false, } end diff --git a/spec/controllers/idv/image_uploads_controller_spec.rb b/spec/controllers/idv/image_uploads_controller_spec.rb index 545301c94f7..c35528847ef 100644 --- a/spec/controllers/idv/image_uploads_controller_spec.rb +++ b/spec/controllers/idv/image_uploads_controller_spec.rb @@ -103,9 +103,6 @@ expect(@analytics).to have_logged_event( 'IdV: doc auth image upload form submitted', success: false, - errors: { - front: [I18n.t('doc_auth.errors.not_a_file')], - }, error_details: { front: { not_a_file: true }, }, @@ -219,9 +216,6 @@ expect(@analytics).to have_logged_event( 'IdV: doc auth image upload form submitted', success: false, - errors: { - limit: [I18n.t('doc_auth.errors.rate_limited_heading')], - }, error_details: { limit: { rate_limited: true }, }, @@ -520,9 +514,6 @@ expect(@analytics).to have_logged_event( 'IdV: doc auth image upload vendor pii validation', success: false, - errors: { - name: [I18n.t('doc_auth.errors.alerts.full_name_check')], - }, error_details: { name: { name: true }, }, @@ -598,9 +589,6 @@ expect(@analytics).to have_logged_event( 'IdV: doc auth image upload vendor pii validation', success: false, - errors: { - state: [I18n.t('doc_auth.errors.general.no_liveness')], - }, error_details: { state: { inclusion: true }, }, @@ -676,9 +664,6 @@ expect(@analytics).to have_logged_event( 'IdV: doc auth image upload vendor pii validation', success: false, - errors: { - state_id_number: [I18n.t('doc_auth.errors.general.no_liveness')], - }, error_details: { state_id_number: { blank: true }, }, @@ -750,9 +735,6 @@ expect(@analytics).to have_logged_event( 'IdV: doc auth image upload vendor pii validation', success: false, - errors: { - dob: [I18n.t('doc_auth.errors.alerts.birth_date_checks')], - }, error_details: { dob: { dob: true }, }, @@ -825,11 +807,6 @@ expect(@analytics).to have_logged_event( 'IdV: doc auth image upload vendor pii validation', success: false, - errors: { - state_id_expiration: [ - 'Try taking new pictures.', - ], - }, error_details: { state_id_expiration: { state_id_expiration: true }, }, diff --git a/spec/controllers/idv/in_person/ssn_controller_spec.rb b/spec/controllers/idv/in_person/ssn_controller_spec.rb index 48fef202097..da9ea25d4ef 100644 --- a/spec/controllers/idv/in_person/ssn_controller_spec.rb +++ b/spec/controllers/idv/in_person/ssn_controller_spec.rb @@ -197,9 +197,6 @@ flow_path: 'standard', step: 'ssn', success: false, - errors: { - ssn: ['Enter a nine-digit Social Security number'], - }, error_details: { ssn: { invalid: true } }, } end diff --git a/spec/controllers/idv/phone_controller_spec.rb b/spec/controllers/idv/phone_controller_spec.rb index e572dd1a4ee..90f60af5356 100644 --- a/spec/controllers/idv/phone_controller_spec.rb +++ b/spec/controllers/idv/phone_controller_spec.rb @@ -290,10 +290,6 @@ expect(@analytics).to have_logged_event( 'IdV: phone confirmation form', success: false, - errors: { - phone: [improbable_phone_message], - otp_delivery_preference: [improbable_otp_message], - }, error_details: { phone: { improbable_phone: true }, otp_delivery_preference: { inclusion: true }, diff --git a/spec/controllers/idv/ssn_controller_spec.rb b/spec/controllers/idv/ssn_controller_spec.rb index 22f315c532a..fbc9c012cdd 100644 --- a/spec/controllers/idv/ssn_controller_spec.rb +++ b/spec/controllers/idv/ssn_controller_spec.rb @@ -234,9 +234,6 @@ flow_path: 'standard', step: 'ssn', success: false, - errors: { - ssn: [t('idv.errors.pattern_mismatch.ssn')], - }, error_details: { ssn: { invalid: true } }, } end diff --git a/spec/controllers/openid_connect/authorization_controller_spec.rb b/spec/controllers/openid_connect/authorization_controller_spec.rb index f1e5572af78..5b93ceffad8 100644 --- a/spec/controllers/openid_connect/authorization_controller_spec.rb +++ b/spec/controllers/openid_connect/authorization_controller_spec.rb @@ -2009,7 +2009,6 @@ prompt: '', allow_prompt_login: true, unauthorized_scope: true, - errors: hash_including(:prompt), error_details: hash_including(:prompt), user_fully_authenticated: true, acr_values: acr_values, @@ -2071,7 +2070,6 @@ prompt:, allow_prompt_login: true, unauthorized_scope: false, - errors: hash_including(:acr_values), error_details: hash_including(:acr_values), user_fully_authenticated: true, acr_values: '', @@ -2237,7 +2235,6 @@ prompt: '', allow_prompt_login: true, unauthorized_scope: true, - errors: hash_including(:prompt), error_details: hash_including(:prompt), user_fully_authenticated: true, acr_values: '', @@ -2276,7 +2273,6 @@ success: false, prompt: 'select_account', unauthorized_scope: true, - errors: hash_including(:client_id), error_details: hash_including(:client_id), user_fully_authenticated: true, acr_values: 'http://idmanagement.gov/ns/assurance/ial/1', @@ -2311,7 +2307,6 @@ success: false, prompt: 'select_account', unauthorized_scope: true, - errors: hash_including(:client_id), error_details: hash_including(:client_id), user_fully_authenticated: true, acr_values: '', diff --git a/spec/controllers/openid_connect/logout_controller_spec.rb b/spec/controllers/openid_connect/logout_controller_spec.rb index 1360f3fd8ed..fca78f5b5e2 100644 --- a/spec/controllers/openid_connect/logout_controller_spec.rb +++ b/spec/controllers/openid_connect/logout_controller_spec.rb @@ -199,9 +199,6 @@ action - errors = { - redirect_uri: [t('openid_connect.authorization.errors.redirect_uri_no_match')], - } expect(@analytics).to have_logged_event( 'OIDC Logout Requested', hash_including( @@ -209,8 +206,9 @@ client_id: service_provider.issuer, client_id_parameter_present: false, id_token_hint_parameter_present: true, - errors: errors, - error_details: hash_including(*errors.keys), + error_details: { + redirect_uri: { redirect_uri_no_match: true }, + }, sp_initiated: true, oidc: true, ), @@ -243,7 +241,6 @@ success: false, client_id_parameter_present: false, id_token_hint_parameter_present: true, - errors: hash_including(*errors_keys), error_details: hash_including(*errors_keys), sp_initiated: true, oidc: true, @@ -362,9 +359,6 @@ action - errors = { - redirect_uri: [t('openid_connect.authorization.errors.redirect_uri_no_match')], - } expect(@analytics).to have_logged_event( 'OIDC Logout Requested', hash_including( @@ -372,8 +366,9 @@ client_id: service_provider.issuer, client_id_parameter_present: true, id_token_hint_parameter_present: false, - errors: errors, - error_details: hash_including(*errors.keys), + error_details: { + redirect_uri: { redirect_uri_no_match: true }, + }, sp_initiated: true, oidc: true, ), @@ -498,9 +493,6 @@ action - errors = { - id_token_hint: [t('openid_connect.logout.errors.id_token_hint_present')], - } expect(@analytics).to have_logged_event( 'OIDC Logout Requested', hash_including( @@ -508,8 +500,9 @@ client_id: service_provider.issuer, client_id_parameter_present: true, id_token_hint_parameter_present: true, - errors: errors, - error_details: hash_including(*errors.keys), + error_details: { + id_token_hint: { present: true }, + }, sp_initiated: true, oidc: true, ), @@ -549,9 +542,6 @@ action - errors = { - redirect_uri: [t('openid_connect.authorization.errors.redirect_uri_no_match')], - } expect(@analytics).to have_logged_event( 'OIDC Logout Requested', hash_including( @@ -559,8 +549,9 @@ client_id: service_provider.issuer, client_id_parameter_present: true, id_token_hint_parameter_present: false, - errors: errors, - error_details: hash_including(*errors.keys), + error_details: { + redirect_uri: { redirect_uri_no_match: true }, + }, sp_initiated: true, oidc: true, ), diff --git a/spec/controllers/openid_connect/token_controller_spec.rb b/spec/controllers/openid_connect/token_controller_spec.rb index e4212c73a53..3ee7c29ecea 100644 --- a/spec/controllers/openid_connect/token_controller_spec.rb +++ b/spec/controllers/openid_connect/token_controller_spec.rb @@ -93,7 +93,6 @@ success: false, client_id: client_id, user_id: user.uuid, - errors: hash_including(:grant_type), code_digest: kind_of(String), code_verifier_present: false, error_details: hash_including(:grant_type), diff --git a/spec/controllers/openid_connect/user_info_controller_spec.rb b/spec/controllers/openid_connect/user_info_controller_spec.rb index a1d90ad6952..3cf76a1227d 100644 --- a/spec/controllers/openid_connect/user_info_controller_spec.rb +++ b/spec/controllers/openid_connect/user_info_controller_spec.rb @@ -25,7 +25,6 @@ expect(@analytics).to have_logged_event( 'OpenID Connect: bearer token authentication', success: false, - errors: hash_including(:access_token), error_details: hash_including(:access_token), ) @@ -59,7 +58,6 @@ expect(@analytics).to have_logged_event( 'OpenID Connect: bearer token authentication', success: false, - errors: hash_including(:access_token), error_details: hash_including(:access_token), ) @@ -92,7 +90,6 @@ expect(@analytics).to have_logged_event( 'OpenID Connect: bearer token authentication', success: false, - errors: hash_including(:access_token), error_details: hash_including(:access_token), ) @@ -129,7 +126,6 @@ expect(@analytics).to have_logged_event( 'OpenID Connect: bearer token authentication', success: false, - errors: { access_token: [t('openid_connect.user_info.errors.not_found')] }, error_details: { access_token: { not_found: true } }, ) end diff --git a/spec/controllers/risc/security_events_controller_spec.rb b/spec/controllers/risc/security_events_controller_spec.rb index 2a9ed0bdb79..ebeee405ab4 100644 --- a/spec/controllers/risc/security_events_controller_spec.rb +++ b/spec/controllers/risc/security_events_controller_spec.rb @@ -85,7 +85,6 @@ client_id: service_provider.issuer, event_type: event_type, error_code: SecurityEventForm::ErrorCodes::JWT_AUD, - errors: kind_of(Hash), error_details: kind_of(Hash), jti: jti, success: false, diff --git a/spec/controllers/saml_idp_controller_spec.rb b/spec/controllers/saml_idp_controller_spec.rb index e85933a64f1..f9f1d7fabdd 100644 --- a/spec/controllers/saml_idp_controller_spec.rb +++ b/spec/controllers/saml_idp_controller_spec.rb @@ -1096,7 +1096,6 @@ def name_id_version(format_urn) 'SAML Auth', hash_including( success: false, - errors: { authn_context: [t('errors.messages.unauthorized_authn_context')] }, error_details: { authn_context: { unauthorized_authn_context: true } }, nameid_format: Saml::Idp::Constants::NAME_ID_FORMAT_PERSISTENT, authn_context: [unknown_value], @@ -1374,7 +1373,6 @@ def name_id_version(format_urn) 'SAML Auth', hash_including( success: false, - errors: { service_provider: [t('errors.messages.unauthorized_service_provider')] }, error_details: { service_provider: { unauthorized_service_provider: true } }, nameid_format: Saml::Idp::Constants::NAME_ID_FORMAT_PERSISTENT, authn_context: request_authn_contexts, @@ -1421,10 +1419,6 @@ def name_id_version(format_urn) 'SAML Auth', hash_including( success: false, - errors: { - service_provider: [t('errors.messages.unauthorized_service_provider')], - authn_context: [t('errors.messages.unauthorized_authn_context')], - }, error_details: { authn_context: { unauthorized_authn_context: true }, service_provider: { unauthorized_service_provider: true }, @@ -1486,7 +1480,6 @@ def name_id_version(format_urn) 'SAML Auth', hash_including( success: false, - errors: { service_provider: [t('errors.messages.no_cert_registered')] }, error_details: { service_provider: { no_cert_registered: true } }, ), ) @@ -1984,7 +1977,6 @@ def name_id_version(format_urn) 'SAML Auth', hash_including( success: false, - errors: { service_provider: ['We cannot detect a certificate in your request.'] }, error_details: { service_provider: { blank_cert_element_req: true } }, nameid_format: Saml::Idp::Constants::NAME_ID_FORMAT_PERSISTENT, authn_context: [Saml::Idp::Constants::DEFAULT_AAL_AUTHN_CONTEXT_CLASSREF], diff --git a/spec/controllers/sign_up/email_confirmations_controller_spec.rb b/spec/controllers/sign_up/email_confirmations_controller_spec.rb index 56ee0371e5b..2874847d7ce 100644 --- a/spec/controllers/sign_up/email_confirmations_controller_spec.rb +++ b/spec/controllers/sign_up/email_confirmations_controller_spec.rb @@ -6,7 +6,6 @@ { success: false, error_details: { confirmation_token: { not_found: true } }, - errors: { confirmation_token: ['not found'] }, } end @@ -87,7 +86,6 @@ expect(@analytics).to have_logged_event( 'User Registration: Email Confirmation', success: false, - errors: { confirmation_token: [t('errors.messages.expired')] }, error_details: { confirmation_token: { expired: true } }, user_id: email_address.user.uuid, ) @@ -110,7 +108,6 @@ expect(@analytics).to have_logged_event( 'User Registration: Email Confirmation', success: false, - errors: { confirmation_token: [t('errors.messages.expired')] }, error_details: { confirmation_token: { expired: true } }, user_id: user.uuid, ) diff --git a/spec/controllers/sign_up/passwords_controller_spec.rb b/spec/controllers/sign_up/passwords_controller_spec.rb index b90c747a195..0841c3dda46 100644 --- a/spec/controllers/sign_up/passwords_controller_spec.rb +++ b/spec/controllers/sign_up/passwords_controller_spec.rb @@ -115,14 +115,6 @@ expect(@analytics).to have_logged_event( 'Password Creation', success: false, - errors: { - password: [ - t('errors.attributes.password.too_short', count: Devise.password_length.first), - ], - password_confirmation: [ - t('errors.messages.too_short', count: Devise.password_length.first), - ], - }, error_details: { password: { too_short: true }, password_confirmation: { too_short: true }, @@ -143,9 +135,6 @@ expect(@analytics).to have_logged_event( 'Password Creation', success: false, - errors: { - password_confirmation: [t('errors.messages.password_mismatch')], - }, error_details: { password_confirmation: { mismatch: true }, }, diff --git a/spec/controllers/sign_up/registrations_controller_spec.rb b/spec/controllers/sign_up/registrations_controller_spec.rb index e6156bf038b..48886e11726 100644 --- a/spec/controllers/sign_up/registrations_controller_spec.rb +++ b/spec/controllers/sign_up/registrations_controller_spec.rb @@ -144,7 +144,6 @@ 'User Registration: Email Submitted', success: false, rate_limited: false, - errors: { email: [t('valid_email.validations.email.invalid')] }, error_details: { email: { invalid: true } }, email_already_exists: false, user_id: 'anonymous-uuid', diff --git a/spec/controllers/two_factor_authentication/personal_key_verification_controller_spec.rb b/spec/controllers/two_factor_authentication/personal_key_verification_controller_spec.rb index 34b08cf63e3..33667857dae 100644 --- a/spec/controllers/two_factor_authentication/personal_key_verification_controller_spec.rb +++ b/spec/controllers/two_factor_authentication/personal_key_verification_controller_spec.rb @@ -212,7 +212,6 @@ expect(@analytics).to have_logged_event( 'Multi-Factor Authentication', success: false, - errors: { personal_key: [t('errors.messages.personal_key_incorrect')] }, error_details: { personal_key: { personal_key_incorrect: true } }, enabled_mfa_methods_count: 1, multi_factor_auth_method: 'personal-key', diff --git a/spec/controllers/users/edit_phone_controller_spec.rb b/spec/controllers/users/edit_phone_controller_spec.rb index a1f25d7748d..fe1af0ca074 100644 --- a/spec/controllers/users/edit_phone_controller_spec.rb +++ b/spec/controllers/users/edit_phone_controller_spec.rb @@ -42,7 +42,6 @@ expect(@analytics).to have_logged_event( 'Phone Number Change: Form submitted', success: false, - errors: hash_including(:delivery_preference), error_details: { delivery_preference: { inclusion: true } }, delivery_preference: 'noise', make_default_number: true, diff --git a/spec/controllers/users/passwords_controller_spec.rb b/spec/controllers/users/passwords_controller_spec.rb index 73701202663..824c961daa7 100644 --- a/spec/controllers/users/passwords_controller_spec.rb +++ b/spec/controllers/users/passwords_controller_spec.rb @@ -216,18 +216,6 @@ expect(@analytics).to have_logged_event( 'Password Changed', success: false, - errors: { - password: [ - t( - 'errors.attributes.password.too_short.other', - count: Devise.password_length.first, - ), - ], - password_confirmation: [t( - 'errors.messages.too_short.other', - count: Devise.password_length.first, - )], - }, error_details: { password: { too_short: true }, password_confirmation: { too_short: true }, @@ -254,18 +242,6 @@ expect(@analytics).to have_logged_event( 'Password Changed', success: false, - errors: { - password: [ - t( - 'errors.attributes.password.too_short.other', - count: Devise.password_length.first, - ), - ], - password_confirmation: [t( - 'errors.messages.too_short.other', - count: Devise.password_length.first, - )], - }, error_details: { password: { too_short: true }, password_confirmation: { too_short: true }, @@ -302,9 +278,6 @@ expect(@analytics).to have_logged_event( 'Password Changed', success: false, - errors: { - password_confirmation: [t('errors.messages.password_mismatch')], - }, error_details: { password_confirmation: { mismatch: true }, }, diff --git a/spec/controllers/users/phone_setup_controller_spec.rb b/spec/controllers/users/phone_setup_controller_spec.rb index b1e1e60e18e..2d85afe5982 100644 --- a/spec/controllers/users/phone_setup_controller_spec.rb +++ b/spec/controllers/users/phone_setup_controller_spec.rb @@ -71,12 +71,6 @@ expect(@analytics).to have_logged_event( 'Multi-Factor Authentication: phone setup', success: false, - errors: { - phone: [ - t('errors.messages.improbable_phone'), - t('two_factor_authentication.otp_delivery_preference.voice_unsupported', location: ''), - ], - }, error_details: { phone: { improbable_phone: true, diff --git a/spec/controllers/users/reset_passwords_controller_spec.rb b/spec/controllers/users/reset_passwords_controller_spec.rb index 2258371d997..5bec6a79ddf 100644 --- a/spec/controllers/users/reset_passwords_controller_spec.rb +++ b/spec/controllers/users/reset_passwords_controller_spec.rb @@ -32,7 +32,6 @@ expect(@analytics).to have_logged_event( 'Password Reset: Token Submitted', success: false, - errors: { user: ['invalid_token'] }, error_details: { user: { blank: true } }, ) expect(response).to redirect_to new_user_password_path @@ -64,7 +63,6 @@ expect(@analytics).to have_logged_event( 'Password Reset: Token Submitted', success: false, - errors: { user: ['invalid_token'] }, error_details: { user: { blank: true } }, ) expect(response).to redirect_to new_user_password_path @@ -86,7 +84,6 @@ expect(@analytics).to have_logged_event( 'Password Reset: Token Submitted', success: false, - errors: { user: ['token_expired'] }, error_details: { user: { token_expired: true } }, user_id: '123', ) @@ -170,14 +167,6 @@ expect(@analytics).to have_logged_event( 'Password Reset: Password Submitted', success: false, - errors: { - password: [password_error_message], - password_confirmation: [t( - 'errors.messages.too_short.other', - count: Devise.password_length.first, - )], - reset_password_token: ['token_expired'], - }, error_details: { password: { too_short: true }, password_confirmation: { too_short: true }, @@ -219,13 +208,6 @@ expect(@analytics).to have_logged_event( 'Password Reset: Password Submitted', success: false, - errors: { - password: [password_error_message], - password_confirmation: [t( - 'errors.messages.too_short.other', - count: Devise.password_length.first, - )], - }, error_details: { password: { too_short: true }, password_confirmation: { too_short: true }, @@ -266,9 +248,6 @@ expect(@analytics).to have_logged_event( 'Password Reset: Password Submitted', success: false, - errors: { - password_confirmation: [t('errors.messages.password_mismatch')], - }, error_details: { password_confirmation: { mismatch: true }, }, @@ -557,7 +536,6 @@ expect(@analytics).to have_logged_event( 'Password Reset: Email Submitted', success: false, - errors: { email: [t('valid_email.validations.email.invalid')] }, error_details: { email: { invalid: true } }, user_id: 'nonexistent-uuid', confirmed: false, diff --git a/spec/controllers/users/totp_setup_controller_spec.rb b/spec/controllers/users/totp_setup_controller_spec.rb index 1dee71f1f2c..69e551f0855 100644 --- a/spec/controllers/users/totp_setup_controller_spec.rb +++ b/spec/controllers/users/totp_setup_controller_spec.rb @@ -218,7 +218,6 @@ 'Multi-Factor Authentication Setup', success: false, error_details: { name: { blank: true } }, - errors: { name: [t('errors.messages.blank')] }, totp_secret_present: true, multi_factor_auth_method: 'totp', enabled_mfa_methods_count: 1, diff --git a/spec/controllers/users/verify_personal_key_controller_spec.rb b/spec/controllers/users/verify_personal_key_controller_spec.rb index f54ea385343..f87f18795b1 100644 --- a/spec/controllers/users/verify_personal_key_controller_spec.rb +++ b/spec/controllers/users/verify_personal_key_controller_spec.rb @@ -133,7 +133,6 @@ expect(@analytics).to have_logged_event( 'Personal key reactivation: Personal key form submitted', - errors: { personal_key: ['Please fill in this field.', error_text] }, error_details: { personal_key: { blank: true, personal_key: true } }, success: false, ) diff --git a/spec/controllers/users/webauthn_setup_controller_spec.rb b/spec/controllers/users/webauthn_setup_controller_spec.rb index afa5fc4a37d..7ba85ab0485 100644 --- a/spec/controllers/users/webauthn_setup_controller_spec.rb +++ b/spec/controllers/users/webauthn_setup_controller_spec.rb @@ -467,9 +467,6 @@ expect(@analytics).to have_logged_event( 'Multi-Factor Authentication Setup', enabled_mfa_methods_count: 0, - errors: { - attestation_object: [I18n.t('errors.webauthn_platform_setup.general_error')], - }, error_details: { attestation_object: { invalid: true } }, in_account_creation_flow: false, mfa_method_counts: {}, diff --git a/spec/forms/openid_connect_authorize_form_spec.rb b/spec/forms/openid_connect_authorize_form_spec.rb index 75db077c746..a8d2b9faaf5 100644 --- a/spec/forms/openid_connect_authorize_form_spec.rb +++ b/spec/forms/openid_connect_authorize_form_spec.rb @@ -66,7 +66,7 @@ it 'is unsuccessful and has error messages' do expect(result.to_h).to eq( success: false, - errors: { response_type: ['is not included in the list'] }, + errors: nil, error_details: { response_type: { inclusion: true } }, client_id: client_id, prompt: 'select_account', diff --git a/spec/forms/openid_connect_token_form_spec.rb b/spec/forms/openid_connect_token_form_spec.rb index 9283dbc7218..19e26d0e068 100644 --- a/spec/forms/openid_connect_token_form_spec.rb +++ b/spec/forms/openid_connect_token_form_spec.rb @@ -395,7 +395,7 @@ expect(submission.to_h).to include( success: false, - errors: form.errors.messages, + errors: nil, error_details: hash_including(*form.errors.attribute_names), client_id: nil, user_id: nil, @@ -412,7 +412,7 @@ expect(submission.to_h).to include( success: false, - errors: form.errors.messages, + errors: nil, error_details: hash_including(:grant_type), client_id: client_id, user_id: user.uuid, diff --git a/spec/forms/otp_delivery_selection_form_spec.rb b/spec/forms/otp_delivery_selection_form_spec.rb index c589d34ce5e..532b9bdbcc3 100644 --- a/spec/forms/otp_delivery_selection_form_spec.rb +++ b/spec/forms/otp_delivery_selection_form_spec.rb @@ -41,11 +41,6 @@ context 'when the form is invalid' do it 'returns false for success? and includes errors' do - errors = { - otp_delivery_preference: ['is not included in the list'], - phone: ['Please fill in this field.'], - } - extra = { otp_delivery_preference: 'foo', resend: false, @@ -62,8 +57,11 @@ expect(subject.submit(otp_delivery_preference: 'foo').to_h).to include( success: false, - errors: errors, - error_details: hash_including(*errors.keys), + errors: nil, + error_details: { + otp_delivery_preference: { inclusion: true }, + phone: { blank: true }, + }, **extra, ) end diff --git a/spec/forms/password_reset_email_form_spec.rb b/spec/forms/password_reset_email_form_spec.rb index 6b1f24e89aa..2e9e4a3e88e 100644 --- a/spec/forms/password_reset_email_form_spec.rb +++ b/spec/forms/password_reset_email_form_spec.rb @@ -39,12 +39,10 @@ it 'returns hash with properties about the event and the nonexistent user' do subject = PasswordResetEmailForm.new('invalid') - errors = { email: [t('valid_email.validations.email.invalid')] } - expect(subject.submit.to_h).to include( success: false, - errors: errors, - error_details: hash_including(*errors.keys), + errors: nil, + error_details: { email: { invalid: true } }, user_id: 'nonexistent-uuid', confirmed: false, active_profile: false, @@ -53,12 +51,11 @@ it 'returns false and adds errors to the form object when domain is invalid' do subject = PasswordResetEmailForm.new('test@çà.com') - errors = { email: [t('valid_email.validations.email.invalid')] } expect(subject.submit.to_h).to include( success: false, - errors: errors, - error_details: hash_including(*errors.keys), + errors: nil, + error_details: { email: { domain: true } }, user_id: 'nonexistent-uuid', confirmed: false, active_profile: false, diff --git a/spec/forms/personal_key_form_spec.rb b/spec/forms/personal_key_form_spec.rb index 5a49b7dbc07..0128b60dc02 100644 --- a/spec/forms/personal_key_form_spec.rb +++ b/spec/forms/personal_key_form_spec.rb @@ -21,14 +21,13 @@ context 'when the form is invalid' do it 'returns FormResponse with success: false' do user = create(:user, :fully_registered, personal_key: 'code') - errors = { personal_key: ['Incorrect personal key'] } form = PersonalKeyForm.new(user, 'foo') expect(form.submit.to_h).to include( success: false, - errors: errors, - error_details: hash_including(*errors.keys), + errors: nil, + error_details: { personal_key: { personal_key_incorrect: true } }, ) expect(user.encrypted_recovery_code_digest).to_not be_nil expect(form.personal_key).to be_nil diff --git a/spec/forms/register_user_email_form_spec.rb b/spec/forms/register_user_email_form_spec.rb index 5d8ec17bac6..8f99a8da5d5 100644 --- a/spec/forms/register_user_email_form_spec.rb +++ b/spec/forms/register_user_email_form_spec.rb @@ -280,7 +280,6 @@ context 'when email is invalid' do it 'returns false and adds errors to the form object' do invalid_email = 'invalid_email' - errors = { email: [t('valid_email.validations.email.invalid')] } extra = { email_already_exists: false, @@ -291,16 +290,14 @@ expect(subject.submit(email: invalid_email, terms_accepted: '1').to_h).to include( success: false, - errors: errors, - error_details: hash_including(*errors.keys), + errors: nil, + error_details: { email: { invalid: true } }, **extra, ) expect_delivered_email_count(0) end it 'returns false and adds errors to the form object when domain is invalid' do - errors = { email: [t('valid_email.validations.email.invalid')] } - extra = { email_already_exists: false, rate_limited: false, @@ -310,8 +307,8 @@ expect(subject.submit(email: 'test@çà.com', terms_accepted: '1').to_h).to include( success: false, - errors: errors, - error_details: hash_including(*errors.keys), + errors: nil, + error_details: { email: { domain: true } }, **extra, ) expect_delivered_email_count(0) @@ -321,7 +318,6 @@ blocked_domain = 'blocked.com' blocked_email = 'test@' + blocked_domain email_address = create(:email_address, email: blocked_email) - errors = { email: [t('valid_email.validations.email.invalid')] } allow(BanDisposableEmailValidator).to receive(:config).and_return([blocked_domain]) extra = { @@ -333,8 +329,8 @@ expect(subject.submit(email: blocked_email, terms_accepted: '1').to_h).to include( success: false, - errors: errors, - error_details: hash_including(*errors.keys), + errors: nil, + error_details: { email: { t('valid_email.validations.email.invalid') => true } }, **extra, ) expect_delivered_email_count(0) @@ -344,13 +340,12 @@ blocked_domain = 'blocked.com' blocked_email = 'test@sub.' + blocked_domain - errors = { email: [t('valid_email.validations.email.invalid')] } expect(BanDisposableEmailValidator).to receive(:config).and_return([blocked_domain]) expect(subject.submit(email: blocked_email, terms_accepted: '1').to_h).to include( success: false, - errors: errors, - error_details: hash_including(*errors.keys), + errors: nil, + error_details: { email: { t('valid_email.validations.email.invalid') => true } }, email_already_exists: false, rate_limited: false, user_id: 'anonymous-uuid', @@ -389,7 +384,7 @@ expect(result.to_h).to eq( success: false, - errors: { terms_accepted: [t('errors.registration.terms')] }, + errors: nil, error_details: { terms_accepted: { terms: true } }, email_already_exists: false, rate_limited: false, diff --git a/spec/forms/reset_password_form_spec.rb b/spec/forms/reset_password_form_spec.rb index 74b7c087ccf..ecf02aee0fb 100644 --- a/spec/forms/reset_password_form_spec.rb +++ b/spec/forms/reset_password_form_spec.rb @@ -33,7 +33,7 @@ it 'returns a hash with errors' do expect(result.to_h).to eq( success: false, - errors: { reset_password_token: ['token_expired'] }, + errors: nil, error_details: { reset_password_token: { token_expired: true } }, user_id: '123', profile_deactivated: false, @@ -53,14 +53,7 @@ it 'returns a hash with errors' do expect(result.to_h).to eq( success: false, - errors: { - password: - ["Password must be at least #{Devise.password_length.first} characters long"], - password_confirmation: [I18n.t( - 'errors.messages.too_short', - count: Devise.password_length.first, - )], - }, + errors: nil, error_details: { password: { too_short: true }, password_confirmation: { too_short: true }, @@ -102,18 +95,7 @@ it 'returns a hash with errors' do expect(result.to_h).to eq( success: false, - errors: { - password: [ - t( - 'errors.attributes.password.too_short.other', - count: Devise.password_length.first, - ), - ], - password_confirmation: [ - t('errors.messages.too_short', count: Devise.password_length.first), - ], - reset_password_token: ['token_expired'], - }, + errors: nil, error_details: { password: { too_short: true }, password_confirmation: { too_short: true }, @@ -133,7 +115,7 @@ it 'returns a hash with errors' do expect(result.to_h).to eq( success: false, - errors: { reset_password_token: ['invalid_token'] }, + errors: nil, error_details: { reset_password_token: { invalid_token: true } }, user_id: nil, profile_deactivated: false, @@ -288,7 +270,7 @@ it 'returns a hash with errors' do expect(result.to_h).to eq( success: false, - errors: { reset_password_token: ['token_expired'] }, + errors: nil, error_details: { reset_password_token: { token_expired: true } }, user_id: '123', profile_deactivated: false, @@ -308,14 +290,7 @@ it 'returns a hash with errors' do expect(result.to_h).to eq( success: false, - errors: { - password: - ["Password must be at least #{Devise.password_length.first} characters long"], - password_confirmation: [I18n.t( - 'errors.messages.too_short', - count: Devise.password_length.first, - )], - }, + errors: nil, error_details: { password: { too_short: true }, password_confirmation: { too_short: true }, @@ -357,18 +332,7 @@ it 'returns a hash with errors' do expect(result.to_h).to eq( success: false, - errors: { - password: [ - t( - 'errors.attributes.password.too_short.other', - count: Devise.password_length.first, - ), - ], - password_confirmation: [ - t('errors.messages.too_short', count: Devise.password_length.first), - ], - reset_password_token: ['token_expired'], - }, + errors: nil, error_details: { password: { too_short: true }, password_confirmation: { too_short: true }, @@ -388,7 +352,7 @@ it 'returns a hash with errors' do expect(result.to_h).to eq( success: false, - errors: { reset_password_token: ['invalid_token'] }, + errors: nil, error_details: { reset_password_token: { invalid_token: true } }, user_id: nil, profile_deactivated: false, diff --git a/spec/forms/totp_setup_form_spec.rb b/spec/forms/totp_setup_form_spec.rb index aae42abd1f1..cdd0ebce540 100644 --- a/spec/forms/totp_setup_form_spec.rb +++ b/spec/forms/totp_setup_form_spec.rb @@ -80,8 +80,8 @@ expect(form.submit.to_h).to include( success: false, + errors: nil, error_details: { name: { blank: true } }, - errors: { name: [t('errors.messages.blank')] }, ) expect(user.auth_app_configurations.any?).to eq false end @@ -95,8 +95,8 @@ expect(form2.submit.to_h).to include( success: false, + errors: nil, error_details: { name: { unique_name: true } }, - errors: { name: [t('errors.piv_cac_setup.unique_name')] }, ) end end diff --git a/spec/forms/two_factor_login_options_form_spec.rb b/spec/forms/two_factor_login_options_form_spec.rb index 6c2edbfae1e..fbfab8b0b2b 100644 --- a/spec/forms/two_factor_login_options_form_spec.rb +++ b/spec/forms/two_factor_login_options_form_spec.rb @@ -27,10 +27,6 @@ context 'when the form is invalid' do it 'returns false for success? and includes errors' do - errors = { - selection: ['is not included in the list'], - } - extra = { selection: 'foo', enabled_mfa_methods_count: 1, @@ -40,8 +36,8 @@ expect(subject.submit(selection: 'foo').to_h).to include( success: false, - errors: errors, - error_details: hash_including(*errors.keys), + errors: nil, + error_details: { selection: { inclusion: true } }, **extra, ) end diff --git a/spec/forms/update_user_password_form_spec.rb b/spec/forms/update_user_password_form_spec.rb index 1955390f085..bdd4fd7705a 100644 --- a/spec/forms/update_user_password_form_spec.rb +++ b/spec/forms/update_user_password_form_spec.rb @@ -22,17 +22,6 @@ let(:password) { 'invalid' } it 'returns FormResponse with success: false and does not do anything else' do - errors = { - password: [t( - 'errors.attributes.password.too_short.other', - count: Devise.password_length.first, - )], - password_confirmation: [I18n.t( - 'errors.messages.too_short', - count: Devise.password_length.first, - )], - } - expect(UserProfilesEncryptor).not_to receive(:new) user.save! @@ -43,7 +32,7 @@ expect(result).to include( success: false, - errors: errors, + errors: nil, error_details: hash_including(:password, :password_confirmation), ) end diff --git a/spec/forms/webauthn_setup_form_spec.rb b/spec/forms/webauthn_setup_form_spec.rb index 1e78a2a96bd..7a3e4940938 100644 --- a/spec/forms/webauthn_setup_form_spec.rb +++ b/spec/forms/webauthn_setup_form_spec.rb @@ -203,14 +203,7 @@ expect(result.to_h).to eq( success: false, - errors: { - attestation_object: [ - I18n.t( - 'errors.webauthn_setup.general_error_html', - link_html: I18n.t('errors.webauthn_setup.additional_methods_link'), - ), - ], - }, + errors: nil, error_details: { attestation_object: { invalid: true } }, transports: ['usb'], transports_mismatch: false, @@ -257,14 +250,7 @@ expect(result.to_h).to eq( success: false, - errors: { - attestation_object: [ - I18n.t( - 'errors.webauthn_setup.general_error_html', - link_html: I18n.t('errors.webauthn_setup.additional_methods_link'), - ), - ], - }, + errors: nil, error_details: { attestation_object: { invalid: true } }, transports: ['usb'], transports_mismatch: false, diff --git a/spec/forms/webauthn_visit_form_spec.rb b/spec/forms/webauthn_visit_form_spec.rb index c1e1d9c11f7..7efed98e9db 100644 --- a/spec/forms/webauthn_visit_form_spec.rb +++ b/spec/forms/webauthn_visit_form_spec.rb @@ -44,85 +44,61 @@ context 'when there are errors' do it 'returns FormResponse with success: false with InvalidStateError' do params = { error: 'InvalidStateError' } - errors = { InvalidStateError: [I18n.t('errors.webauthn_setup.already_registered')] } expect(subject.submit(params).to_h).to include( success: false, - errors: errors, - error_details: hash_including(*errors.keys), + errors: nil, + error_details: { InvalidStateError: { invalid: true } }, ) end it 'returns FormResponse with success: false with NotSupportedError' do params = { error: 'NotSupportedError' } - errors = { NotSupportedError: [I18n.t('errors.webauthn_setup.not_supported')] } expect(subject.submit(params).to_h).to include( success: false, - errors: errors, - error_details: hash_including(*errors.keys), + errors: nil, + error_details: { NotSupportedError: { invalid: true } }, ) end it 'returns FormResponse with success: false with an unrecognized error' do params = { error: 'foo' } - general_error = t( - 'errors.webauthn_setup.general_error_html', - link_html: link_to( - t('errors.webauthn_setup.additional_methods_link'), - authentication_methods_setup_path, - ), - ) - errors = { - foo: [general_error], - } expect(subject.submit(params).to_h).to include( success: false, - errors: errors, - error_details: hash_including(*errors.keys), + error_details: { foo: { invalid: true } }, ) end context 'with platform authenticator' do it 'returns FormResponse with success: false with InvalidStateError' do params = { error: 'InvalidStateError', platform: 'true' } - errors = { - InvalidStateError: [I18n.t('errors.webauthn_platform_setup.already_registered')], - } expect(subject.submit(params).to_h).to include( success: false, - errors: errors, - error_details: hash_including(*errors.keys), + errors: nil, + error_details: { InvalidStateError: { invalid: true } }, ) end it 'returns FormResponse with success: false with NotSupportedError' do params = { error: 'NotSupportedError', platform: 'true' } - errors = { NotSupportedError: [I18n.t('errors.webauthn_platform_setup.not_supported')] } expect(subject.submit(params).to_h).to include( success: false, - errors: errors, - error_details: hash_including(*errors.keys), + errors: nil, + error_details: { NotSupportedError: { invalid: true } }, ) end it 'returns FormResponse with success: false with an unrecognized error' do params = { error: 'foo', platform: 'true' } - errors = { foo: [I18n.t( - 'errors.webauthn_platform_setup.account_setup_error', - link: link_to( - I18n.t('errors.webauthn_platform_setup.choose_another_method'), - authentication_methods_setup_path, - ), - )] } expect(subject.submit(params).to_h).to include( success: false, - errors: errors, - error_details: hash_including(*errors.keys), + errors: nil, + error_details: { foo: { invalid: true } }, ) end @@ -132,15 +108,11 @@ it 'returns FormResponse with success: false with an unrecognized error' do params = { error: 'foo', platform: 'true' } - errors = { foo: [I18n.t( - 'errors.webauthn_platform_setup.account_setup_error', - link: I18n.t('errors.webauthn_platform_setup.choose_another_method'), - )] } expect(subject.submit(params).to_h).to include( success: false, - errors: errors, - error_details: hash_including(*errors.keys), + errors: nil, + error_details: { foo: { invalid: true } }, ) end end diff --git a/spec/services/form_response_spec.rb b/spec/services/form_response_spec.rb index c18654a5da4..25ddab00b9c 100644 --- a/spec/services/form_response_spec.rb +++ b/spec/services/form_response_spec.rb @@ -179,9 +179,7 @@ response = FormResponse.new(success: false, errors: errors) response_hash = { success: false, - errors: { - email_language: ['Language cannot be blank'], - }, + errors: nil, error_details: { email_language: { blank: true }, }, @@ -197,9 +195,7 @@ response = FormResponse.new(success: false, errors: errors) response_hash = { success: false, - errors: { - email_language: [t('errors.messages.blank')], - }, + errors: nil, error_details: { email_language: { blank: true }, }, @@ -240,9 +236,7 @@ response = FormResponse.new(success: false, errors: errors) response_hash = { success: false, - errors: { - email_language: ['Language cannot be blank'], - }, + errors: nil, error_details: { email_language: { blank: true }, }, 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