-
Notifications
You must be signed in to change notification settings - Fork 166
Align PIV/CAC setup-after-sign-in specs to user behavior #10939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| require 'rails_helper' | ||
|
|
||
| RSpec.describe 'Setup PIV/CAC after sign-in' do | ||
| include SamlAuthHelper | ||
|
|
||
| scenario 'user opts to not add piv/cac card' do | ||
| perform_steps_to_get_to_add_piv_cac_during_sign_up | ||
|
|
||
| click_on t('forms.piv_cac_setup.no_thanks') | ||
|
|
||
| expect(page).to have_current_path(sign_up_completed_path) | ||
| end | ||
|
|
||
| context 'without an associated service provider' do | ||
| scenario 'user opts to not add piv/cac card' do | ||
| perform_steps_to_get_to_add_piv_cac_during_sign_up(sp: nil) | ||
|
|
||
| click_on t('forms.piv_cac_setup.no_thanks') | ||
|
|
||
| expect(page).to have_current_path(account_path) | ||
| end | ||
| end | ||
|
|
||
| scenario 'user opts to add piv/cac card' do | ||
| perform_steps_to_get_to_add_piv_cac_during_sign_up | ||
|
|
||
| fill_in t('forms.piv_cac_setup.nickname'), with: 'Card 1' | ||
| click_on t('forms.piv_cac_setup.submit') | ||
| follow_piv_cac_redirect | ||
|
|
||
| expect(page).to have_current_path(sign_up_completed_path) | ||
| end | ||
|
|
||
| scenario 'user opts to add piv/cac card but gets an error' do | ||
| perform_steps_to_get_to_add_piv_cac_during_sign_up | ||
|
|
||
| fill_in t('forms.piv_cac_setup.nickname'), with: 'Card 1' | ||
| stub_piv_cac_service(error: 'certificate.bad') | ||
| click_on t('forms.piv_cac_setup.submit') | ||
| follow_piv_cac_redirect | ||
|
|
||
| expect(page).to have_current_path(setup_piv_cac_error_path(error: 'certificate.bad')) | ||
| end | ||
|
|
||
| scenario 'user opts to add piv/cac card and has piv cac redirect in CSP' do | ||
| allow(Identity::Hostdata).to receive(:env).and_return('test') | ||
| allow(Identity::Hostdata).to receive(:domain).and_return('example.com') | ||
|
|
||
| perform_steps_to_get_to_add_piv_cac_during_sign_up | ||
|
|
||
| expected_form_action = <<-STR.squish | ||
| form-action https://*.pivcac.test.example.com 'self' | ||
| http://localhost:7654 https://example.com | ||
| STR | ||
|
|
||
| expect(page.response_headers['Content-Security-Policy']). | ||
| to(include(expected_form_action)) | ||
| end | ||
|
|
||
| def perform_steps_to_get_to_add_piv_cac_during_sign_up(sp: :oidc) | ||
| user = create(:user, :fully_registered, :with_phone) | ||
| if sp | ||
| visit_idp_from_sp_with_ial1(sp) | ||
| else | ||
| visit new_user_session_path | ||
| end | ||
|
|
||
| click_on t('account.login.piv_cac') | ||
| stub_piv_cac_service | ||
| click_on t('forms.piv_cac_login.submit') | ||
|
|
||
| follow_piv_cac_redirect | ||
| expect(page).to have_current_path(login_piv_cac_error_path(error: 'user.not_found')) | ||
| click_on t('instructions.mfa.piv_cac.back_to_sign_in') | ||
|
|
||
| fill_in_credentials_and_submit(user.email, user.password) | ||
| fill_in_code_with_last_phone_otp | ||
| click_submit_default | ||
| expect(current_path).to eq login_add_piv_cac_prompt_path | ||
| fill_in t('forms.piv_cac_setup.nickname'), with: 'Card 1' | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the event being
mult_factor_auth_added_piv_cac, what information would be captured inmethod_name?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm honestly not really sure I see the value in logging
method_name. I kept it here just for parity with how it worked previously. I could imagine a potential query where someone filters likefilter properties.event_properties.method_name = 'piv_cac'without an event name, since some other events follow this pattern as well (e.g.'Multi-Factor Authentication: Added phone'). But I kinda doubt that's common? We could create a follow-up ticket to investigate if we're querying that way and remove the redundant event property if unused.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And to clarify, this change was necessary because it was flagged by our undocumented analytics parameters checker. It wasn't flagged previously because
sign_in_spec.rbstill exempts itself from these checks, but creating a new feature test file without the exemptions caused it to be caught.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just the default, was added a long time ago but I do wonder if we still need it.