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

Audit Rewards server responses #5918

Merged
merged 1 commit into from
Jul 23, 2020
Merged

Conversation

emerick
Copy link
Contributor

@emerick emerick commented Jun 22, 2020

Resolves brave/brave-browser#9666

Submitter Checklist:

Test Plan:

No specific plan here, we just need to run through a general test of Rewards functionality with a focus on server communications.

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

@emerick emerick self-assigned this Jun 22, 2020
@emerick emerick requested a review from husobee June 22, 2020 19:07
@emerick
Copy link
Contributor Author

emerick commented Jun 22, 2020

@husobee If you take a look at the response/response_*.cc files, you'll see the HTTP response codes that we currently handle on the client and the JSON that we expect back from the server. Figured this might help you visualize the current client support as you work on doc'ing the ledger response codes for us.

@emerick emerick force-pushed the rewards-audit-server-responses branch 5 times, most recently from 6dd2aa9 to 9fc2685 Compare June 29, 2020 18:43
@emerick emerick force-pushed the rewards-audit-server-responses branch 2 times, most recently from 6c6e6d4 to f38ab00 Compare July 4, 2020 13:52
@emerick emerick force-pushed the rewards-audit-server-responses branch 5 times, most recently from 7931228 to 42ea64f Compare July 14, 2020 15:06
@emerick emerick changed the title WIP: Audit Rewards server responses Audit Rewards server responses Jul 14, 2020
@emerick emerick marked this pull request as ready for review July 14, 2020 16:28
@emerick emerick force-pushed the rewards-audit-server-responses branch from 42ea64f to 3a9b59d Compare July 14, 2020 16:29
@emerick emerick requested a review from zenparsing July 14, 2020 18:19
@emerick emerick force-pushed the rewards-audit-server-responses branch from 3a9b59d to b7f4754 Compare July 15, 2020 13:57
Copy link
Contributor

@NejcZdovc NejcZdovc left a comment

Choose a reason for hiding this comment

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

  1. All header guards need to be changed in response folder
    BRAVELEDGER_COMMON_RESPONSE_API_H_ -> BRAVELEDGER_RESPONSE_RESPONSE_API_H_`

  2. Functions in response folder should not have Response at the end of the functions as it's already in braveledger_response_util namespace

  3. Some functions in response folder have Parse prefix, but they are not parsing anything, just reading HTTP_CODE. I would suggest that we rename them to something like Check prefix.

Copy link
Collaborator

@zenparsing zenparsing left a comment

Choose a reason for hiding this comment

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

The response format documentation and parsing consolidations in this PR are great, and make it much easier to see our API client assumptions. Obviously keeping code comments in sync will be a challenge over time, but I think it's probably worth it in this case.

I'm less confident that moving all of this code out of its feature/responsibility area into a "response" folder is helpful, though. As it is, the code for accessing any particular HTTP service is already split out into a few different places:

  • static_values.h
  • The request folder
  • The general "subject" area folder that uses it

And having a "response" folder just means one more place to split things out into. Having a structure like this makes it harder to see the whole picture, harder to learn, and makes it more difficult to do gradual refactors. One option might be to create a new "endpoints" folder (or similar) that groups together each endpoint as an entity and provides a fetch function for each one.

In my opinion, for now I think we should keep these response files together in the folder where they are used. What do you think?


namespace braveledger_response_util {

ledger::ServerPublisherInfoPtr ParsePublisherInfoResponse(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would prefer not merge any refactors of the publist code at this time (as there might be uplift requirements).

@emerick emerick force-pushed the rewards-audit-server-responses branch 2 times, most recently from 8531c14 to 55b9974 Compare July 21, 2020 16:27
@emerick emerick requested review from zenparsing and NejcZdovc July 21, 2020 16:36
Copy link
Collaborator

@zenparsing zenparsing left a comment

Choose a reason for hiding this comment

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

The troubles that I've had this week have convinced me that we should not be refactoring publisher list v4 files until the feature has stabilized in 1.12.

@emerick emerick force-pushed the rewards-audit-server-responses branch 3 times, most recently from 8640528 to 67b0608 Compare July 22, 2020 20:42
@emerick emerick requested a review from iefremov as a code owner July 22, 2020 20:42
@emerick emerick force-pushed the rewards-audit-server-responses branch from 67b0608 to 8640528 Compare July 22, 2020 20:44
@emerick emerick removed the request for review from iefremov July 22, 2020 20:45
@emerick emerick force-pushed the rewards-audit-server-responses branch from 8640528 to 70dd047 Compare July 22, 2020 20:49
ledger::ResultCallback callback) {
base::Value parsed_response(base::Value::Type::DICTIONARY);
ParseSignedCredsResponse(response, &parsed_response);
const ledger::Result result =
Copy link
Contributor

Choose a reason for hiding this comment

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

we receive RETRY_SHORT, but it's ignored

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code receives RETRY_SHORT as a suggestion from a previous code review, but I guess I'm not sure why we wanted to make that logic change in the first place. None of this particular code has ever handled RETRY_SHORT before, from what I can see. It seems like ParseSignedCreds should return RETRY to remain consistent with how things were before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Spoke offline, I'll add a RETRY_SHORT handler to GetSignedCredsFromResponse.

@emerick emerick force-pushed the rewards-audit-server-responses branch 3 times, most recently from 0b80527 to 538ca7c Compare July 23, 2020 14:54
@emerick emerick requested a review from NejcZdovc July 23, 2020 14:54
@emerick emerick force-pushed the rewards-audit-server-responses branch from 538ca7c to 58246f6 Compare July 23, 2020 17:05
@emerick emerick merged commit fff07d5 into master Jul 23, 2020
@emerick emerick deleted the rewards-audit-server-responses branch July 23, 2020 20:27
@emerick emerick added this to the 1.13.x - Nightly milestone Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Audit server responses
3 participants