Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Error response handling for permissions APIs #736

Merged
merged 8 commits into from
Feb 1, 2019

Conversation

lucassaldanha
Copy link
Contributor

PR description

Error messages:

Accounts API:

  • Adding/removing account without params: “Request contains an empty list of accounts”
  • Adding/removing an empty string from the whitelist: “Request contains an invalid account“
  • Request with duplicate entries: “Request contains duplicated accounts”
  • Adding an account that is already on the whitelist: "Cannot add an existing account to whitelist"
  • Removing an account that is NOT on the whitelist: "Cannot remove an absent account from whitelist"

Nodes API:

  • Adding/removing node without params: “Request contains an empty list of nodes”
  • Adding/removing an empty string from the whitelist: “Request contains an invalid node“
  • Request with duplicate entries: “Request contains duplicated nodes”
  • Adding a node that is already on the whitelist: “Cannot add an existing node to whitelist”
  • Removing a node that is NOT on the whitelist: “Cannot remove an absent node from the whitelist”

List<String> accounts = Arrays.asList("0x0", "0x1");
JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null, true);
when(accountWhitelist.addAccounts(eq(accounts))).thenReturn(AddResult.SUCCESS);
JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null, "Success");
Copy link
Contributor

Choose a reason for hiding this comment

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

Change to JsonRpcSuccessResponse(null)

List<String> accounts = Arrays.asList("0x0", "0x1");
JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null, true);
when(accountWhitelist.removeAccounts(eq(accounts))).thenReturn(RemoveResult.SUCCESS);
JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null, "Success");
Copy link
Contributor

Choose a reason for hiding this comment

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

JsonRpcSuccessResponse(null)

@lucassaldanha lucassaldanha merged commit fd65738 into PegaSysEng:master Feb 1, 2019
@lucassaldanha lucassaldanha deleted the nc-2113 branch February 3, 2019 08:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants