Skip to content

LG-8697 Use StringRedacter instead of copied redact method#7683

Closed
soniaconnolly wants to merge 37 commits intomainfrom
sonia-lg-8697
Closed

LG-8697 Use StringRedacter instead of copied redact method#7683
soniaconnolly wants to merge 37 commits intomainfrom
sonia-lg-8697

Conversation

@soniaconnolly
Copy link
Contributor

@soniaconnolly soniaconnolly commented Jan 23, 2023

NOTE: @zachmargolis worked on this together and finalized the code changes. I'll be closing this branch and making a new one off main with the same commits as soon as #7686 is merged.

Change VerifyBaseStep and NewPhoneForm to use the StringRedacterConcern introduced while refactoring the Flow State Machine. Reduces repetition in code and creates a place to add more redaction methods as needed.

This PR depends on the PR for LG-7400, merge that one first!

🎫 Ticket

LG-8697, subtask of LG-7401

🛠 Summary of changes

Updated VerifyBaseStep and NewPhoneForm and tests. Add new string_redacter_spec.rb with a test formerly in new_phone_form_spec.rb

soniaconnolly and others added 30 commits January 11, 2023 13:00
Co-authored-by: Jonathan Hooper <jonathan.hooper@gsa.gov>
Co-authored-by: Jonathan Hooper <jonathan.hooper@gsa.gov>
Co-authored-by: Eric Gade <eric.gade@gsa.gov>
Co-authored-by: Jonathan Hooper <jonathan.hooper@gsa.gov>
Replace resolution_info_verified with already existing resolution_info_verified

Co-authored-by: Eric Gade <eric.gade@gsa.gov>
Look for proofing results in :stages, :resolution rather than :extra

Co-authored-by: Eric Gade <eric.gade@gsa.gov>
Redirect back to verify_info if needed from review controller before action
Proofing results exception found deeper in data structure on failure

Co-authored-by: Eric Gade <eric.gade@gsa.gov>
Co-authored-by: Alex Bradley <alexander.bradley@gsa.gov>
per PR feedback. This is now available for a future PR to use in PhoneController and VerifyBaseStep.

Co-authored-by: Alex Bradley <alexander.bradley@gsa.gov>
Co-authored-by: Eric Gade <eric.gade@gsa.gov>
changelog: Internal improvements, Flow State Machine, Add update method to new VerifyInfoController
Co-authored-by: Jonathan Hooper <jonathan.hooper@gsa.gov>
Co-authored-by: Jonathan Hooper <jonathan.hooper@gsa.gov>
Co-authored-by: Eric Gade <eric.gade@gsa.gov>
Co-authored-by: Jonathan Hooper <jonathan.hooper@gsa.gov>
Replace resolution_info_verified with already existing resolution_info_verified

Co-authored-by: Eric Gade <eric.gade@gsa.gov>
Look for proofing results in :stages, :resolution rather than :extra

Co-authored-by: Eric Gade <eric.gade@gsa.gov>
Redirect back to verify_info if needed from review controller before action
Proofing results exception found deeper in data structure on failure

Co-authored-by: Eric Gade <eric.gade@gsa.gov>
Co-authored-by: Alex Bradley <alexander.bradley@gsa.gov>
per PR feedback. This is now available for a future PR to use in PhoneController and VerifyBaseStep.

Co-authored-by: Alex Bradley <alexander.bradley@gsa.gov>
Co-authored-by: Eric Gade <eric.gade@gsa.gov>
changelog: Internal, Flow State Machine, Add update action for new VerifyInfoController
Also adding the wait template

Co-authored-by: Sonia Connolly <sonia.connolly@gsa.gov>
Co-authored-by: Alex Bradley <alexander.bradley@gsa.gov>

[skip changelog]
Move test from NewPhoneForm to new StringRedacter spec
params.fetch(:user, {})[:password].presence
end

def confirm_verify_info_complete
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this related to the changes for string redaction?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, base branch issues like @zachmargolis pointed out below.

@zachmargolis
Copy link
Contributor

I'd recommend changing the base on this Pull Request (to sonia-lg-7400) so it's easier to view the changes (how to link just in case)

@@ -0,0 +1,7 @@
module StringRedacter
extend ActiveSupport::Concern
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
extend ActiveSupport::Concern
module_function

Personally I'd go with a static method so we'd reference this directly like StringRedacter.redact_alphanumeric('abcdef') instead of just redact_alphanumeric, one of the advantages is that it's easier to see where this comes from at call sites.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 70c79e6 and moved to services 7f3a351

@soniaconnolly soniaconnolly changed the base branch from main to sonia-lg-7400 January 23, 2023 21:32
@soniaconnolly soniaconnolly changed the base branch from sonia-lg-7400 to sonia-lg-7401 January 23, 2023 21:32
@@ -0,0 +1,15 @@
require 'rails_helper'

describe 'StringRedacter' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like in the branch base switch, the StrictRedacter definition itself seems to have disappeared?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for keeping an eye on this! I think this is going to have to wait until PR #7672 gets merged and I can branch directly from main.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also realized now, StringRedacter is added on that PR, but the specs, refactoring etc are all here

Comment on lines +4 to +8
module Idv
class RedactTestController < ApplicationController
include StringRedacter
end
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so ruby blocks are weird, this is going to define Idv::RedactRestController in the global namespace.

When making classes in specs, I'd consider using the Class.new syntax so that the classes are anonymous and don't stay around:

let(:controller) do
  Class.new(ApplicationController.new) do
    include StringRedacter
  end.new
end

# ...

expect(controller.redact_alphanumeric)...

(also this mixin/concern business... another reason I'd consider just a static method StringRedacter.redact_alphanumeric)

soniaconnolly and others added 2 commits January 24, 2023 13:19
Co-authored-by: Zach Margolis <zachmargolis@users.noreply.github.com>
@soniaconnolly soniaconnolly changed the base branch from sonia-lg-7401 to main January 24, 2023 21:34
@soniaconnolly
Copy link
Contributor Author

Replaced with cleaned-up version #7699

@soniaconnolly soniaconnolly deleted the sonia-lg-8697 branch February 14, 2023 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants