Skip to content
Merged
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
28 changes: 11 additions & 17 deletions spec/controllers/saml_idp_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -541,12 +541,12 @@ def name_id_version(format_urn)
)
end

shared_examples 'a verified identity' do |authn_context, ial|
context 'with IAL2 and the identity is already verified' do
let(:ial2_settings) do
saml_settings(
overrides: {
issuer: sp1_issuer,
authn_context: authn_context,
authn_context: Saml::Idp::Constants::IAL2_AUTHN_CONTEXT_CLASSREF,
},
)
end
Expand All @@ -563,7 +563,7 @@ def name_id_version(format_urn)
ial2_authnrequest = saml_authn_request_url(
overrides: {
issuer: sp1_issuer,
authn_context: authn_context,
authn_context: Saml::Idp::Constants::IAL2_AUTHN_CONTEXT_CLASSREF,
},
)
raw_req = CGI.unescape ial2_authnrequest.split('SAMLRequest').last
Expand All @@ -584,7 +584,7 @@ def name_id_version(format_urn)
before do
stub_sign_in(user)
session[:sign_in_flow] = sign_in_flow
IdentityLinker.new(user, sp1).link_identity(ial: ial)
IdentityLinker.new(user, sp1).link_identity(ial: Idp::Constants::IAL2)
user.identities.last.update!(
verified_attributes: %w[given_name family_name social_security_number address],
)
Expand All @@ -606,7 +606,7 @@ def name_id_version(format_urn)

it 'sets identity ial' do
saml_get_auth(ial2_settings)
expect(user.identities.last.ial).to eq(ial)
expect(user.identities.last.ial).to eq(Idp::Constants::IAL2)
end

it 'does not redirect the user to the IdV URL' do
Expand Down Expand Up @@ -634,7 +634,7 @@ def name_id_version(format_urn)
stub_analytics
expect(@analytics).to receive(:track_event).
with('SAML Auth Request', {
requested_ial: authn_context,
requested_ial: Saml::Idp::Constants::IAL2_AUTHN_CONTEXT_CLASSREF,
service_provider: sp1_issuer,
force_authn: false,
user_fully_authenticated: true,
Expand All @@ -644,9 +644,9 @@ def name_id_version(format_urn)
success: true,
errors: {},
nameid_format: Saml::Idp::Constants::NAME_ID_FORMAT_PERSISTENT,
authn_context: [authn_context],
authn_context: [Saml::Idp::Constants::IAL2_AUTHN_CONTEXT_CLASSREF],
authn_context_comparison: 'exact',
requested_ial: authn_context,
requested_ial: Saml::Idp::Constants::IAL2_AUTHN_CONTEXT_CLASSREF,
service_provider: sp1_issuer,
endpoint: "/api/saml/auth#{path_year}",
idv: false,
Expand All @@ -656,8 +656,8 @@ def name_id_version(format_urn)
})
expect(@analytics).to receive(:track_event).with(
'SP redirect initiated',
ial: ial,
billed_ial: [ial, 2].min,
ial: Idp::Constants::IAL2,
billed_ial: Idp::Constants::IAL2,
sign_in_flow:,
)

Expand All @@ -675,14 +675,8 @@ def name_id_version(format_urn)
end
end

context 'with IAL2 and the identity is already verified' do
it_behaves_like 'a verified identity',
Saml::Idp::Constants::IAL2_AUTHN_CONTEXT_CLASSREF,
Idp::Constants::IAL2
end

context 'with IAL2 and the profile is reset' do
it 'redirects to IdV URL for IAL2 proofer' do
it 'redirects to reactivate account path' do
user = create(:profile, :verified, :password_reset).user
generate_saml_response(user, ial2_settings)

Expand Down