Skip to content
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

55597 mocked auth data profiles #12232

Merged
merged 0 commits into from
Mar 31, 2023
Merged

Conversation

bramleyjl
Copy link
Contributor

@bramleyjl bramleyjl commented Mar 23, 2023

Summary

  • This PR adds the credential_list route to the Mocked Authentication module. This route takes a CSP type parameter and searches for all CSP user attribute profiles of that type currently in the vets-api-mockdata directory, controlled by Settings.sign_in.mock_credential_dir. The mock profile filenames should be the user_identifier, which is the user's email stripped of any non-word characters. This filenaming is used by the Mocked Authentication mock profile creator, and any files with non-word characters such as . will not be read by the reader. The mock data reader then creates and returns a mock_profiles hash that looks like:
mock_profiles: {
  bobloblaw: { 'credential_payload': { given_name: 'Bob', family_name: 'Loblaw', email: 'bobloblaw@gmail.com', ... },
               'encoded_credential': 'eyJjcmVkZW50aWFsX3V1aWQiOiIzY2I3OTJiZ...yLTc4NDgifQ==' },
  geneparmesan: { 'credential_payload': { given_name: 'Gene', family_name: 'Parmesan', email: 'geneparmesan@gmail.com', ... },
                  'encoded_credential': '1jZjBlMzM4N2IzYWIiLCJlbWFpbCI6Im1vY2...iZm9ybWF0dGVk==' }
}

Each entry is keyed to its user_identifier and possesses a credential_payload of attributes that differs depending on the CSP, as well as that payload cast to JSON and encoded as the encoded_credential field that can be passed back to the Mocked Authentication /authorize endpoint.

Related issue(s)

Testing done

  • Unit tests added to cover the controller
  • To test, first ensure that you have credential data in your vets-api-mockdata/credentials/ directory for the CSP type you wish to test. You can create new mock credential data for ID.me, DSLogon, and Login.gov by performing an actual CSP authentication in localhost & enabling response logging.
  • Navigate to the mocked_authentication/credential_list endpoint with your selected CSP type:
    curl http://localhost:3000/mocked_authentication/credential_list?type=logingov
    

Screenshots

Screenshot from 2023-03-24 13-54-50

What areas of the site does it impact?

(Describe what parts of the site are impacted andifcode touched other areas)

Acceptance criteria

  • I fixed|updated|added unit tests and integration tests for each feature (if applicable).
  • Documentation has been updated (link to documentation)
  • I added a screenshot of the developed feature

@bramleyjl bramleyjl self-assigned this Mar 23, 2023
@va-vfs-bot va-vfs-bot temporarily deployed to 55597_mocked_auth_data_profiles/main/main March 23, 2023 22:34 Inactive
@github-actions
Copy link

github-actions bot commented Mar 23, 2023

1 Warning
⚠️ This PR changes 209 LoC (not counting whitespace/newlines).

In order to ensure each PR receives the proper attention it deserves, we recommend not exceeding
200. Expect some delays getting reviews.

File Summary

Files

  • modules/mocked_authentication/app/controllers/mocked_authentication/credential_controller.rb (+19/-0)

  • modules/mocked_authentication/config/routes.rb (+1/-0)

  • modules/mocked_authentication/lib/mockdata/reader.rb (+62/-0)

  • modules/mocked_authentication/lib/mockdata/writer.rb (+1/-1)

  • modules/mocked_authentication/spec/lib/mockdata/reader_spec.rb (+41/-0)

  • modules/mocked_authentication/spec/lib/mockdata/writer_spec.rb (+1/-1)

  • modules/mocked_authentication/spec/requests/credential_request_spec.rb (+82/-0)

    Note: We exclude files matching the following when considering PR size:

    *.csv, *.json, *.tsv, *.txt, Gemfile.lock, app/swagger, modules/mobile/docs, spec/fixtures/, spec/support/vcr_cassettes/, modules/mobile/spec/support/vcr_cassettes/, db/seeds, modules/vaos/app/docs, modules/meb_api/app/docs, modules/appeals_api/app/swagger/
    

