From 9e224ed7f3a90677aa59553a770223cd6f2dd3d0 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Wed, 24 Jun 2020 13:29:56 +1000 Subject: [PATCH] rename more "whitelist" occurrences to "allowlist" (#1133) * rename more whitelist occurrences; change allowlisted to allowed and reword where we ended up with allowlisting Signed-off-by: Sally MacFarlane --- ...AndOnChainPermissioningAcceptanceTest.java | 6 +- ...ntractPermissioningAcceptanceTestBase.java | 10 +- .../org/hyperledger/besu/RunnerBuilder.java | 8 +- .../hyperledger/besu/cli/BesuCommandTest.java | 69 +++++++--- .../api/graphql/GraphQLConfiguration.java | 18 +-- .../api/graphql/GraphQLHttpService.java | 12 +- .../api/jsonrpc/JsonRpcConfiguration.java | 12 +- .../PermAddNodesToAllowlist.java | 5 +- .../permissioning/PermGetNodesAllowlist.java | 2 +- .../PermRemoveNodesFromAllowlist.java | 5 +- .../internal/response/JsonRpcError.java | 6 +- .../jsonrpc/websocket/WebSocketService.java | 6 +- .../PermAddNodesToAllowlistTest.java | 12 +- .../PermAddNodesToWhitelistTest.java | 12 +- .../PermGetNodesAllowlistTest.java | 8 +- .../PermGetNodesWhitelistTest.java | 8 +- .../PermRemoveNodesFromAllowlistTest.java | 14 +- .../PermRemoveNodesFromWhitelistTest.java | 14 +- .../websocket/WebSocketHostAllowlistTest.java | 26 ++-- .../mainnet/MainnetTransactionValidator.java | 2 +- .../eth/transactions/TransactionPoolTest.java | 2 +- ...untLocalConfigPermissioningController.java | 2 +- ...odeLocalConfigPermissioningController.java | 122 ++++++++--------- .../PermissioningConfigurationBuilder.java | 22 +-- ...nt.java => NodeAllowlistUpdatedEvent.java} | 6 +- .../permissioning/AllowlistPersistorTest.java | 14 +- ...PermissioningConfigurationBuilderTest.java | 11 +- .../LocalPermissioningConfigurationTest.java | 8 +- ...ocalConfigPermissioningControllerTest.java | 126 ++++++++---------- .../prometheus/MetricsConfiguration.java | 22 +-- 30 files changed, 305 insertions(+), 285 deletions(-) rename ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/node/{NodeWhitelistUpdatedEvent.java => NodeAllowlistUpdatedEvent.java} (92%) diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalAndOnChainPermissioningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalAndOnChainPermissioningAcceptanceTest.java index 02f548ed35..1247c5b514 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalAndOnChainPermissioningAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalAndOnChainPermissioningAcceptanceTest.java @@ -37,7 +37,7 @@ public class NodeLocalAndOnChainPermissioningAcceptanceTest } @Test - public void testNodeCannotConnectWhnAllowlistedOnChainButNotLocal() { + public void testNodeCannotConnectWhenAllowedOnChainButNotLocally() { // add permissioned node after cluster start because we need enode URI for local config permissionedNode = permissionedNode("permissioned-node", bootnode, allowedNode); @@ -60,7 +60,7 @@ public class NodeLocalAndOnChainPermissioningAcceptanceTest } @Test - public void testNodeCannotConnectWhenAllowlistedLocalButNotOnChain() { + public void testNodeCannotConnectWhenAllowedLocallyButNotOnChain() { // onchain allowlist: A, B // local allowlist: A, B, C @@ -82,7 +82,7 @@ public class NodeLocalAndOnChainPermissioningAcceptanceTest } @Test - public void testNodesCanConnectWhenAllowlistedBothOnChainAndLocal() { + public void testNodesCanConnectWhenAllowedBothOnChainAndLocally() { // add permissioned node after cluster start because we need enode URI for local config permissionedNode = permissionedNode("permissioned-node", bootnode, allowedNode, forbiddenNode); permissionedCluster.addNode(permissionedNode); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTestBase.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTestBase.java index db5b385823..917e128768 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTestBase.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTestBase.java @@ -56,19 +56,19 @@ class NodeSmartContractPermissioningAcceptanceTestBase extends AcceptanceTestBas return new Cluster(clusterConfiguration, net); } - protected Node permissionedNode(final String name, final Node... localConfigAllowListedNodes) { - return permissionedNode(name, GENESIS_FILE, localConfigAllowListedNodes); + protected Node permissionedNode(final String name, final Node... localConfigAllowedNodes) { + return permissionedNode(name, GENESIS_FILE, localConfigAllowedNodes); } protected Node permissionedNode( - final String name, final String genesisFile, final Node... localConfigAllowListedNodes) { + final String name, final String genesisFile, final Node... localConfigAllowedNodes) { PermissionedNodeBuilder permissionedNodeBuilder = this.permissionedNodeBuilder .name(name) .genesisFile(genesisFile) .nodesContractEnabled(CONTRACT_ADDRESS); - if (localConfigAllowListedNodes != null && localConfigAllowListedNodes.length > 0) { - permissionedNodeBuilder.nodesPermittedInConfig(localConfigAllowListedNodes); + if (localConfigAllowedNodes != null && localConfigAllowedNodes.length > 0) { + permissionedNodeBuilder.nodesPermittedInConfig(localConfigAllowedNodes); } return permissionedNodeBuilder.build(); } diff --git a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java index 684b626688..2530e02e9c 100644 --- a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java @@ -669,8 +669,8 @@ public class RunnerBuilder { final Set supportedCapabilities, final Collection jsonRpcApis, final FilterManager filterManager, - final Optional accountWhitelistController, - final Optional nodeWhitelistController, + final Optional accountAllowlistController, + final Optional nodeAllowlistController, final PrivacyParameters privacyParameters, final JsonRpcConfiguration jsonRpcConfiguration, final WebSocketConfiguration webSocketConfiguration, @@ -692,8 +692,8 @@ public class RunnerBuilder { miningCoordinator, metricsSystem, supportedCapabilities, - accountWhitelistController, - nodeWhitelistController, + accountAllowlistController, + nodeAllowlistController, jsonRpcApis, privacyParameters, jsonRpcConfiguration, diff --git a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java index 64456c8ddb..7b6703440d 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -590,7 +590,7 @@ public class BesuCommandTest extends CommandTestAbstract { @Test public void nodePermissioningTomlPathMustUseOption() throws IOException { - final List allowlistedNodes = + final List allowedNodes = Lists.newArrayList( URI.create( "enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@192.168.0.9:4567"), @@ -600,18 +600,18 @@ public class BesuCommandTest extends CommandTestAbstract { final URL configFile = this.getClass().getResource(PERMISSIONING_CONFIG_TOML); final Path permToml = createTempFile("toml", Resources.toByteArray(configFile)); - final String allowlistedNodesString = - allowlistedNodes.stream().map(Object::toString).collect(Collectors.joining(",")); + final String allowedNodesString = + allowedNodes.stream().map(Object::toString).collect(Collectors.joining(",")); parseCommand( "--permissions-nodes-config-file-enabled", "--permissions-nodes-config-file", permToml.toString(), "--bootnodes", - allowlistedNodesString); + allowedNodesString); final LocalPermissioningConfiguration localPermissioningConfiguration = LocalPermissioningConfiguration.createDefault(); localPermissioningConfiguration.setNodePermissioningConfigFilePath(permToml.toString()); - localPermissioningConfiguration.setNodeAllowlist(allowlistedNodes); + localPermissioningConfiguration.setNodeAllowlist(allowedNodes); verify(mockRunnerBuilder) .permissioningConfiguration(permissioningConfigurationArgumentCaptor.capture()); @@ -2026,8 +2026,10 @@ public class BesuCommandTest extends CommandTestAbstract { .contains("Domain cannot be empty string or null string."); } + /** test deprecated CLI option * */ + @Deprecated @Test - public void rpcHttpHostAllowlistAcceptsSingleArgument() { + public void rpcHttpHostWhitelistAcceptsSingleArgument() { parseCommand("--host-whitelist", "a"); verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture()); @@ -2042,9 +2044,25 @@ public class BesuCommandTest extends CommandTestAbstract { assertThat(commandErrorOutput.toString()).isEmpty(); } + @Test + public void rpcHttpHostAllowlistAcceptsSingleArgument() { + parseCommand("--host-allowlist", "a"); + + verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture()); + verify(mockRunnerBuilder).build(); + + assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist().size()).isEqualTo(1); + assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist()).contains("a"); + assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist()) + .doesNotContain("localhost"); + + assertThat(commandOutput.toString()).isEmpty(); + assertThat(commandErrorOutput.toString()).isEmpty(); + } + @Test public void rpcHttpHostAllowlistAcceptsMultipleArguments() { - parseCommand("--host-whitelist", "a,b"); + parseCommand("--host-allowlist", "a,b"); verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture()); verify(mockRunnerBuilder).build(); @@ -2060,7 +2078,24 @@ public class BesuCommandTest extends CommandTestAbstract { @Test public void rpcHttpHostAllowlistAcceptsDoubleComma() { - parseCommand("--host-whitelist", "a,,b"); + parseCommand("--host-allowlist", "a,,b"); + + verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture()); + verify(mockRunnerBuilder).build(); + + assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist().size()).isEqualTo(2); + assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist()).contains("a", "b"); + assertThat(jsonRpcConfigArgumentCaptor.getValue().getHostsAllowlist()) + .doesNotContain("*", "localhost"); + + assertThat(commandOutput.toString()).isEmpty(); + assertThat(commandErrorOutput.toString()).isEmpty(); + } + + @Deprecated + @Test + public void rpcHttpHostWhitelistAllowlistAcceptsMultipleFlags() { + parseCommand("--host-whitelist=a", "--host-allowlist=b"); verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture()); verify(mockRunnerBuilder).build(); @@ -2076,7 +2111,7 @@ public class BesuCommandTest extends CommandTestAbstract { @Test public void rpcHttpHostAllowlistAcceptsMultipleFlags() { - parseCommand("--host-whitelist=a", "--host-whitelist=b"); + parseCommand("--host-allowlist=a", "--host-allowlist=b"); verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture()); verify(mockRunnerBuilder).build(); @@ -2093,7 +2128,7 @@ public class BesuCommandTest extends CommandTestAbstract { @Test public void rpcHttpHostAllowlistStarWithAnotherHostnameMustFail() { final String[] origins = {"friend", "*"}; - parseCommand("--host-whitelist", String.join(",", origins)); + parseCommand("--host-allowlist", String.join(",", origins)); Mockito.verifyZeroInteractions(mockRunnerBuilder); @@ -2105,7 +2140,7 @@ public class BesuCommandTest extends CommandTestAbstract { @Test public void rpcHttpHostAllowlistStarWithAnotherHostnameMustFailStarFirst() { final String[] origins = {"*", "friend"}; - parseCommand("--host-whitelist", String.join(",", origins)); + parseCommand("--host-allowlist", String.join(",", origins)); Mockito.verifyZeroInteractions(mockRunnerBuilder); @@ -2117,7 +2152,7 @@ public class BesuCommandTest extends CommandTestAbstract { @Test public void rpcHttpHostAllowlistAllWithAnotherHostnameMustFail() { final String[] origins = {"friend", "all"}; - parseCommand("--host-whitelist", String.join(",", origins)); + parseCommand("--host-allowlist", String.join(",", origins)); Mockito.verifyZeroInteractions(mockRunnerBuilder); @@ -2129,7 +2164,7 @@ public class BesuCommandTest extends CommandTestAbstract { @Test public void rpcHttpHostAllowlistWithNoneMustBuildEmptyList() { final String[] origins = {"none"}; - parseCommand("--host-whitelist", String.join(",", origins)); + parseCommand("--host-allowlist", String.join(",", origins)); verify(mockRunnerBuilder).jsonRpcConfiguration(jsonRpcConfigArgumentCaptor.capture()); verify(mockRunnerBuilder).build(); @@ -2143,7 +2178,7 @@ public class BesuCommandTest extends CommandTestAbstract { @Test public void rpcHttpHostAllowlistNoneWithAnotherDomainMustFail() { final String[] origins = {"http://domain1.com", "none"}; - parseCommand("--host-whitelist", String.join(",", origins)); + parseCommand("--host-allowlist", String.join(",", origins)); Mockito.verifyZeroInteractions(mockRunnerBuilder); @@ -2155,7 +2190,7 @@ public class BesuCommandTest extends CommandTestAbstract { @Test public void rpcHttpHostAllowlistNoneWithAnotherDomainMustFailNoneFirst() { final String[] origins = {"none", "http://domain1.com"}; - parseCommand("--host-whitelist", String.join(",", origins)); + parseCommand("--host-allowlist", String.join(",", origins)); Mockito.verifyZeroInteractions(mockRunnerBuilder); @@ -2166,7 +2201,7 @@ public class BesuCommandTest extends CommandTestAbstract { @Test public void rpcHttpHostAllowlistEmptyValueFails() { - parseCommand("--host-whitelist="); + parseCommand("--host-allowlist="); Mockito.verifyZeroInteractions(mockRunnerBuilder); @@ -3065,7 +3100,7 @@ public class BesuCommandTest extends CommandTestAbstract { @Rule public TemporaryFolder testFolder = new TemporaryFolder(); @Test - public void errorIsRaisedIfStaticNodesAreNotAllowlisted() throws IOException { + public void errorIsRaisedIfStaticNodesAreNotAllowed() throws IOException { final File staticNodesFile = testFolder.newFile("static-nodes.json"); staticNodesFile.deleteOnExit(); final File permissioningConfig = testFolder.newFile("permissioning"); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLConfiguration.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLConfiguration.java index b091c8c063..8c32b55288 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLConfiguration.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLConfiguration.java @@ -34,7 +34,7 @@ public class GraphQLConfiguration { private int port; private String host; private List corsAllowedDomains = Collections.emptyList(); - private List hostsWhitelist = Arrays.asList("localhost", "127.0.0.1"); + private List hostsAllowlist = Arrays.asList("localhost", "127.0.0.1"); private long httpTimeoutSec = TimeoutOptions.defaultOptions().getTimeoutSeconds(); public static GraphQLConfiguration createDefault() { @@ -81,13 +81,13 @@ public class GraphQLConfiguration { this.corsAllowedDomains = corsAllowedDomains; } - Collection getHostsWhitelist() { - return Collections.unmodifiableCollection(this.hostsWhitelist); + Collection getHostsAllowlist() { + return Collections.unmodifiableCollection(this.hostsAllowlist); } - public void setHostsAllowlist(final List hostsWhitelist) { - checkNotNull(hostsWhitelist); - this.hostsWhitelist = hostsWhitelist; + public void setHostsAllowlist(final List hostsAllowlist) { + checkNotNull(hostsAllowlist); + this.hostsAllowlist = hostsAllowlist; } public Long getHttpTimeoutSec() { @@ -105,7 +105,7 @@ public class GraphQLConfiguration { .add("port", port) .add("host", host) .add("corsAllowedDomains", corsAllowedDomains) - .add("hostsWhitelist", hostsWhitelist) + .add("hostsAllowlist", hostsAllowlist) .add("httpTimeoutSec", httpTimeoutSec) .toString(); } @@ -123,11 +123,11 @@ public class GraphQLConfiguration { && port == that.port && Objects.equals(host, that.host) && Objects.equals(corsAllowedDomains, that.corsAllowedDomains) - && Objects.equals(hostsWhitelist, that.hostsWhitelist); + && Objects.equals(hostsAllowlist, that.hostsAllowlist); } @Override public int hashCode() { - return Objects.hash(enabled, port, host, corsAllowedDomains, hostsWhitelist); + return Objects.hash(enabled, port, host, corsAllowedDomains, hostsAllowlist); } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLHttpService.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLHttpService.java index 9b49b78e6a..a06aa401a2 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLHttpService.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLHttpService.java @@ -192,8 +192,8 @@ public class GraphQLHttpService { private Handler checkWhitelistHostHeader() { return event -> { final Optional hostHeader = getAndValidateHostHeader(event); - if (config.getHostsWhitelist().contains("*") - || (hostHeader.isPresent() && hostIsInWhitelist(hostHeader.get()))) { + if (config.getHostsAllowlist().contains("*") + || (hostHeader.isPresent() && hostIsInAllowlist(hostHeader.get()))) { event.next(); } else { final HttpServerResponse response = event.response(); @@ -219,13 +219,13 @@ public class GraphQLHttpService { return Optional.ofNullable(Iterables.get(splitHostHeader, 0)); } - private boolean hostIsInWhitelist(final String hostHeader) { - if (config.getHostsWhitelist().stream() + private boolean hostIsInAllowlist(final String hostHeader) { + if (config.getHostsAllowlist().stream() .anyMatch( - whitelistEntry -> whitelistEntry.toLowerCase().equals(hostHeader.toLowerCase()))) { + allowlistEntry -> allowlistEntry.toLowerCase().equals(hostHeader.toLowerCase()))) { return true; } else { - LOG.trace("Host not in whitelist: '{}'", hostHeader); + LOG.trace("Host not in allowlist: '{}'", hostHeader); return false; } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcConfiguration.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcConfiguration.java index d098ba846a..7afc35a0ba 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcConfiguration.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcConfiguration.java @@ -37,7 +37,7 @@ public class JsonRpcConfiguration { private String host; private List corsAllowedDomains = Collections.emptyList(); private List rpcApis; - private List hostsWhitelist = Arrays.asList("localhost", "127.0.0.1"); + private List hostsAllowlist = Arrays.asList("localhost", "127.0.0.1"); private boolean authenticationEnabled = false; private String authenticationCredentialsFile; private File authenticationPublicKeyFile; @@ -104,11 +104,11 @@ public class JsonRpcConfiguration { } public Collection getHostsAllowlist() { - return Collections.unmodifiableCollection(this.hostsWhitelist); + return Collections.unmodifiableCollection(this.hostsAllowlist); } public void setHostsAllowlist(final List hostsWhitelist) { - this.hostsWhitelist = hostsWhitelist; + this.hostsAllowlist = hostsWhitelist; } public boolean isAuthenticationEnabled() { @@ -158,7 +158,7 @@ public class JsonRpcConfiguration { .add("port", port) .add("host", host) .add("corsAllowedDomains", corsAllowedDomains) - .add("hostsWhitelist", hostsWhitelist) + .add("hostsAllowlist", hostsAllowlist) .add("rpcApis", rpcApis) .add("authenticationEnabled", authenticationEnabled) .add("authenticationCredentialsFile", authenticationCredentialsFile) @@ -183,7 +183,7 @@ public class JsonRpcConfiguration { && Objects.equals(host, that.host) && Objects.equals(corsAllowedDomains, that.corsAllowedDomains) && Objects.equals(rpcApis, that.rpcApis) - && Objects.equals(hostsWhitelist, that.hostsWhitelist) + && Objects.equals(hostsAllowlist, that.hostsAllowlist) && Objects.equals(authenticationCredentialsFile, that.authenticationCredentialsFile) && Objects.equals(authenticationPublicKeyFile, that.authenticationPublicKeyFile); } @@ -196,7 +196,7 @@ public class JsonRpcConfiguration { host, corsAllowedDomains, rpcApis, - hostsWhitelist, + hostsAllowlist, authenticationEnabled, authenticationCredentialsFile, authenticationPublicKeyFile); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddNodesToAllowlist.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddNodesToAllowlist.java index 1329d82109..c4fde95398 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddNodesToAllowlist.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddNodesToAllowlist.java @@ -24,6 +24,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcRespon import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.p2p.network.exceptions.P2PDisabledException; import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController; +import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult; import java.util.List; import java.util.Optional; @@ -52,10 +53,10 @@ public class PermAddNodesToAllowlist implements JsonRpcMethod { if (nodeWhitelistPermissioningController.isPresent()) { try { final List enodeURLs = enodeListParam.getStringList(); - final NodeLocalConfigPermissioningController.NodesWhitelistResult nodesWhitelistResult = + final NodesAllowlistResult nodesAllowlistResult = nodeWhitelistPermissioningController.get().addNodes(enodeURLs); - switch (nodesWhitelistResult.result()) { + switch (nodesAllowlistResult.result()) { case SUCCESS: return new JsonRpcSuccessResponse(requestContext.getRequest().getId()); case ERROR_EMPTY_ENTRY: diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermGetNodesAllowlist.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermGetNodesAllowlist.java index 9b4f19a143..ed763f8b1e 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermGetNodesAllowlist.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermGetNodesAllowlist.java @@ -47,7 +47,7 @@ public class PermGetNodesAllowlist implements JsonRpcMethod { try { if (nodeWhitelistPermissioningController.isPresent()) { final List enodeList = - nodeWhitelistPermissioningController.get().getNodesWhitelist(); + nodeWhitelistPermissioningController.get().getNodesAllowlist(); return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), enodeList); } else { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveNodesFromAllowlist.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveNodesFromAllowlist.java index 1e3532c32b..3f28b603ee 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveNodesFromAllowlist.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveNodesFromAllowlist.java @@ -24,6 +24,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcRespon import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.p2p.network.exceptions.P2PDisabledException; import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController; +import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult; import java.util.List; import java.util.Optional; @@ -51,10 +52,10 @@ public class PermRemoveNodesFromAllowlist implements JsonRpcMethod { if (nodeWhitelistPermissioningController.isPresent()) { try { final List enodeURLs = enodeListParam.getStringList(); - final NodeLocalConfigPermissioningController.NodesWhitelistResult nodesWhitelistResult = + final NodesAllowlistResult nodesAllowlistResult = nodeWhitelistPermissioningController.get().removeNodes(enodeURLs); - switch (nodesWhitelistResult.result()) { + switch (nodesAllowlistResult.result()) { case SUCCESS: return new JsonRpcSuccessResponse(requestContext.getRequest().getId()); case ERROR_EMPTY_ENTRY: diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java index 586916fdf8..989e07faf3 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java @@ -77,7 +77,7 @@ public enum JsonRpcError { PARENT_BLOCK_NOT_FOUND(-32000, "Parent block not found"), // Permissioning/Account allowlist errors - ACCOUNT_ALLOWLIST_NOT_ENABLED(-32000, "Account allowlisting has not been enabled"), + ACCOUNT_ALLOWLIST_NOT_ENABLED(-32000, "Account allowlist has not been enabled"), ACCOUNT_ALLOWLIST_EMPTY_ENTRY(-32000, "Request contains an empty list of accounts"), ACCOUNT_ALLOWLIST_INVALID_ENTRY(-32000, "Request contains an invalid account"), ACCOUNT_ALLOWLIST_DUPLICATED_ENTRY(-32000, "Request contains duplicate accounts"), @@ -85,7 +85,7 @@ public enum JsonRpcError { ACCOUNT_ALLOWLIST_ABSENT_ENTRY(-32000, "Cannot remove an absent account from allowlist"), // Permissioning/Node allowlist errors - NODE_ALLOWLIST_NOT_ENABLED(-32000, "Node allowlisting has not been enabled"), + NODE_ALLOWLIST_NOT_ENABLED(-32000, "Node allowlist has not been enabled"), NODE_ALLOWLIST_EMPTY_ENTRY(-32000, "Request contains an empty list of nodes"), NODE_ALLOWLIST_INVALID_ENTRY(-32000, "Request contains an invalid node"), NODE_ALLOWLIST_DUPLICATED_ENTRY(-32000, "Request contains duplicate nodes"), @@ -103,7 +103,7 @@ public enum JsonRpcError { ALLOWLIST_RELOAD_ERROR( -32000, "Error reloading permissions file. Please use perm_getAccountsAllowlist and perm_getNodesAllowlist to review the current state of the allowlists"), - PERMISSIONING_NOT_ENABLED(-32000, "Node/Account allowlisting has not been enabled"), + PERMISSIONING_NOT_ENABLED(-32000, "Node/Account allowlist has not been enabled"), NON_PERMITTED_NODE_CANNOT_BE_ADDED_AS_A_PEER(-32000, "Cannot add a non-permitted node as a peer"), // Permissioning/Authorization errors diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketService.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketService.java index d389e00aad..d5a1239837 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketService.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketService.java @@ -108,7 +108,7 @@ public class WebSocketService { LOG.trace("Websocket authentication token {}", token); } - if (!hasAllowlistedHostnameHeader(Optional.ofNullable(websocket.headers().get("Host")))) { + if (!hasAllowedHostnameHeader(Optional.ofNullable(websocket.headers().get("Host")))) { websocket.reject(403); } @@ -233,7 +233,7 @@ public class WebSocketService { private Handler checkAllowlistHostHeader() { return event -> { - if (hasAllowlistedHostnameHeader(Optional.ofNullable(event.request().host()))) { + if (hasAllowedHostnameHeader(Optional.ofNullable(event.request().host()))) { event.next(); } else { final HttpServerResponse response = event.response(); @@ -248,7 +248,7 @@ public class WebSocketService { } @VisibleForTesting - public boolean hasAllowlistedHostnameHeader(final Optional header) { + public boolean hasAllowedHostnameHeader(final Optional header) { return configuration.getHostsAllowlist().contains("*") || header.map(value -> checkHostInAllowlist(validateHostHeader(value))).orElse(false); } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddNodesToAllowlistTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddNodesToAllowlistTest.java index d5696f8001..bbd2cbbda5 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddNodesToAllowlistTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddNodesToAllowlistTest.java @@ -15,7 +15,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning; import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesWhitelistResult; +import static org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.times; @@ -110,7 +110,7 @@ public class PermAddNodesToAllowlistTest { request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY); when(nodeLocalConfigPermissioningController.addNodes(eq(Lists.emptyList()))) - .thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); + .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); final JsonRpcResponse actual = method.response(request); @@ -125,7 +125,7 @@ public class PermAddNodesToAllowlistTest { request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_DUPLICATED_ENTRY); when(nodeLocalConfigPermissioningController.addNodes(any())) - .thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY)); + .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY)); final JsonRpcResponse actual = method.response(request); @@ -140,7 +140,7 @@ public class PermAddNodesToAllowlistTest { request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY); when(nodeLocalConfigPermissioningController.addNodes(eq(new ArrayList<>()))) - .thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); + .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); final JsonRpcResponse actual = method.response(request); @@ -153,7 +153,7 @@ public class PermAddNodesToAllowlistTest { final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId()); when(nodeLocalConfigPermissioningController.addNodes(any())) - .thenReturn(new NodesWhitelistResult(AllowlistOperationResult.SUCCESS)); + .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.SUCCESS)); final JsonRpcResponse actual = method.response(request); @@ -169,7 +169,7 @@ public class PermAddNodesToAllowlistTest { final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId()); when(nodeLocalConfigPermissioningController.addNodes(any())) - .thenReturn(new NodesWhitelistResult(AllowlistOperationResult.SUCCESS)); + .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.SUCCESS)); final JsonRpcResponse actual = method.response(request); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddNodesToWhitelistTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddNodesToWhitelistTest.java index 598bb68a75..ea5daf79a5 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddNodesToWhitelistTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddNodesToWhitelistTest.java @@ -15,7 +15,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning; import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesWhitelistResult; +import static org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.times; @@ -111,7 +111,7 @@ public class PermAddNodesToWhitelistTest { request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY); when(nodeLocalConfigPermissioningController.addNodes(eq(Lists.emptyList()))) - .thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); + .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); final JsonRpcResponse actual = method.response(request); @@ -126,7 +126,7 @@ public class PermAddNodesToWhitelistTest { request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_DUPLICATED_ENTRY); when(nodeLocalConfigPermissioningController.addNodes(any())) - .thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY)); + .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY)); final JsonRpcResponse actual = method.response(request); @@ -141,7 +141,7 @@ public class PermAddNodesToWhitelistTest { request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY); when(nodeLocalConfigPermissioningController.addNodes(eq(new ArrayList<>()))) - .thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); + .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); final JsonRpcResponse actual = method.response(request); @@ -154,7 +154,7 @@ public class PermAddNodesToWhitelistTest { final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId()); when(nodeLocalConfigPermissioningController.addNodes(any())) - .thenReturn(new NodesWhitelistResult(AllowlistOperationResult.SUCCESS)); + .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.SUCCESS)); final JsonRpcResponse actual = method.response(request); @@ -170,7 +170,7 @@ public class PermAddNodesToWhitelistTest { final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId()); when(nodeLocalConfigPermissioningController.addNodes(any())) - .thenReturn(new NodesWhitelistResult(AllowlistOperationResult.SUCCESS)); + .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.SUCCESS)); final JsonRpcResponse actual = method.response(request); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermGetNodesAllowlistTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermGetNodesAllowlistTest.java index 470666173e..a7d261b845 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermGetNodesAllowlistTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermGetNodesAllowlistTest.java @@ -71,14 +71,14 @@ public class PermGetNodesAllowlistTest { new JsonRpcSuccessResponse( request.getRequest().getId(), Lists.newArrayList(enode1, enode2, enode3)); - when(nodeLocalConfigPermissioningController.getNodesWhitelist()) + when(nodeLocalConfigPermissioningController.getNodesAllowlist()) .thenReturn(buildNodesList(enode1, enode2, enode3)); final JsonRpcResponse actual = method.response(request); assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected); - verify(nodeLocalConfigPermissioningController, times(1)).getNodesWhitelist(); + verify(nodeLocalConfigPermissioningController, times(1)).getNodesAllowlist(); verifyNoMoreInteractions(nodeLocalConfigPermissioningController); } @@ -88,13 +88,13 @@ public class PermGetNodesAllowlistTest { final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId(), Lists.emptyList()); - when(nodeLocalConfigPermissioningController.getNodesWhitelist()).thenReturn(buildNodesList()); + when(nodeLocalConfigPermissioningController.getNodesAllowlist()).thenReturn(buildNodesList()); final JsonRpcResponse actual = method.response(request); assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected); - verify(nodeLocalConfigPermissioningController, times(1)).getNodesWhitelist(); + verify(nodeLocalConfigPermissioningController, times(1)).getNodesAllowlist(); verifyNoMoreInteractions(nodeLocalConfigPermissioningController); } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermGetNodesWhitelistTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermGetNodesWhitelistTest.java index 05bd029b3c..a644e090c4 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermGetNodesWhitelistTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermGetNodesWhitelistTest.java @@ -72,14 +72,14 @@ public class PermGetNodesWhitelistTest { new JsonRpcSuccessResponse( request.getRequest().getId(), Lists.newArrayList(enode1, enode2, enode3)); - when(nodeLocalConfigPermissioningController.getNodesWhitelist()) + when(nodeLocalConfigPermissioningController.getNodesAllowlist()) .thenReturn(buildNodesList(enode1, enode2, enode3)); final JsonRpcResponse actual = method.response(request); assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected); - verify(nodeLocalConfigPermissioningController, times(1)).getNodesWhitelist(); + verify(nodeLocalConfigPermissioningController, times(1)).getNodesAllowlist(); verifyNoMoreInteractions(nodeLocalConfigPermissioningController); } @@ -89,13 +89,13 @@ public class PermGetNodesWhitelistTest { final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId(), Lists.emptyList()); - when(nodeLocalConfigPermissioningController.getNodesWhitelist()).thenReturn(buildNodesList()); + when(nodeLocalConfigPermissioningController.getNodesAllowlist()).thenReturn(buildNodesList()); final JsonRpcResponse actual = method.response(request); assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected); - verify(nodeLocalConfigPermissioningController, times(1)).getNodesWhitelist(); + verify(nodeLocalConfigPermissioningController, times(1)).getNodesAllowlist(); verifyNoMoreInteractions(nodeLocalConfigPermissioningController); } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveNodesFromAllowlistTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveNodesFromAllowlistTest.java index e180cd9927..f96526d150 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveNodesFromAllowlistTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveNodesFromAllowlistTest.java @@ -15,7 +15,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning; import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesWhitelistResult; +import static org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.times; @@ -93,7 +93,7 @@ public class PermRemoveNodesFromAllowlistTest { request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY); when(nodeLocalConfigPermissioningController.removeNodes(eq(Lists.emptyList()))) - .thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); + .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); final JsonRpcResponse actual = method.response(request); @@ -106,7 +106,7 @@ public class PermRemoveNodesFromAllowlistTest { final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId()); when(nodeLocalConfigPermissioningController.removeNodes(any())) - .thenReturn(new NodesWhitelistResult(AllowlistOperationResult.SUCCESS)); + .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.SUCCESS)); final JsonRpcResponse actual = method.response(request); @@ -122,7 +122,7 @@ public class PermRemoveNodesFromAllowlistTest { final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId()); when(nodeLocalConfigPermissioningController.removeNodes(any())) - .thenReturn(new NodesWhitelistResult(AllowlistOperationResult.SUCCESS)); + .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.SUCCESS)); final JsonRpcResponse actual = method.response(request); @@ -152,7 +152,7 @@ public class PermRemoveNodesFromAllowlistTest { request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_DUPLICATED_ENTRY); when(nodeLocalConfigPermissioningController.removeNodes(any())) - .thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY)); + .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY)); final JsonRpcResponse actual = method.response(request); @@ -167,7 +167,7 @@ public class PermRemoveNodesFromAllowlistTest { request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY); when(nodeLocalConfigPermissioningController.removeNodes(eq(new ArrayList<>()))) - .thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); + .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); final JsonRpcResponse actual = method.response(request); @@ -183,7 +183,7 @@ public class PermRemoveNodesFromAllowlistTest { when(nodeLocalConfigPermissioningController.removeNodes(any())) .thenReturn( - new NodesWhitelistResult(AllowlistOperationResult.ERROR_FIXED_NODE_CANNOT_BE_REMOVED)); + new NodesAllowlistResult(AllowlistOperationResult.ERROR_FIXED_NODE_CANNOT_BE_REMOVED)); final JsonRpcResponse actual = method.response(request); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveNodesFromWhitelistTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveNodesFromWhitelistTest.java index 9810ca107b..f0dcde3de6 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveNodesFromWhitelistTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveNodesFromWhitelistTest.java @@ -15,7 +15,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.permissioning; import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesWhitelistResult; +import static org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.times; @@ -94,7 +94,7 @@ public class PermRemoveNodesFromWhitelistTest { request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY); when(nodeLocalConfigPermissioningController.removeNodes(eq(Lists.emptyList()))) - .thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); + .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); final JsonRpcResponse actual = method.response(request); @@ -107,7 +107,7 @@ public class PermRemoveNodesFromWhitelistTest { final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId()); when(nodeLocalConfigPermissioningController.removeNodes(any())) - .thenReturn(new NodesWhitelistResult(AllowlistOperationResult.SUCCESS)); + .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.SUCCESS)); final JsonRpcResponse actual = method.response(request); @@ -123,7 +123,7 @@ public class PermRemoveNodesFromWhitelistTest { final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId()); when(nodeLocalConfigPermissioningController.removeNodes(any())) - .thenReturn(new NodesWhitelistResult(AllowlistOperationResult.SUCCESS)); + .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.SUCCESS)); final JsonRpcResponse actual = method.response(request); @@ -153,7 +153,7 @@ public class PermRemoveNodesFromWhitelistTest { request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_DUPLICATED_ENTRY); when(nodeLocalConfigPermissioningController.removeNodes(any())) - .thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY)); + .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY)); final JsonRpcResponse actual = method.response(request); @@ -168,7 +168,7 @@ public class PermRemoveNodesFromWhitelistTest { request.getRequest().getId(), JsonRpcError.NODE_ALLOWLIST_EMPTY_ENTRY); when(nodeLocalConfigPermissioningController.removeNodes(eq(new ArrayList<>()))) - .thenReturn(new NodesWhitelistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); + .thenReturn(new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY)); final JsonRpcResponse actual = method.response(request); @@ -184,7 +184,7 @@ public class PermRemoveNodesFromWhitelistTest { when(nodeLocalConfigPermissioningController.removeNodes(any())) .thenReturn( - new NodesWhitelistResult(AllowlistOperationResult.ERROR_FIXED_NODE_CANNOT_BE_REMOVED)); + new NodesAllowlistResult(AllowlistOperationResult.ERROR_FIXED_NODE_CANNOT_BE_REMOVED)); final JsonRpcResponse actual = method.response(request); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketHostAllowlistTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketHostAllowlistTest.java index 4904e1b2c9..feef777894 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketHostAllowlistTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketHostAllowlistTest.java @@ -104,7 +104,7 @@ public class WebSocketHostAllowlistTest { @Test public void websocketRequestWithDefaultHeaderAndDefaultConfigIsAccepted() { - boolean result = websocketService.hasAllowlistedHostnameHeader(Optional.of("localhost:50012")); + boolean result = websocketService.hasAllowedHostnameHeader(Optional.of("localhost:50012")); assertThat(result).isTrue(); } @@ -115,7 +115,7 @@ public class WebSocketHostAllowlistTest { @Test public void websocketRequestWithEmptyHeaderAndDefaultConfigIsRejected() { - assertThat(websocketService.hasAllowlistedHostnameHeader(Optional.of(""))).isFalse(); + assertThat(websocketService.hasAllowedHostnameHeader(Optional.of(""))).isFalse(); } @Test @@ -126,8 +126,8 @@ public class WebSocketHostAllowlistTest { @Test public void websocketRequestWithAnyHostnameAndWildcardConfigIsAccepted() { webSocketConfiguration.setHostsAllowlist(Collections.singletonList("*")); - assertThat(websocketService.hasAllowlistedHostnameHeader(Optional.of("ally"))).isTrue(); - assertThat(websocketService.hasAllowlistedHostnameHeader(Optional.of("foe"))).isTrue(); + assertThat(websocketService.hasAllowedHostnameHeader(Optional.of("ally"))).isTrue(); + assertThat(websocketService.hasAllowedHostnameHeader(Optional.of("foe"))).isTrue(); } @Test @@ -138,15 +138,15 @@ public class WebSocketHostAllowlistTest { } @Test - public void websocketRequestWithAllowlistedHostIsAccepted() { + public void websocketRequestWithAllowedHostIsAccepted() { webSocketConfiguration.setHostsAllowlist(hostsAllowlist); - assertThat(websocketService.hasAllowlistedHostnameHeader(Optional.of("ally"))).isTrue(); - assertThat(websocketService.hasAllowlistedHostnameHeader(Optional.of("ally:12345"))).isTrue(); - assertThat(websocketService.hasAllowlistedHostnameHeader(Optional.of("friend"))).isTrue(); + assertThat(websocketService.hasAllowedHostnameHeader(Optional.of("ally"))).isTrue(); + assertThat(websocketService.hasAllowedHostnameHeader(Optional.of("ally:12345"))).isTrue(); + assertThat(websocketService.hasAllowedHostnameHeader(Optional.of("friend"))).isTrue(); } @Test - public void httpRequestWithAllowlistedHostIsAccepted(final TestContext context) { + public void httpRequestWithAllowedHostIsAccepted(final TestContext context) { webSocketConfiguration.setHostsAllowlist(hostsAllowlist); doHttpRequestAndVerify(context, "ally", 400); doHttpRequestAndVerify(context, "ally:12345", 400); @@ -156,7 +156,7 @@ public class WebSocketHostAllowlistTest { @Test public void websocketRequestWithUnknownHostIsRejected() { webSocketConfiguration.setHostsAllowlist(hostsAllowlist); - assertThat(websocketService.hasAllowlistedHostnameHeader(Optional.of("foe"))).isFalse(); + assertThat(websocketService.hasAllowedHostnameHeader(Optional.of("foe"))).isFalse(); } @Test @@ -169,9 +169,9 @@ public class WebSocketHostAllowlistTest { public void websocketRequestWithMalformedHostIsRejected() { webSocketConfiguration.setAuthenticationEnabled(false); webSocketConfiguration.setHostsAllowlist(hostsAllowlist); - assertThat(websocketService.hasAllowlistedHostnameHeader(Optional.of("ally:friend"))).isFalse(); - assertThat(websocketService.hasAllowlistedHostnameHeader(Optional.of("ally:123456"))).isFalse(); - assertThat(websocketService.hasAllowlistedHostnameHeader(Optional.of("ally:friend:1234"))) + assertThat(websocketService.hasAllowedHostnameHeader(Optional.of("ally:friend"))).isFalse(); + assertThat(websocketService.hasAllowedHostnameHeader(Optional.of("ally:123456"))).isFalse(); + assertThat(websocketService.hasAllowedHostnameHeader(Optional.of("ally:friend:1234"))) .isFalse(); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidator.java index 6604b998a1..f745709d32 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidator.java @@ -149,7 +149,7 @@ public class MainnetTransactionValidator implements TransactionValidator { if (!isSenderAllowed(transaction, validationParams)) { return ValidationResult.invalid( TransactionInvalidReason.TX_SENDER_NOT_AUTHORIZED, - String.format("Sender %s is not on the Account Whitelist", transaction.getSender())); + String.format("Sender %s is not on the Account Allowlist", transaction.getSender())); } return ValidationResult.valid(); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolTest.java index b5fc61fffe..e1ecc6dc39 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolTest.java @@ -516,7 +516,7 @@ public class TransactionPoolTest { } @Test - public void shouldAllowTransactionWhenAccountWhitelistControllerIsNotPresent() { + public void shouldAllowTransactionWhenAccountAllowlistControllerIsNotPresent() { givenTransactionIsValid(transaction1); assertThat(transactionPool.addLocalTransaction(transaction1)).isEqualTo(valid()); diff --git a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/AccountLocalConfigPermissioningController.java b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/AccountLocalConfigPermissioningController.java index 5058db99b8..89a6ac2543 100644 --- a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/AccountLocalConfigPermissioningController.java +++ b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/AccountLocalConfigPermissioningController.java @@ -216,7 +216,7 @@ public class AccountLocalConfigPermissioningController implements TransactionPer configuration = updatedConfig; } catch (Exception e) { LOG.warn( - "Error reloading permissions file. In-memory allowlisted accounts will be reverted to previous valid configuration. " + "Error reloading permissions file. In-memory accounts allowlist will be reverted to previous valid configuration. " + "Details: {}", e.getMessage()); accountAllowlist.clear(); diff --git a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodeLocalConfigPermissioningController.java b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodeLocalConfigPermissioningController.java index 676ebe01ec..9e93380819 100644 --- a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodeLocalConfigPermissioningController.java +++ b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodeLocalConfigPermissioningController.java @@ -16,8 +16,8 @@ package org.hyperledger.besu.ethereum.permissioning; import org.hyperledger.besu.ethereum.p2p.peers.EnodeURL; import org.hyperledger.besu.ethereum.permissioning.AllowlistPersistor.ALLOWLIST_TYPE; +import org.hyperledger.besu.ethereum.permissioning.node.NodeAllowlistUpdatedEvent; import org.hyperledger.besu.ethereum.permissioning.node.NodePermissioningProvider; -import org.hyperledger.besu.ethereum.permissioning.node.NodeWhitelistUpdatedEvent; import org.hyperledger.besu.metrics.BesuMetricCategory; import org.hyperledger.besu.plugin.services.MetricsSystem; import org.hyperledger.besu.plugin.services.metrics.Counter; @@ -47,9 +47,9 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning private LocalPermissioningConfiguration configuration; private final List fixedNodes; private final Bytes localNodeId; - private final List nodesWhitelist = new ArrayList<>(); + private final List nodesAllowlist = new ArrayList<>(); private final AllowlistPersistor allowlistPersistor; - private final Subscribers> nodeWhitelistUpdatedObservers = + private final Subscribers> nodeAllowlistUpdatedObservers = Subscribers.create(); private final Counter checkCounter; @@ -106,8 +106,8 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning } } - public NodesWhitelistResult addNodes(final List enodeURLs) { - final NodesWhitelistResult inputValidationResult = validInput(enodeURLs); + public NodesAllowlistResult addNodes(final List enodeURLs) { + final NodesAllowlistResult inputValidationResult = validInput(enodeURLs); if (inputValidationResult.result() != AllowlistOperationResult.SUCCESS) { return inputValidationResult; } @@ -115,31 +115,31 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning enodeURLs.stream().map(EnodeURL::fromString).collect(Collectors.toList()); for (EnodeURL peer : peers) { - if (nodesWhitelist.contains(peer)) { - return new NodesWhitelistResult( + if (nodesAllowlist.contains(peer)) { + return new NodesAllowlistResult( AllowlistOperationResult.ERROR_EXISTING_ENTRY, - String.format("Specified peer: %s already exists in whitelist.", peer.getNodeId())); + String.format("Specified peer: %s already exists in allowlist.", peer.getNodeId())); } } - final List oldWhitelist = new ArrayList<>(this.nodesWhitelist); + final List oldAllowlist = new ArrayList<>(this.nodesAllowlist); peers.forEach(this::addNode); - notifyListUpdatedSubscribers(new NodeWhitelistUpdatedEvent(peers, Collections.emptyList())); + notifyListUpdatedSubscribers(new NodeAllowlistUpdatedEvent(peers, Collections.emptyList())); - final NodesWhitelistResult updateConfigFileResult = updateWhitelistInConfigFile(oldWhitelist); + final NodesAllowlistResult updateConfigFileResult = updateAllowlistInConfigFile(oldAllowlist); if (updateConfigFileResult.result() != AllowlistOperationResult.SUCCESS) { return updateConfigFileResult; } - return new NodesWhitelistResult(AllowlistOperationResult.SUCCESS); + return new NodesAllowlistResult(AllowlistOperationResult.SUCCESS); } public boolean addNode(final EnodeURL enodeURL) { - return nodesWhitelist.add(enodeURL); + return nodesAllowlist.add(enodeURL); } - public NodesWhitelistResult removeNodes(final List enodeURLs) { - final NodesWhitelistResult inputValidationResult = validInput(enodeURLs); + public NodesAllowlistResult removeNodes(final List enodeURLs) { + final NodesAllowlistResult inputValidationResult = validInput(enodeURLs); if (inputValidationResult.result() != AllowlistOperationResult.SUCCESS) { return inputValidationResult; } @@ -148,61 +148,61 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning boolean anyBootnode = peers.stream().anyMatch(fixedNodes::contains); if (anyBootnode) { - return new NodesWhitelistResult(AllowlistOperationResult.ERROR_FIXED_NODE_CANNOT_BE_REMOVED); + return new NodesAllowlistResult(AllowlistOperationResult.ERROR_FIXED_NODE_CANNOT_BE_REMOVED); } for (EnodeURL peer : peers) { - if (!(nodesWhitelist.contains(peer))) { - return new NodesWhitelistResult( + if (!(nodesAllowlist.contains(peer))) { + return new NodesAllowlistResult( AllowlistOperationResult.ERROR_ABSENT_ENTRY, - String.format("Specified peer: %s does not exist in whitelist.", peer.getNodeId())); + String.format("Specified peer: %s does not exist in allowlist.", peer.getNodeId())); } } - final List oldWhitelist = new ArrayList<>(this.nodesWhitelist); + final List oldAllowlist = new ArrayList<>(this.nodesAllowlist); peers.forEach(this::removeNode); - notifyListUpdatedSubscribers(new NodeWhitelistUpdatedEvent(Collections.emptyList(), peers)); + notifyListUpdatedSubscribers(new NodeAllowlistUpdatedEvent(Collections.emptyList(), peers)); - final NodesWhitelistResult updateConfigFileResult = updateWhitelistInConfigFile(oldWhitelist); + final NodesAllowlistResult updateConfigFileResult = updateAllowlistInConfigFile(oldAllowlist); if (updateConfigFileResult.result() != AllowlistOperationResult.SUCCESS) { return updateConfigFileResult; } - return new NodesWhitelistResult(AllowlistOperationResult.SUCCESS); + return new NodesAllowlistResult(AllowlistOperationResult.SUCCESS); } private boolean removeNode(final EnodeURL enodeURL) { - return nodesWhitelist.remove(enodeURL); + return nodesAllowlist.remove(enodeURL); } - private NodesWhitelistResult updateWhitelistInConfigFile(final List oldWhitelist) { + private NodesAllowlistResult updateAllowlistInConfigFile(final List oldAllowlist) { try { - verifyConfigurationFileState(peerToEnodeURI(oldWhitelist)); - updateConfigurationFile(peerToEnodeURI(nodesWhitelist)); - verifyConfigurationFileState(peerToEnodeURI(nodesWhitelist)); + verifyConfigurationFileState(peerToEnodeURI(oldAllowlist)); + updateConfigurationFile(peerToEnodeURI(nodesAllowlist)); + verifyConfigurationFileState(peerToEnodeURI(nodesAllowlist)); } catch (IOException e) { - revertState(oldWhitelist); - return new NodesWhitelistResult(AllowlistOperationResult.ERROR_ALLOWLIST_PERSIST_FAIL); + revertState(oldAllowlist); + return new NodesAllowlistResult(AllowlistOperationResult.ERROR_ALLOWLIST_PERSIST_FAIL); } catch (AllowlistFileSyncException e) { - return new NodesWhitelistResult(AllowlistOperationResult.ERROR_ALLOWLIST_FILE_SYNC); + return new NodesAllowlistResult(AllowlistOperationResult.ERROR_ALLOWLIST_FILE_SYNC); } - return new NodesWhitelistResult(AllowlistOperationResult.SUCCESS); + return new NodesAllowlistResult(AllowlistOperationResult.SUCCESS); } - private NodesWhitelistResult validInput(final List peers) { + private NodesAllowlistResult validInput(final List peers) { if (peers == null || peers.isEmpty()) { - return new NodesWhitelistResult( + return new NodesAllowlistResult( AllowlistOperationResult.ERROR_EMPTY_ENTRY, String.format("Null/empty peers list")); } if (peerListHasDuplicates(peers)) { - return new NodesWhitelistResult( + return new NodesAllowlistResult( AllowlistOperationResult.ERROR_DUPLICATED_ENTRY, String.format("Specified peer list contains duplicates")); } - return new NodesWhitelistResult(AllowlistOperationResult.SUCCESS); + return new NodesAllowlistResult(AllowlistOperationResult.SUCCESS); } private boolean peerListHasDuplicates(final List peers) { @@ -218,9 +218,9 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning allowlistPersistor.updateConfig(ALLOWLIST_TYPE.NODES, nodes); } - private void revertState(final List nodesWhitelist) { - this.nodesWhitelist.clear(); - this.nodesWhitelist.addAll(nodesWhitelist); + private void revertState(final List nodesAllowlist) { + this.nodesAllowlist.clear(); + this.nodesAllowlist.addAll(nodesAllowlist); } private Collection peerToEnodeURI(final Collection peers) { @@ -235,16 +235,16 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning if (Objects.equals(localNodeId, node.getNodeId())) { return true; } - return nodesWhitelist.stream().anyMatch(p -> EnodeURL.sameListeningEndpoint(p, node)); + return nodesAllowlist.stream().anyMatch(p -> EnodeURL.sameListeningEndpoint(p, node)); } - public List getNodesWhitelist() { - return nodesWhitelist.stream().map(Object::toString).collect(Collectors.toList()); + public List getNodesAllowlist() { + return nodesAllowlist.stream().map(Object::toString).collect(Collectors.toList()); } public synchronized void reload() throws RuntimeException { - final List currentAccountsList = new ArrayList<>(nodesWhitelist); - nodesWhitelist.clear(); + final List currentAccountsList = new ArrayList<>(nodesAllowlist); + nodesAllowlist.clear(); try { final LocalPermissioningConfiguration updatedConfig = @@ -257,59 +257,59 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning readNodesFromConfig(updatedConfig); configuration = updatedConfig; - createNodeWhitelistModifiedEventAfterReload(currentAccountsList, nodesWhitelist); + createNodeAllowlistModifiedEventAfterReload(currentAccountsList, nodesAllowlist); } catch (Exception e) { LOG.warn( - "Error reloading permissions file. In-memory whitelisted nodes will be reverted to previous valid configuration. " + "Error reloading permissions file. In-memory nodes allowlist will be reverted to previous valid configuration. " + "Details: {}", e.getMessage()); - nodesWhitelist.clear(); - nodesWhitelist.addAll(currentAccountsList); + nodesAllowlist.clear(); + nodesAllowlist.addAll(currentAccountsList); throw new RuntimeException(e); } } - private void createNodeWhitelistModifiedEventAfterReload( - final List previousNodeWhitelist, final List currentNodesList) { + private void createNodeAllowlistModifiedEventAfterReload( + final List previousNodeAllowlist, final List currentNodesList) { final List removedNodes = - previousNodeWhitelist.stream() + previousNodeAllowlist.stream() .filter(n -> !currentNodesList.contains(n)) .collect(Collectors.toList()); final List addedNodes = currentNodesList.stream() - .filter(n -> !previousNodeWhitelist.contains(n)) + .filter(n -> !previousNodeAllowlist.contains(n)) .collect(Collectors.toList()); if (!removedNodes.isEmpty() || !addedNodes.isEmpty()) { - notifyListUpdatedSubscribers(new NodeWhitelistUpdatedEvent(addedNodes, removedNodes)); + notifyListUpdatedSubscribers(new NodeAllowlistUpdatedEvent(addedNodes, removedNodes)); } } - public long subscribeToListUpdatedEvent(final Consumer subscriber) { - return nodeWhitelistUpdatedObservers.subscribe(subscriber); + public long subscribeToListUpdatedEvent(final Consumer subscriber) { + return nodeAllowlistUpdatedObservers.subscribe(subscriber); } - private void notifyListUpdatedSubscribers(final NodeWhitelistUpdatedEvent event) { + private void notifyListUpdatedSubscribers(final NodeAllowlistUpdatedEvent event) { LOG.trace( - "Sending NodeWhitelistUpdatedEvent (added: {}, removed {})", + "Sending NodeAllowlistUpdatedEvent (added: {}, removed {})", event.getAddedNodes().size(), event.getRemovedNodes().size()); - nodeWhitelistUpdatedObservers.forEach(c -> c.accept(event)); + nodeAllowlistUpdatedObservers.forEach(c -> c.accept(event)); } - public static class NodesWhitelistResult { + public static class NodesAllowlistResult { private final AllowlistOperationResult result; private final Optional message; - NodesWhitelistResult(final AllowlistOperationResult result, final String message) { + NodesAllowlistResult(final AllowlistOperationResult result, final String message) { this.result = result; this.message = Optional.of(message); } @VisibleForTesting - public NodesWhitelistResult(final AllowlistOperationResult result) { + public NodesAllowlistResult(final AllowlistOperationResult result) { this.result = result; this.message = Optional.empty(); } diff --git a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/PermissioningConfigurationBuilder.java b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/PermissioningConfigurationBuilder.java index 79138f648e..c62a82fcd4 100644 --- a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/PermissioningConfigurationBuilder.java +++ b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/PermissioningConfigurationBuilder.java @@ -67,21 +67,21 @@ public class PermissioningConfigurationBuilder { if (localConfigNodePermissioningEnabled) { final TomlParseResult nodePermissioningToml = readToml(nodePermissioningConfigFilepath); - final TomlArray nodeWhitelistTomlArray = + final TomlArray nodeAllowlistTomlArray = getAllowlistArray(nodePermissioningToml, NODES_ALLOWLIST_KEY, NODES_WHITELIST_KEY); permissioningConfiguration.setNodePermissioningConfigFilePath( nodePermissioningConfigFilepath); - if (nodeWhitelistTomlArray != null) { - List nodesWhitelistToml = - nodeWhitelistTomlArray + if (nodeAllowlistTomlArray != null) { + List nodesAllowlistToml = + nodeAllowlistTomlArray .toList() .parallelStream() .map(Object::toString) .map(EnodeURL::asURI) .collect(Collectors.toList()); - permissioningConfiguration.setNodeAllowlist(nodesWhitelistToml); + permissioningConfiguration.setNodeAllowlist(nodesAllowlistToml); } else { throw new Exception( NODES_ALLOWLIST_KEY @@ -100,22 +100,22 @@ public class PermissioningConfigurationBuilder { if (localConfigAccountPermissioningEnabled) { final TomlParseResult accountPermissioningToml = readToml(accountPermissioningConfigFilepath); - final TomlArray accountWhitelistTomlArray = + final TomlArray accountAllowlistTomlArray = getAllowlistArray( accountPermissioningToml, ACCOUNTS_ALLOWLIST_KEY, ACCOUNTS_WHITELIST_KEY); permissioningConfiguration.setAccountPermissioningConfigFilePath( accountPermissioningConfigFilepath); - if (accountWhitelistTomlArray != null) { - List accountsWhitelistToml = - accountWhitelistTomlArray + if (accountAllowlistTomlArray != null) { + List accountsAllowlistToml = + accountAllowlistTomlArray .toList() .parallelStream() .map(Object::toString) .collect(Collectors.toList()); - accountsWhitelistToml.stream() + accountsAllowlistToml.stream() .filter(s -> !AccountLocalConfigPermissioningController.isValidAccountString(s)) .findFirst() .ifPresent( @@ -123,7 +123,7 @@ public class PermissioningConfigurationBuilder { throw new IllegalArgumentException("Invalid account " + s); }); - permissioningConfiguration.setAccountAllowlist(accountsWhitelistToml); + permissioningConfiguration.setAccountAllowlist(accountsAllowlistToml); } else { throw new Exception( ACCOUNTS_ALLOWLIST_KEY diff --git a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/node/NodeWhitelistUpdatedEvent.java b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/node/NodeAllowlistUpdatedEvent.java similarity index 92% rename from ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/node/NodeWhitelistUpdatedEvent.java rename to ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/node/NodeAllowlistUpdatedEvent.java index a3ac4c2fe2..b5847469c3 100644 --- a/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/node/NodeWhitelistUpdatedEvent.java +++ b/ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/node/NodeAllowlistUpdatedEvent.java @@ -20,12 +20,12 @@ import java.util.Collections; import java.util.List; import java.util.Objects; -public class NodeWhitelistUpdatedEvent { +public class NodeAllowlistUpdatedEvent { private final List addedNodes; private final List removedNodes; - public NodeWhitelistUpdatedEvent( + public NodeAllowlistUpdatedEvent( final List addedNodes, final List removedNodes) { this.addedNodes = addedNodes != null ? addedNodes : Collections.emptyList(); this.removedNodes = removedNodes != null ? removedNodes : Collections.emptyList(); @@ -47,7 +47,7 @@ public class NodeWhitelistUpdatedEvent { if (o == null || getClass() != o.getClass()) { return false; } - NodeWhitelistUpdatedEvent that = (NodeWhitelistUpdatedEvent) o; + NodeAllowlistUpdatedEvent that = (NodeAllowlistUpdatedEvent) o; return Objects.equals(addedNodes, that.addedNodes) && Objects.equals(removedNodes, that.removedNodes); } diff --git a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/AllowlistPersistorTest.java b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/AllowlistPersistorTest.java index b1c19358e6..27b2f92032 100644 --- a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/AllowlistPersistorTest.java +++ b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/AllowlistPersistorTest.java @@ -36,14 +36,14 @@ public class AllowlistPersistorTest { private AllowlistPersistor allowlistPersistor; private File tempFile; - private final String accountsWhitelist = + private final String accountsAllowlist = String.format("%s=[%s]", ALLOWLIST_TYPE.ACCOUNTS.getTomlKey(), "\"account1\",\"account2\""); - private final String nodesWhitelist = + private final String nodesAllowlist = String.format("%s=[%s]", ALLOWLIST_TYPE.NODES.getTomlKey(), "\"node1\",\"node2\""); @Before public void setUp() throws IOException { - List lines = Lists.newArrayList(nodesWhitelist, accountsWhitelist); + List lines = Lists.newArrayList(nodesAllowlist, accountsAllowlist); tempFile = File.createTempFile("test", "test"); tempFile.deleteOnExit(); Files.write(tempFile.toPath(), lines, StandardOpenOption.WRITE, StandardOpenOption.CREATE); @@ -66,7 +66,7 @@ public class AllowlistPersistorTest { @Test public void lineShouldBeAdded() throws IOException { final ALLOWLIST_TYPE key = ALLOWLIST_TYPE.NODES; - final Set updatedWhitelist = Collections.singleton("node5"); + final Set updatedAllowlist = Collections.singleton("node5"); assertThat(countLines()).isEqualTo(2); assertThat(hasKey(key)).isTrue(); @@ -76,7 +76,7 @@ public class AllowlistPersistorTest { assertThat(countLines()).isEqualTo(1); assertThat(hasKey(key)).isFalse(); - allowlistPersistor.addNewConfigItem(key, updatedWhitelist); + allowlistPersistor.addNewConfigItem(key, updatedAllowlist); assertThat(countLines()).isEqualTo(2); assertThat(hasKey(key)).isTrue(); @@ -88,13 +88,13 @@ public class AllowlistPersistorTest { String newValue = "node5"; assertThat(countLines()).isEqualTo(2); - assertThat(hasKeyAndExactLineContent(key, nodesWhitelist)).isTrue(); + assertThat(hasKeyAndExactLineContent(key, nodesAllowlist)).isTrue(); allowlistPersistor.updateConfig(key, Collections.singleton(newValue)); assertThat(countLines()).isEqualTo(2); assertThat(hasKeyAndContainsValue(key, newValue)).isTrue(); - assertThat(hasKeyAndExactLineContent(key, nodesWhitelist)).isFalse(); + assertThat(hasKeyAndExactLineContent(key, nodesAllowlist)).isFalse(); } @Test diff --git a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/LocalPermissioningConfigurationBuilderTest.java b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/LocalPermissioningConfigurationBuilderTest.java index 37ae527328..a9d9992816 100644 --- a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/LocalPermissioningConfigurationBuilderTest.java +++ b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/LocalPermissioningConfigurationBuilderTest.java @@ -31,8 +31,11 @@ import org.junit.Test; public class LocalPermissioningConfigurationBuilderTest { private static final String PERMISSIONING_CONFIG_VALID = "/permissioning_config.toml"; + + @Deprecated private static final String PERMISSIONING_CONFIG_VALID_WHITELISTS = "/permissioning_config_whitelists.toml"; + private static final String PERMISSIONING_CONFIG_ACCOUNT_ALLOWLIST_ONLY = "/permissioning_config_account_allowlist_only.toml"; private static final String PERMISSIONING_CONFIG_NODE_ALLOWLIST_ONLY = @@ -90,7 +93,7 @@ public class LocalPermissioningConfigurationBuilderTest { } @Test - public void permissioningConfigWithOnlyNodeWhitelistSet() throws Exception { + public void permissioningConfigWithOnlyNodeAllowlistSet() throws Exception { final String uri = "enode://" + VALID_NODE_ID + "@192.168.0.9:4567"; final URL configFile = this.getClass().getResource(PERMISSIONING_CONFIG_NODE_ALLOWLIST_ONLY); @@ -106,7 +109,7 @@ public class LocalPermissioningConfigurationBuilderTest { } @Test - public void permissioningConfigWithOnlyAccountWhitelistSet() throws Exception { + public void permissioningConfigWithOnlyAccountAllowlistSet() throws Exception { final URL configFile = this.getClass().getResource(PERMISSIONING_CONFIG_ACCOUNT_ALLOWLIST_ONLY); final Path toml = createTempFile("toml", Resources.toByteArray(configFile)); @@ -145,7 +148,7 @@ public class LocalPermissioningConfigurationBuilderTest { } @Test - public void permissioningConfigWithEmptyWhitelistMustNotError() throws Exception { + public void permissioningConfigWithEmptyAllowlistMustNotError() throws Exception { final URL configFile = this.getClass().getResource(PERMISSIONING_CONFIG_EMPTY_ALLOWLISTS); final Path toml = createTempFile("toml", Resources.toByteArray(configFile)); @@ -158,7 +161,7 @@ public class LocalPermissioningConfigurationBuilderTest { } @Test - public void permissioningConfigWithAbsentWhitelistMustThrowException() throws Exception { + public void permissioningConfigWithAbsentAllowlistMustThrowException() throws Exception { final URL configFile = this.getClass().getResource(PERMISSIONING_CONFIG_ABSENT_ALLOWLISTS); final Path toml = createTempFile("toml", Resources.toByteArray(configFile)); diff --git a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/LocalPermissioningConfigurationTest.java b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/LocalPermissioningConfigurationTest.java index 80112e0244..5e63e31a07 100644 --- a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/LocalPermissioningConfigurationTest.java +++ b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/LocalPermissioningConfigurationTest.java @@ -40,7 +40,7 @@ public class LocalPermissioningConfigurationTest { } @Test - public void setNodeWhitelist() { + public void setNodeAllowlist() { final LocalPermissioningConfiguration configuration = LocalPermissioningConfiguration.createDefault(); configuration.setNodeAllowlist(Arrays.asList(nodes)); @@ -49,7 +49,7 @@ public class LocalPermissioningConfigurationTest { } @Test - public void setNodeWhiteListPassingNull() { + public void setNodeAllowListPassingNull() { final LocalPermissioningConfiguration configuration = LocalPermissioningConfiguration.createDefault(); configuration.setNodeAllowlist(null); @@ -58,7 +58,7 @@ public class LocalPermissioningConfigurationTest { } @Test - public void setAccountWhitelist() { + public void setAccountAllowlist() { final String[] accounts = {"1111111111111111", "2222222222222222", "ffffffffffffffff"}; final LocalPermissioningConfiguration configuration = LocalPermissioningConfiguration.createDefault(); @@ -68,7 +68,7 @@ public class LocalPermissioningConfigurationTest { } @Test - public void setAccountWhiteListPassingNull() { + public void setAccountAllowListPassingNull() { final LocalPermissioningConfiguration configuration = LocalPermissioningConfiguration.createDefault(); configuration.setAccountAllowlist(null); diff --git a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeLocalConfigPermissioningControllerTest.java b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeLocalConfigPermissioningControllerTest.java index e3d3aab9b6..c667cd6d09 100644 --- a/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeLocalConfigPermissioningControllerTest.java +++ b/ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeLocalConfigPermissioningControllerTest.java @@ -28,7 +28,8 @@ import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; import org.hyperledger.besu.ethereum.p2p.peers.EnodeURL; -import org.hyperledger.besu.ethereum.permissioning.node.NodeWhitelistUpdatedEvent; +import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult; +import org.hyperledger.besu.ethereum.permissioning.node.NodeAllowlistUpdatedEvent; import org.hyperledger.besu.metrics.BesuMetricCategory; import org.hyperledger.besu.plugin.services.MetricsSystem; import org.hyperledger.besu.plugin.services.metrics.Counter; @@ -103,103 +104,84 @@ public class NodeLocalConfigPermissioningControllerTest { @Test public void whenAddNodesWithValidInputShouldReturnSuccess() { - NodeLocalConfigPermissioningController.NodesWhitelistResult expected = - new NodeLocalConfigPermissioningController.NodesWhitelistResult( - AllowlistOperationResult.SUCCESS); - NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult = - controller.addNodes(Lists.newArrayList(enode1)); + NodesAllowlistResult expected = new NodesAllowlistResult(AllowlistOperationResult.SUCCESS); + NodesAllowlistResult actualResult = controller.addNodes(Lists.newArrayList(enode1)); assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result"); - assertThat(controller.getNodesWhitelist()).containsExactly(enode1); + assertThat(controller.getNodesAllowlist()).containsExactly(enode1); } @Test public void whenAddNodesInputHasExistingNodeShouldReturnAddErrorExistingEntry() { controller.addNodes(Arrays.asList(enode1)); - NodeLocalConfigPermissioningController.NodesWhitelistResult expected = - new NodeLocalConfigPermissioningController.NodesWhitelistResult( - AllowlistOperationResult.ERROR_EXISTING_ENTRY); - NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult = - controller.addNodes(Lists.newArrayList(enode1, enode2)); + NodesAllowlistResult expected = + new NodesAllowlistResult(AllowlistOperationResult.ERROR_EXISTING_ENTRY); + NodesAllowlistResult actualResult = controller.addNodes(Lists.newArrayList(enode1, enode2)); assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result"); } @Test public void whenAddNodesInputHasDuplicatedNodesShouldReturnDuplicatedEntryError() { - NodeLocalConfigPermissioningController.NodesWhitelistResult expected = - new NodeLocalConfigPermissioningController.NodesWhitelistResult( - AllowlistOperationResult.ERROR_DUPLICATED_ENTRY); + NodesAllowlistResult expected = + new NodesAllowlistResult(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY); - NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult = - controller.addNodes(Arrays.asList(enode1, enode1)); + NodesAllowlistResult actualResult = controller.addNodes(Arrays.asList(enode1, enode1)); assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result"); } @Test public void whenAddNodesInputHasEmptyListOfNodesShouldReturnErrorEmptyEntry() { - NodeLocalConfigPermissioningController.NodesWhitelistResult expected = - new NodeLocalConfigPermissioningController.NodesWhitelistResult( - AllowlistOperationResult.ERROR_EMPTY_ENTRY); - NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult = - controller.removeNodes(new ArrayList<>()); + NodesAllowlistResult expected = + new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY); + NodesAllowlistResult actualResult = controller.removeNodes(new ArrayList<>()); assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result"); } @Test public void whenAddNodesInputHasNullListOfNodesShouldReturnErrorEmptyEntry() { - NodeLocalConfigPermissioningController.NodesWhitelistResult expected = - new NodeLocalConfigPermissioningController.NodesWhitelistResult( - AllowlistOperationResult.ERROR_EMPTY_ENTRY); - NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult = - controller.removeNodes(null); + NodesAllowlistResult expected = + new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY); + NodesAllowlistResult actualResult = controller.removeNodes(null); assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result"); } @Test public void whenRemoveNodesInputHasAbsentNodeShouldReturnRemoveErrorAbsentEntry() { - NodeLocalConfigPermissioningController.NodesWhitelistResult expected = - new NodeLocalConfigPermissioningController.NodesWhitelistResult( - AllowlistOperationResult.ERROR_ABSENT_ENTRY); - NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult = - controller.removeNodes(Lists.newArrayList(enode1, enode2)); + NodesAllowlistResult expected = + new NodesAllowlistResult(AllowlistOperationResult.ERROR_ABSENT_ENTRY); + NodesAllowlistResult actualResult = controller.removeNodes(Lists.newArrayList(enode1, enode2)); assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result"); } @Test public void whenRemoveNodesInputHasDuplicateNodesShouldReturnErrorDuplicatedEntry() { - NodeLocalConfigPermissioningController.NodesWhitelistResult expected = - new NodeLocalConfigPermissioningController.NodesWhitelistResult( - AllowlistOperationResult.ERROR_DUPLICATED_ENTRY); - NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult = - controller.removeNodes(Lists.newArrayList(enode1, enode1)); + NodesAllowlistResult expected = + new NodesAllowlistResult(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY); + NodesAllowlistResult actualResult = controller.removeNodes(Lists.newArrayList(enode1, enode1)); assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result"); } @Test public void whenRemoveNodesInputHasEmptyListOfNodesShouldReturnErrorEmptyEntry() { - NodeLocalConfigPermissioningController.NodesWhitelistResult expected = - new NodeLocalConfigPermissioningController.NodesWhitelistResult( - AllowlistOperationResult.ERROR_EMPTY_ENTRY); - NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult = - controller.removeNodes(new ArrayList<>()); + NodesAllowlistResult expected = + new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY); + NodesAllowlistResult actualResult = controller.removeNodes(new ArrayList<>()); assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result"); } @Test public void whenRemoveNodesInputHasNullListOfNodesShouldReturnErrorEmptyEntry() { - NodeLocalConfigPermissioningController.NodesWhitelistResult expected = - new NodeLocalConfigPermissioningController.NodesWhitelistResult( - AllowlistOperationResult.ERROR_EMPTY_ENTRY); - NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult = - controller.removeNodes(null); + NodesAllowlistResult expected = + new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY); + NodesAllowlistResult actualResult = controller.removeNodes(null); assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result"); } @@ -287,7 +269,7 @@ public class NodeLocalConfigPermissioningControllerTest { @Test public void - whenCheckingIfNodeIsPermittedDiscoveryPortShouldNotBeConsidered_whitelistedNodeHasDiscDisabled() { + whenCheckingIfNodeIsPermittedDiscoveryPortShouldNotBeConsidered_allowedNodeHasDiscDisabled() { String peerWithDiscoveryPortSet = "enode://aaaa80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@127.0.0.1:30303?discport=0"; String peerWithoutDiscoveryPortSet = @@ -330,16 +312,16 @@ public class NodeLocalConfigPermissioningControllerTest { List newNode1 = singletonList(EnodeURL.fromString(enode1).toString()); List newNode2 = singletonList(EnodeURL.fromString(enode2).toString()); - assertThat(controller.getNodesWhitelist().size()).isEqualTo(0); + assertThat(controller.getNodesAllowlist().size()).isEqualTo(0); controller.addNodes(newNode1); - assertThat(controller.getNodesWhitelist().size()).isEqualTo(1); + assertThat(controller.getNodesAllowlist().size()).isEqualTo(1); doThrow(new IOException()).when(allowlistPersistor).updateConfig(any(), any()); controller.addNodes(newNode2); - assertThat(controller.getNodesWhitelist().size()).isEqualTo(1); - assertThat(controller.getNodesWhitelist()).isEqualTo(newNode1); + assertThat(controller.getNodesAllowlist().size()).isEqualTo(1); + assertThat(controller.getNodesAllowlist()).isEqualTo(newNode1); verify(allowlistPersistor, times(3)).verifyConfigFileMatchesState(any(), any()); verify(allowlistPersistor, times(2)).updateConfig(any(), any()); @@ -365,7 +347,7 @@ public class NodeLocalConfigPermissioningControllerTest { controller.reload(); - assertThat(controller.getNodesWhitelist()).containsExactly(expectedEnodeURL); + assertThat(controller.getNodesAllowlist()).containsExactly(expectedEnodeURL); } @Test @@ -389,15 +371,15 @@ public class NodeLocalConfigPermissioningControllerTest { .isInstanceOf(RuntimeException.class) .hasMessageContaining("Unable to read permissioning TOML config file"); - assertThat(controller.getNodesWhitelist()).containsExactly(expectedEnodeURI); + assertThat(controller.getNodesAllowlist()).containsExactly(expectedEnodeURI); } @Test @SuppressWarnings("unchecked") - public void whenAddingNodeShouldNotifyWhitelistModifiedSubscribers() { - final Consumer consumer = mock(Consumer.class); - final NodeWhitelistUpdatedEvent expectedEvent = - new NodeWhitelistUpdatedEvent( + public void whenAddingNodeShouldNotifyAllowlistModifiedSubscribers() { + final Consumer consumer = mock(Consumer.class); + final NodeAllowlistUpdatedEvent expectedEvent = + new NodeAllowlistUpdatedEvent( Lists.newArrayList(EnodeURL.fromString(enode1)), Collections.emptyList()); controller.subscribeToListUpdatedEvent(consumer); @@ -411,7 +393,7 @@ public class NodeLocalConfigPermissioningControllerTest { public void whenAddingNodeDoesNotAddShouldNotNotifyAllowlistModifiedSubscribers() { // adding node before subscribing to allowlist modified events controller.addNodes(Lists.newArrayList(enode1)); - final Consumer consumer = mock(Consumer.class); + final Consumer consumer = mock(Consumer.class); controller.subscribeToListUpdatedEvent(consumer); // won't add duplicate node @@ -426,9 +408,9 @@ public class NodeLocalConfigPermissioningControllerTest { // adding node before subscribing to allowlist modified events controller.addNodes(Lists.newArrayList(enode1)); - final Consumer consumer = mock(Consumer.class); - final NodeWhitelistUpdatedEvent expectedEvent = - new NodeWhitelistUpdatedEvent( + final Consumer consumer = mock(Consumer.class); + final NodeAllowlistUpdatedEvent expectedEvent = + new NodeAllowlistUpdatedEvent( Collections.emptyList(), Lists.newArrayList(EnodeURL.fromString(enode1))); controller.subscribeToListUpdatedEvent(consumer); @@ -440,7 +422,7 @@ public class NodeLocalConfigPermissioningControllerTest { @Test @SuppressWarnings("unchecked") public void whenRemovingNodeDoesNotRemoveShouldNotifyAllowlistModifiedSubscribers() { - final Consumer consumer = mock(Consumer.class); + final Consumer consumer = mock(Consumer.class); controller.subscribeToListUpdatedEvent(consumer); // won't remove absent node @@ -451,17 +433,15 @@ public class NodeLocalConfigPermissioningControllerTest { @Test public void whenRemovingBootnodeShouldReturnRemoveBootnodeError() { - NodeLocalConfigPermissioningController.NodesWhitelistResult expected = - new NodeLocalConfigPermissioningController.NodesWhitelistResult( - AllowlistOperationResult.ERROR_FIXED_NODE_CANNOT_BE_REMOVED); + NodesAllowlistResult expected = + new NodesAllowlistResult(AllowlistOperationResult.ERROR_FIXED_NODE_CANNOT_BE_REMOVED); bootnodesList.add(EnodeURL.fromString(enode1)); controller.addNodes(Lists.newArrayList(enode1, enode2)); - NodeLocalConfigPermissioningController.NodesWhitelistResult actualResult = - controller.removeNodes(Lists.newArrayList(enode1)); + NodesAllowlistResult actualResult = controller.removeNodes(Lists.newArrayList(enode1)); assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result"); - assertThat(controller.getNodesWhitelist()).containsExactly(enode1, enode2); + assertThat(controller.getNodesAllowlist()).containsExactly(enode1, enode2); } @Test @@ -470,9 +450,9 @@ public class NodeLocalConfigPermissioningControllerTest { final Path permissionsFile = createPermissionsFileWithNode(enode2); final LocalPermissioningConfiguration permissioningConfig = mock(LocalPermissioningConfiguration.class); - final Consumer consumer = mock(Consumer.class); - final NodeWhitelistUpdatedEvent expectedEvent = - new NodeWhitelistUpdatedEvent( + final Consumer consumer = mock(Consumer.class); + final NodeAllowlistUpdatedEvent expectedEvent = + new NodeAllowlistUpdatedEvent( Lists.newArrayList(EnodeURL.fromString(enode2)), Lists.newArrayList(EnodeURL.fromString(enode1))); @@ -497,7 +477,7 @@ public class NodeLocalConfigPermissioningControllerTest { final Path permissionsFile = createPermissionsFileWithNode(enode1); final LocalPermissioningConfiguration permissioningConfig = mock(LocalPermissioningConfiguration.class); - final Consumer consumer = mock(Consumer.class); + final Consumer consumer = mock(Consumer.class); when(permissioningConfig.getNodePermissioningConfigFilePath()) .thenReturn(permissionsFile.toAbsolutePath().toString()); diff --git a/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/MetricsConfiguration.java b/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/MetricsConfiguration.java index db96565e1d..3cab361797 100644 --- a/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/MetricsConfiguration.java +++ b/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/MetricsConfiguration.java @@ -45,7 +45,7 @@ public class MetricsConfiguration { private final String pushHost; private final int pushInterval; private final String prometheusJob; - private final List hostsWhitelist; + private final List hostsAllowlist; private final boolean timersEnabled; public static Builder builder() { @@ -62,7 +62,7 @@ public class MetricsConfiguration { final String pushHost, final int pushInterval, final String prometheusJob, - final List hostsWhitelist, + final List hostsAllowlist, final boolean timersEnabled) { this.enabled = enabled; this.port = port; @@ -73,7 +73,7 @@ public class MetricsConfiguration { this.pushHost = pushHost; this.pushInterval = pushInterval; this.prometheusJob = prometheusJob; - this.hostsWhitelist = hostsWhitelist; + this.hostsAllowlist = hostsAllowlist; this.timersEnabled = timersEnabled; } @@ -122,7 +122,7 @@ public class MetricsConfiguration { } Collection getHostsAllowlist() { - return Collections.unmodifiableCollection(this.hostsWhitelist); + return Collections.unmodifiableCollection(this.hostsAllowlist); } public boolean isTimersEnabled() { @@ -141,7 +141,7 @@ public class MetricsConfiguration { .add("pushHost", pushHost) .add("pushInterval", pushInterval) .add("prometheusJob", prometheusJob) - .add("hostsWhitelist", hostsWhitelist) + .add("hostsAllowlist", hostsAllowlist) .toString(); } @@ -163,7 +163,7 @@ public class MetricsConfiguration { && Objects.equals(metricCategories, that.metricCategories) && Objects.equals(pushHost, that.pushHost) && Objects.equals(prometheusJob, that.prometheusJob) - && Objects.equals(hostsWhitelist, that.hostsWhitelist); + && Objects.equals(hostsAllowlist, that.hostsAllowlist); } @Override @@ -178,7 +178,7 @@ public class MetricsConfiguration { pushHost, pushInterval, prometheusJob, - hostsWhitelist); + hostsAllowlist); } public static class Builder { @@ -191,7 +191,7 @@ public class MetricsConfiguration { private String pushHost = DEFAULT_METRICS_PUSH_HOST; private int pushInterval = 15; private String prometheusJob = "besu-client"; - private List hostsWhitelist = Arrays.asList("localhost", "127.0.0.1"); + private List hostsAllowlist = Arrays.asList("localhost", "127.0.0.1"); private boolean timersEnabled = DEFAULT_TIMERS_ENABLED; private Builder() {} @@ -241,8 +241,8 @@ public class MetricsConfiguration { return this; } - public Builder hostsAllowlist(final List hostsWhitelist) { - this.hostsWhitelist = hostsWhitelist; + public Builder hostsAllowlist(final List hostsAllowlist) { + this.hostsAllowlist = hostsAllowlist; return this; } @@ -262,7 +262,7 @@ public class MetricsConfiguration { pushHost, pushInterval, prometheusJob, - hostsWhitelist, + hostsAllowlist, timersEnabled); } }