rename variables to use allowlist (#2832)

Signed-off-by: Sally MacFarlane <sally.macfarlane@consensys.net>
pull/2854/head
Sally MacFarlane 3 years ago committed by GitHub
parent 4d93bc75e5
commit aaad52e175
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AllowlistPersistorAcceptanceTest.java
  2. 2
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/AllowlistWithDnsPersistorAcceptanceTest.java
  3. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcConfiguration.java
  4. 10
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddNodesToAllowlist.java
  5. 10
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermGetNodesAllowlist.java
  6. 18
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermReloadPermissionsFromFile.java
  7. 10
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveNodesFromAllowlist.java
  8. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/JsonRpcMethodsFactory.java
  9. 38
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PermJsonRpcMethods.java
  10. 12
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceHostAllowlistTest.java

@ -64,7 +64,7 @@ public class AllowlistPersistorAcceptanceTest extends AcceptanceTestBase {
}
@Test
public void manipulatedAccountsWhitelistIsPersisted() {
public void manipulatedAccountsAllowlistIsPersisted() {
node.verify(
perm.expectPermissioningAllowlistFileKeyValue(
ALLOWLIST_TYPE.ACCOUNTS, tempFile, senderA.getAddress()));
@ -87,7 +87,7 @@ public class AllowlistPersistorAcceptanceTest extends AcceptanceTestBase {
}
@Test
public void manipulatedNodesWhitelistIsPersisted() {
public void manipulatedNodesAllowlistIsPersisted() {
node.verify(perm.addNodesToAllowlist(ENODE_ONE, ENODE_TWO));
node.verify(
perm.expectPermissioningAllowlistFileKeyValue(
@ -104,7 +104,7 @@ public class AllowlistPersistorAcceptanceTest extends AcceptanceTestBase {
}
@Test
public void manipulatedNodesWhitelistWithHostnameShouldNotWorkWhenDnsDisabled() {
public void manipulatedNodesAllowlistWithHostnameShouldNotWorkWhenDnsDisabled() {
Assertions.assertThatThrownBy(() -> node.verify(perm.addNodesToAllowlist(ENODE_FOURTH)))
.isInstanceOf(RuntimeException.class)
.hasMessageContaining("Request contains an invalid node");

@ -60,7 +60,7 @@ public class AllowlistWithDnsPersistorAcceptanceTest extends AcceptanceTestBase
}
@Test
public void manipulatedNodesWhitelistWithHostnameShouldWorkWhenDnsEnabled() {
public void manipulatedNodesAllowlistWithHostnameShouldWorkWhenDnsEnabled() {
node.verify(perm.addNodesToAllowlist(ENODE_ONE, ENODE_TWO));
node.verify(

@ -110,8 +110,8 @@ public class JsonRpcConfiguration {
return Collections.unmodifiableCollection(this.hostsAllowlist);
}
public void setHostsAllowlist(final List<String> hostsWhitelist) {
this.hostsAllowlist = hostsWhitelist;
public void setHostsAllowlist(final List<String> hostsAllowlist) {
this.hostsAllowlist = hostsAllowlist;
}
public boolean isAuthenticationEnabled() {

@ -32,11 +32,11 @@ import java.util.Optional;
public class PermAddNodesToAllowlist implements JsonRpcMethod {
private final Optional<NodeLocalConfigPermissioningController>
nodeWhitelistPermissioningController;
nodeAllowlistPermissioningController;
public PermAddNodesToAllowlist(
final Optional<NodeLocalConfigPermissioningController> nodeWhitelistPermissioningController) {
this.nodeWhitelistPermissioningController = nodeWhitelistPermissioningController;
final Optional<NodeLocalConfigPermissioningController> nodeAllowlistPermissioningController) {
this.nodeAllowlistPermissioningController = nodeAllowlistPermissioningController;
}
@Override
@ -50,11 +50,11 @@ public class PermAddNodesToAllowlist implements JsonRpcMethod {
requestContext.getRequiredParameter(0, StringListParameter.class);
try {
if (nodeWhitelistPermissioningController.isPresent()) {
if (nodeAllowlistPermissioningController.isPresent()) {
try {
final List<String> enodeURLs = enodeListParam.getStringList();
final NodesAllowlistResult nodesAllowlistResult =
nodeWhitelistPermissioningController.get().addNodes(enodeURLs);
nodeAllowlistPermissioningController.get().addNodes(enodeURLs);
switch (nodesAllowlistResult.result()) {
case SUCCESS:

@ -30,11 +30,11 @@ import java.util.Optional;
public class PermGetNodesAllowlist implements JsonRpcMethod {
private final Optional<NodeLocalConfigPermissioningController>
nodeWhitelistPermissioningController;
nodeAllowlistPermissioningController;
public PermGetNodesAllowlist(
final Optional<NodeLocalConfigPermissioningController> nodeWhitelistPermissioningController) {
this.nodeWhitelistPermissioningController = nodeWhitelistPermissioningController;
final Optional<NodeLocalConfigPermissioningController> nodeAllowlistPermissioningController) {
this.nodeAllowlistPermissioningController = nodeAllowlistPermissioningController;
}
@Override
@ -45,9 +45,9 @@ public class PermGetNodesAllowlist implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
try {
if (nodeWhitelistPermissioningController.isPresent()) {
if (nodeAllowlistPermissioningController.isPresent()) {
final List<String> enodeList =
nodeWhitelistPermissioningController.get().getNodesAllowlist();
nodeAllowlistPermissioningController.get().getNodesAllowlist();
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), enodeList);
} else {

@ -28,14 +28,14 @@ import java.util.Optional;
public class PermReloadPermissionsFromFile implements JsonRpcMethod {
private final Optional<AccountLocalConfigPermissioningController> accountWhitelistController;
private final Optional<NodeLocalConfigPermissioningController> nodesWhitelistController;
private final Optional<AccountLocalConfigPermissioningController> accountAllowlistController;
private final Optional<NodeLocalConfigPermissioningController> nodesAllowlistController;
public PermReloadPermissionsFromFile(
final Optional<AccountLocalConfigPermissioningController> accountWhitelistController,
final Optional<NodeLocalConfigPermissioningController> nodesWhitelistController) {
this.accountWhitelistController = accountWhitelistController;
this.nodesWhitelistController = nodesWhitelistController;
final Optional<AccountLocalConfigPermissioningController> accountAllowlistController,
final Optional<NodeLocalConfigPermissioningController> nodesAllowlistController) {
this.accountAllowlistController = accountAllowlistController;
this.nodesAllowlistController = nodesAllowlistController;
}
@Override
@ -45,14 +45,14 @@ public class PermReloadPermissionsFromFile implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
if (!accountWhitelistController.isPresent() && !nodesWhitelistController.isPresent()) {
if (!accountAllowlistController.isPresent() && !nodesAllowlistController.isPresent()) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), JsonRpcError.PERMISSIONING_NOT_ENABLED);
}
try {
accountWhitelistController.ifPresent(AccountLocalConfigPermissioningController::reload);
nodesWhitelistController.ifPresent(NodeLocalConfigPermissioningController::reload);
accountAllowlistController.ifPresent(AccountLocalConfigPermissioningController::reload);
nodesAllowlistController.ifPresent(NodeLocalConfigPermissioningController::reload);
return new JsonRpcSuccessResponse(requestContext.getRequest().getId());
} catch (Exception e) {
return new JsonRpcErrorResponse(

@ -32,11 +32,11 @@ import java.util.Optional;
public class PermRemoveNodesFromAllowlist implements JsonRpcMethod {
private final Optional<NodeLocalConfigPermissioningController>
nodeWhitelistPermissioningController;
nodeAllowlistPermissioningController;
public PermRemoveNodesFromAllowlist(
final Optional<NodeLocalConfigPermissioningController> nodeWhitelistPermissioningController) {
this.nodeWhitelistPermissioningController = nodeWhitelistPermissioningController;
final Optional<NodeLocalConfigPermissioningController> nodeAllowlistPermissioningController) {
this.nodeAllowlistPermissioningController = nodeAllowlistPermissioningController;
}
@Override
@ -49,11 +49,11 @@ public class PermRemoveNodesFromAllowlist implements JsonRpcMethod {
final StringListParameter enodeListParam =
requestContext.getRequiredParameter(0, StringListParameter.class);
try {
if (nodeWhitelistPermissioningController.isPresent()) {
if (nodeAllowlistPermissioningController.isPresent()) {
try {
final List<String> enodeURLs = enodeListParam.getStringList();
final NodesAllowlistResult nodesAllowlistResult =
nodeWhitelistPermissioningController.get().removeNodes(enodeURLs);
nodeAllowlistPermissioningController.get().removeNodes(enodeURLs);
switch (nodesAllowlistResult.result()) {
case SUCCESS:

@ -61,8 +61,8 @@ public class JsonRpcMethodsFactory {
final MiningCoordinator miningCoordinator,
final ObservableMetricsSystem metricsSystem,
final Set<Capability> supportedCapabilities,
final Optional<AccountLocalConfigPermissioningController> accountsWhitelistController,
final Optional<NodeLocalConfigPermissioningController> nodeWhitelistController,
final Optional<AccountLocalConfigPermissioningController> accountsAllowlistController,
final Optional<NodeLocalConfigPermissioningController> nodeAllowlistController,
final Collection<RpcApi> rpcApis,
final PrivacyParameters privacyParameters,
final JsonRpcConfiguration jsonRpcConfiguration,
@ -111,7 +111,7 @@ public class JsonRpcMethodsFactory {
webSocketConfiguration,
metricsConfiguration),
new MinerJsonRpcMethods(miningCoordinator),
new PermJsonRpcMethods(accountsWhitelistController, nodeWhitelistController),
new PermJsonRpcMethods(accountsAllowlistController, nodeAllowlistController),
new PrivJsonRpcMethods(
blockchainQueries,
protocolSchedule,

@ -38,14 +38,14 @@ import java.util.Optional;
public class PermJsonRpcMethods extends ApiGroupJsonRpcMethods {
private final Optional<AccountLocalConfigPermissioningController> accountsWhitelistController;
private final Optional<NodeLocalConfigPermissioningController> nodeWhitelistController;
private final Optional<AccountLocalConfigPermissioningController> accountsAllowlistController;
private final Optional<NodeLocalConfigPermissioningController> nodeAllowlistController;
public PermJsonRpcMethods(
final Optional<AccountLocalConfigPermissioningController> accountsWhitelistController,
final Optional<NodeLocalConfigPermissioningController> nodeWhitelistController) {
this.accountsWhitelistController = accountsWhitelistController;
this.nodeWhitelistController = nodeWhitelistController;
final Optional<AccountLocalConfigPermissioningController> accountsAllowlistController,
final Optional<NodeLocalConfigPermissioningController> nodeAllowlistController) {
this.accountsAllowlistController = accountsAllowlistController;
this.nodeAllowlistController = nodeAllowlistController;
}
@Override
@ -56,18 +56,18 @@ public class PermJsonRpcMethods extends ApiGroupJsonRpcMethods {
@Override
protected Map<String, JsonRpcMethod> create() {
return mapOf(
new PermAddNodesToWhitelist(nodeWhitelistController),
new PermAddNodesToAllowlist(nodeWhitelistController),
new PermRemoveNodesFromWhitelist(nodeWhitelistController),
new PermRemoveNodesFromAllowlist(nodeWhitelistController),
new PermGetNodesWhitelist(nodeWhitelistController),
new PermGetNodesAllowlist(nodeWhitelistController),
new PermGetAccountsWhitelist(accountsWhitelistController),
new PermGetAccountsAllowlist(accountsWhitelistController),
new PermAddAccountsToWhitelist(accountsWhitelistController),
new PermAddAccountsToAllowlist(accountsWhitelistController),
new PermRemoveAccountsFromWhitelist(accountsWhitelistController),
new PermRemoveAccountsFromAllowlist(accountsWhitelistController),
new PermReloadPermissionsFromFile(accountsWhitelistController, nodeWhitelistController));
new PermAddNodesToWhitelist(nodeAllowlistController),
new PermAddNodesToAllowlist(nodeAllowlistController),
new PermRemoveNodesFromWhitelist(nodeAllowlistController),
new PermRemoveNodesFromAllowlist(nodeAllowlistController),
new PermGetNodesWhitelist(nodeAllowlistController),
new PermGetNodesAllowlist(nodeAllowlistController),
new PermGetAccountsWhitelist(accountsAllowlistController),
new PermGetAccountsAllowlist(accountsAllowlistController),
new PermAddAccountsToWhitelist(accountsAllowlistController),
new PermAddAccountsToAllowlist(accountsAllowlistController),
new PermRemoveAccountsFromWhitelist(accountsAllowlistController),
new PermRemoveAccountsFromAllowlist(accountsAllowlistController),
new PermReloadPermissionsFromFile(accountsAllowlistController, nodeAllowlistController));
}
}

@ -64,7 +64,7 @@ import org.junit.ClassRule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
public class JsonRpcHttpServiceHostWhitelistTest {
public class JsonRpcHttpServiceHostAllowlistTest {
@ClassRule public static final TemporaryFolder folder = new TemporaryFolder();
@ -82,7 +82,7 @@ public class JsonRpcHttpServiceHostWhitelistTest {
private final JsonRpcConfiguration jsonRpcConfig = createJsonRpcConfig();
private final NatService natService = new NatService(Optional.empty());
private final List<String> hostsWhitelist = Arrays.asList("ally", "friend");
private final List<String> hostsAllowlist = Arrays.asList("ally", "friend");
@Before
public void initServerAndClient() throws Exception {
@ -170,8 +170,8 @@ public class JsonRpcHttpServiceHostWhitelistTest {
}
@Test
public void requestWithWhitelistedHostIsAccepted() throws IOException {
jsonRpcConfig.setHostsAllowlist(hostsWhitelist);
public void requestWithAllowlistedHostIsAccepted() throws IOException {
jsonRpcConfig.setHostsAllowlist(hostsAllowlist);
assertThat(doRequest("ally")).isEqualTo(200);
assertThat(doRequest("ally:12345")).isEqualTo(200);
assertThat(doRequest("friend")).isEqualTo(200);
@ -179,7 +179,7 @@ public class JsonRpcHttpServiceHostWhitelistTest {
@Test
public void requestWithUnknownHostIsRejected() throws IOException {
jsonRpcConfig.setHostsAllowlist(hostsWhitelist);
jsonRpcConfig.setHostsAllowlist(hostsAllowlist);
assertThat(doRequest("foe")).isEqualTo(403);
}
@ -196,7 +196,7 @@ public class JsonRpcHttpServiceHostWhitelistTest {
@Test
public void requestWithMalformedHostIsRejected() throws IOException {
jsonRpcConfig.setHostsAllowlist(hostsWhitelist);
jsonRpcConfig.setHostsAllowlist(hostsAllowlist);
assertThat(doRequest("ally:friend")).isEqualTo(403);
assertThat(doRequest("ally:123456")).isEqualTo(403);
assertThat(doRequest("ally:friend:1234")).isEqualTo(403);
Loading…
Cancel
Save