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

MB-2737 Ignore service item params in CreatePaymentRequestPayload #4313

Merged
merged 9 commits into from
Jul 9, 2020

Conversation

noelledusahel
Copy link
Contributor

@noelledusahel noelledusahel commented Jun 23, 2020

Description

The Prime may attempt to send Service Item Params through the Create Payment Request payload, but we want the source of truth to be the MTO. This PR achieves ignoring the input of service item params by converting this part of the payload to readOnly, and removing the handler function that assigns serviceItemParams to serviceItems. At this time there can be a CreatePaymentRequest success when serviceItemParams are passed, without throwing an error.

Reviewer Notes

Is there anything you would like reviewers to give additional scrutiny?

Setup

  • make db_dev_e2e_populate
  • make server_run
  • Make a pr_payload.json file containing the following (which references E2E data) running with this payload should produce an error, to make it successful, then remove the params part of the payload:
  {
    "body": {
      "isFinal": false,
      "moveTaskOrderID": "9c7b255c-2981-4bf8-839f-61c7458e2b4d",
      "serviceItems": [
        {
          "id": "76055c99-0990-410c-a7c9-69373b0b53eb",
          "params": [
            {
             "key": "weightActual",
              "value": "1111"
            }
          ]
        }
      ]
    }
  }
  • go run ./cmd/prime-api-client --insecure create-payment-request --filename pr_payload.json | jq
  • Verify parameters and that the payment request is created without the service item params passed in through the payment request payload (in this case weightActual).

Code Review Verification Steps

  • Code follows the guidelines for Logging
  • The requirements listed in
    Querying the Database Safely
    have been satisfied.
  • Any new migrations/schema changes:
    • Follow our guidelines for zero-downtime deploys (see Zero-Downtime Deploys)
    • Have been communicated to #g-database
    • Secure migrations have been tested following the instructions in our docs
  • There are no aXe warnings for UI.
  • This works in Supported Browsers and their phone views (Chrome, Firefox, IE, Edge).
  • Tested in the Experimental environment (for changes to containers, app startup, or connection to data stores)
  • User facing changes have been reviewed by design.
  • Request review from a member of a different team.
  • Have the Jira acceptance criteria been met for this change?

References

Screenshots

If this PR makes visible UI changes, an image of the finished UI can help reviewers and casual
observers understand the context of the changes. A before image is optional and
can be included at the submitter's discretion.

Consider using an animated image to show an entire workflow instead of using multiple images. You may want to use GIPHY CAPTURE for this! 📸

Please frame screenshots to show enough useful context but also highlight the affected regions.

@robot-mymove
Copy link

robot-mymove commented Jun 23, 2020

Messages
📖 🔗 MB-2737

Generated by 🚫 dangerJS against 96e659d

@noelledusahel noelledusahel changed the title MB-2737 Remove service item params in CreatePaymentRequestPayload MB-2737 Ignore service item params in CreatePaymentRequestPayload Jun 23, 2020
Copy link
Contributor

@gidjin gidjin left a comment

Choose a reason for hiding this comment

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

Looks like we should also return an error if params are sent in since they are now readOnly. See this thread. Also in trying it I get an error when running the steps in the setup, not sure if I've missed something or not.

2020/06/30 02:48:13 File decode failed: json: unknown field "params"

response := handler.Handle(params)
typedResponse := response.(*paymentrequestop.CreatePaymentRequestCreated)

paymentServiceItemParams := typedResponse.Payload.PaymentServiceItems[0].PaymentServiceItemParams
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to also verify that the call to CreatePaymentRequest isn't given any ServiceItemParams? I think that this will just be checking the mock return value that you defined above.

Copy link
Contributor

Choose a reason for hiding this comment

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

@gidjin looks like this as addressed already.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to test the error message that would be returned if someone were to pass in params?

Copy link
Contributor

Choose a reason for hiding this comment

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

@gidjin yes, I expect when the params are sent, there will be an error message. Or do you mean to test this in unit test? I think there is test for this but not on this function... let me see

Copy link
Contributor

Choose a reason for hiding this comment

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

Unit test or integration test. Just some sort of test, if possible would be nice. If not no worries

@pearl-truss
Copy link
Contributor

I'm getting a no matching versions for query "latest" after running make db_dev_e2e_populate. I did a make clean after switching branches

@blvrd
Copy link
Contributor

blvrd commented Jul 9, 2020

I'm getting a no matching versions for query "latest" after running make db_dev_e2e_populate. I did a make clean after switching branches

@pearl-truss here's what I usually do before reviewing a pull request:

make clean && make build && make db_dev_e2e_populate && make server_run

Maybe that will solve the problem. Also, every once in a while, I run make prune to clear out old Docker volumes just in case something weird is going on there.

Copy link
Contributor

@blvrd blvrd left a comment

Choose a reason for hiding this comment

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

This all looks great, and I'm getting the proper error when trying to send in service item params. I do agree with @gidjin that it might be good to test the actual error message that is returned if you have time to add that.

@jacquelineIO jacquelineIO merged commit c8673cb into master Jul 9, 2020
@jacquelineIO jacquelineIO deleted the nb-MB-2737-ignore-params branch July 9, 2020 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

6 participants