-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2157 from 18F/jgs-lg-241-feature-tests-for-piv-cac
[LG-241] Add feature specs for piv/cac
- Loading branch information
Showing
16 changed files
with
387 additions
and
71 deletions.
There are no files selected for viewing
This file contains 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,15 @@ | ||
module PivCacConcern | ||
extend ActiveSupport::Concern | ||
|
||
def create_piv_cac_nonce | ||
user_session[:piv_cac_nonce] = SecureRandom.base64(20) | ||
end | ||
|
||
def piv_cac_nonce | ||
user_session[:piv_cac_nonce] | ||
end | ||
|
||
def clear_piv_cac_nonce | ||
user_session[:piv_cac_nonce] = nil | ||
end | ||
end |
This file contains 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 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
22 changes: 22 additions & 0 deletions
22
app/presenters/piv_cac_authentication_setup_base_presenter.rb
This file contains 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,22 @@ | ||
class PivCacAuthenticationSetupBasePresenter | ||
include Rails.application.routes.url_helpers | ||
include ActionView::Helpers::TranslationHelper | ||
|
||
attr_reader :form | ||
|
||
def initialize(form) | ||
@form = form | ||
end | ||
|
||
def piv_cac_nonce | ||
@form.nonce | ||
end | ||
|
||
def piv_cac_capture_text | ||
t('forms.piv_cac_setup.submit') | ||
end | ||
|
||
def piv_cac_service_link | ||
PivCacService.piv_cac_service_link(piv_cac_nonce) | ||
end | ||
end |
22 changes: 22 additions & 0 deletions
22
app/presenters/piv_cac_authentication_setup_error_presenter.rb
This file contains 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,22 @@ | ||
class PivCacAuthenticationSetupErrorPresenter < PivCacAuthenticationSetupBasePresenter | ||
def error | ||
form.error_type | ||
end | ||
|
||
def may_select_another_certificate? | ||
error.start_with?('certificate.') && error != 'certificate.none' || | ||
error == 'token.invalid' || error == 'piv_cac.already_associated' | ||
end | ||
|
||
def title | ||
t("titles.piv_cac_setup.#{error}") | ||
end | ||
|
||
def heading | ||
t("headings.piv_cac_setup.#{error}") | ||
end | ||
|
||
def description | ||
t("forms.piv_cac_setup.#{error}_html") | ||
end | ||
end |
This file contains 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 |
---|---|---|
@@ -1,29 +1,13 @@ | ||
class PivCacAuthenticationSetupPresenter | ||
include Rails.application.routes.url_helpers | ||
include ActionView::Helpers::TranslationHelper | ||
|
||
def initialize(form) | ||
@form = form | ||
end | ||
|
||
def error | ||
@form.error_type | ||
end | ||
|
||
def may_select_another_certificate? | ||
error.start_with?('certificate.') && error != 'certificate.none' || | ||
error == 'token.invalid' || error == 'piv_cac.already_associated' | ||
end | ||
|
||
class PivCacAuthenticationSetupPresenter < PivCacAuthenticationSetupBasePresenter | ||
def title | ||
t("titles.piv_cac_setup.#{error}") | ||
t('titles.piv_cac_setup.new') | ||
end | ||
|
||
def heading | ||
t("headings.piv_cac_setup.#{error}") | ||
t('headings.piv_cac_setup.new') | ||
end | ||
|
||
def description | ||
t("forms.piv_cac_setup.#{error}_html") | ||
t('forms.piv_cac_setup.piv_cac_intro_html') | ||
end | ||
end |
This file contains 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 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 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 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 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
Oops, something went wrong.