Big PRs are difficult to review, often become stale, and cause delays.

Generated by 🚫 Danger

@va-vfs-bot va-vfs-bot temporarily deployed to 55597_mocked_auth_data_profiles/main/main March 23, 2023 22:47 Inactive
@bramleyjl bramleyjl force-pushed the 55597_mocked_auth_data_profiles branch from 30285ef to df21a42 Compare March 24, 2023 18:47
@va-vfs-bot va-vfs-bot temporarily deployed to 55597_mocked_auth_data_profiles/main/main March 24, 2023 18:48 Inactive
@va-vfs-bot va-vfs-bot temporarily deployed to 55597_mocked_auth_data_profiles/main/main March 24, 2023 18:54 Inactive
@bramleyjl bramleyjl added identity identity-backend Identity team backend label labels Mar 24, 2023
@bramleyjl bramleyjl marked this pull request as ready for review March 24, 2023 21:02
@bramleyjl bramleyjl requested a review from a team as a code owner March 24, 2023 21:02
Copy link
Contributor

@bosawt bosawt left a comment

Choose a reason for hiding this comment

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

Mostly comments around some code quality stuff, also have what (I think) will fix your CodeQL issue

@va-vfs-bot va-vfs-bot temporarily deployed to 55597_mocked_auth_data_profiles/main/main March 24, 2023 23:33 Inactive
@bramleyjl bramleyjl force-pushed the 55597_mocked_auth_data_profiles branch from 6d72db4 to 353b319 Compare March 29, 2023 21:24
@va-vsp-bot va-vsp-bot requested a deployment to master/main/55597_mocked_auth_data_profiles March 29, 2023 21:25 In progress
@va-vsp-bot va-vsp-bot requested a deployment to master/main/55597_mocked_auth_data_profiles March 29, 2023 22:14 In progress
@va-vsp-bot va-vsp-bot requested a deployment to master/main/55597_mocked_auth_data_profiles March 29, 2023 22:33 In progress
Copy link
Contributor

@bosawt bosawt left a comment

Choose a reason for hiding this comment

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

Just a small set of nitpicks this time for code quality. I did confirm it works so behaviorally seems good

modules/mocked_authentication/lib/mockdata/reader.rb Outdated Show resolved Hide resolved
modules/mocked_authentication/lib/mockdata/reader.rb Outdated Show resolved Hide resolved
modules/mocked_authentication/lib/mockdata/reader.rb Outdated Show resolved Hide resolved
@bramleyjl bramleyjl force-pushed the 55597_mocked_auth_data_profiles branch from 584baf7 to 11b8249 Compare March 30, 2023 20:05
@va-vsp-bot va-vsp-bot requested a deployment to master/main/55597_mocked_auth_data_profiles March 30, 2023 20:06 In progress
@bramleyjl bramleyjl requested a review from bosawt March 30, 2023 20:16
@va-vsp-bot va-vsp-bot requested a deployment to master/main/55597_mocked_auth_data_profiles March 30, 2023 20:16 In progress
Copy link
Contributor

@bosawt bosawt left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks for making the changes!

validate_index_params(type)
mock_profiles = Mockdata::Reader.find_credentials(credential_type: type)

render json: { mock_profiles: }
Copy link
Contributor

Choose a reason for hiding this comment

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

I've gotta admit, seeing the hashes like this after the Ruby 3.1 upgrade still catches me off guard for a second before I realize this is how it's supposed to be, ha

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm starting to get used to it surprisingly quickly! It really does cut a lot of unnecessary text out.

@bramleyjl bramleyjl merged commit d7bf6a4 into master Mar 31, 2023
@bramleyjl bramleyjl deleted the 55597_mocked_auth_data_profiles branch March 31, 2023 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
identity identity-backend Identity team backend label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants