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 <sally.macfarlane@consensys.net>
pull/1137/head
Sally MacFarlane 4 years ago committed by GitHub
parent 785b26b1fa
commit 9e224ed7f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeLocalAndOnChainPermissioningAcceptanceTest.java
  2. 10
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/permissioning/NodeSmartContractPermissioningAcceptanceTestBase.java
  3. 8
      besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
  4. 69
      besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
  5. 18
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLConfiguration.java
  6. 12
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLHttpService.java
  7. 12
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcConfiguration.java
  8. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddNodesToAllowlist.java
  9. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermGetNodesAllowlist.java
  10. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveNodesFromAllowlist.java
  11. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java
  12. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketService.java
  13. 12
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddNodesToAllowlistTest.java
  14. 12
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermAddNodesToWhitelistTest.java
  15. 8
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermGetNodesAllowlistTest.java
  16. 8
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermGetNodesWhitelistTest.java
  17. 14
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveNodesFromAllowlistTest.java
  18. 14
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/permissioning/PermRemoveNodesFromWhitelistTest.java
  19. 26
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketHostAllowlistTest.java
  20. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidator.java
  21. 2
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolTest.java
  22. 2
      ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/AccountLocalConfigPermissioningController.java
  23. 122
      ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/NodeLocalConfigPermissioningController.java
  24. 22
      ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/PermissioningConfigurationBuilder.java
  25. 6
      ethereum/permissioning/src/main/java/org/hyperledger/besu/ethereum/permissioning/node/NodeAllowlistUpdatedEvent.java
  26. 14
      ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/AllowlistPersistorTest.java
  27. 11
      ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/LocalPermissioningConfigurationBuilderTest.java
  28. 8
      ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/LocalPermissioningConfigurationTest.java
  29. 126
      ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeLocalConfigPermissioningControllerTest.java
  30. 22
      metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/MetricsConfiguration.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);

@ -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();
}

@ -669,8 +669,8 @@ public class RunnerBuilder {
final Set<Capability> supportedCapabilities,
final Collection<RpcApi> jsonRpcApis,
final FilterManager filterManager,
final Optional<AccountLocalConfigPermissioningController> accountWhitelistController,
final Optional<NodeLocalConfigPermissioningController> nodeWhitelistController,
final Optional<AccountLocalConfigPermissioningController> accountAllowlistController,
final Optional<NodeLocalConfigPermissioningController> 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,

@ -590,7 +590,7 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test
public void nodePermissioningTomlPathMustUseOption() throws IOException {
final List<URI> allowlistedNodes =
final List<URI> 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");

@ -34,7 +34,7 @@ public class GraphQLConfiguration {
private int port;
private String host;
private List<String> corsAllowedDomains = Collections.emptyList();
private List<String> hostsWhitelist = Arrays.asList("localhost", "127.0.0.1");
private List<String> 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<String> getHostsWhitelist() {
return Collections.unmodifiableCollection(this.hostsWhitelist);
Collection<String> getHostsAllowlist() {
return Collections.unmodifiableCollection(this.hostsAllowlist);
}
public void setHostsAllowlist(final List<String> hostsWhitelist) {
checkNotNull(hostsWhitelist);
this.hostsWhitelist = hostsWhitelist;
public void setHostsAllowlist(final List<String> 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);
}
}

@ -192,8 +192,8 @@ public class GraphQLHttpService {
private Handler<RoutingContext> checkWhitelistHostHeader() {
return event -> {
final Optional<String> 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;
}
}

@ -37,7 +37,7 @@ public class JsonRpcConfiguration {
private String host;
private List<String> corsAllowedDomains = Collections.emptyList();
private List<RpcApi> rpcApis;
private List<String> hostsWhitelist = Arrays.asList("localhost", "127.0.0.1");
private List<String> 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<String> getHostsAllowlist() {
return Collections.unmodifiableCollection(this.hostsWhitelist);
return Collections.unmodifiableCollection(this.hostsAllowlist);
}
public void setHostsAllowlist(final List<String> 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);

@ -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<String> 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:

@ -47,7 +47,7 @@ public class PermGetNodesAllowlist implements JsonRpcMethod {
try {
if (nodeWhitelistPermissioningController.isPresent()) {
final List<String> enodeList =
nodeWhitelistPermissioningController.get().getNodesWhitelist();
nodeWhitelistPermissioningController.get().getNodesAllowlist();
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), enodeList);
} else {

@ -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<String> 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:

@ -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

@ -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<RoutingContext> 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<String> header) {
public boolean hasAllowedHostnameHeader(final Optional<String> header) {
return configuration.getHostsAllowlist().contains("*")
|| header.map(value -> checkHostInAllowlist(validateHostHeader(value))).orElse(false);
}

@ -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);

@ -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);

@ -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);
}

@ -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);
}

@ -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);

@ -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);

@ -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();
}

@ -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();

@ -516,7 +516,7 @@ public class TransactionPoolTest {
}
@Test
public void shouldAllowTransactionWhenAccountWhitelistControllerIsNotPresent() {
public void shouldAllowTransactionWhenAccountAllowlistControllerIsNotPresent() {
givenTransactionIsValid(transaction1);
assertThat(transactionPool.addLocalTransaction(transaction1)).isEqualTo(valid());

@ -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();

@ -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<EnodeURL> fixedNodes;
private final Bytes localNodeId;
private final List<EnodeURL> nodesWhitelist = new ArrayList<>();
private final List<EnodeURL> nodesAllowlist = new ArrayList<>();
private final AllowlistPersistor allowlistPersistor;
private final Subscribers<Consumer<NodeWhitelistUpdatedEvent>> nodeWhitelistUpdatedObservers =
private final Subscribers<Consumer<NodeAllowlistUpdatedEvent>> nodeAllowlistUpdatedObservers =
Subscribers.create();
private final Counter checkCounter;
@ -106,8 +106,8 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning
}
}
public NodesWhitelistResult addNodes(final List<String> enodeURLs) {
final NodesWhitelistResult inputValidationResult = validInput(enodeURLs);
public NodesAllowlistResult addNodes(final List<String> 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<EnodeURL> oldWhitelist = new ArrayList<>(this.nodesWhitelist);
final List<EnodeURL> 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<String> enodeURLs) {
final NodesWhitelistResult inputValidationResult = validInput(enodeURLs);
public NodesAllowlistResult removeNodes(final List<String> 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<EnodeURL> oldWhitelist = new ArrayList<>(this.nodesWhitelist);
final List<EnodeURL> 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<EnodeURL> oldWhitelist) {
private NodesAllowlistResult updateAllowlistInConfigFile(final List<EnodeURL> 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<String> peers) {
private NodesAllowlistResult validInput(final List<String> 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<String> peers) {
@ -218,9 +218,9 @@ public class NodeLocalConfigPermissioningController implements NodePermissioning
allowlistPersistor.updateConfig(ALLOWLIST_TYPE.NODES, nodes);
}
private void revertState(final List<EnodeURL> nodesWhitelist) {
this.nodesWhitelist.clear();
this.nodesWhitelist.addAll(nodesWhitelist);
private void revertState(final List<EnodeURL> nodesAllowlist) {
this.nodesAllowlist.clear();
this.nodesAllowlist.addAll(nodesAllowlist);
}
private Collection<String> peerToEnodeURI(final Collection<EnodeURL> 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<String> getNodesWhitelist() {
return nodesWhitelist.stream().map(Object::toString).collect(Collectors.toList());
public List<String> getNodesAllowlist() {
return nodesAllowlist.stream().map(Object::toString).collect(Collectors.toList());
}
public synchronized void reload() throws RuntimeException {
final List<EnodeURL> currentAccountsList = new ArrayList<>(nodesWhitelist);
nodesWhitelist.clear();
final List<EnodeURL> 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<EnodeURL> previousNodeWhitelist, final List<EnodeURL> currentNodesList) {
private void createNodeAllowlistModifiedEventAfterReload(
final List<EnodeURL> previousNodeAllowlist, final List<EnodeURL> currentNodesList) {
final List<EnodeURL> removedNodes =
previousNodeWhitelist.stream()
previousNodeAllowlist.stream()
.filter(n -> !currentNodesList.contains(n))
.collect(Collectors.toList());
final List<EnodeURL> 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<NodeWhitelistUpdatedEvent> subscriber) {
return nodeWhitelistUpdatedObservers.subscribe(subscriber);
public long subscribeToListUpdatedEvent(final Consumer<NodeAllowlistUpdatedEvent> 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<String> 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();
}

@ -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<URI> nodesWhitelistToml =
nodeWhitelistTomlArray
if (nodeAllowlistTomlArray != null) {
List<URI> 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<String> accountsWhitelistToml =
accountWhitelistTomlArray
if (accountAllowlistTomlArray != null) {
List<String> 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

@ -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<EnodeURL> addedNodes;
private final List<EnodeURL> removedNodes;
public NodeWhitelistUpdatedEvent(
public NodeAllowlistUpdatedEvent(
final List<EnodeURL> addedNodes, final List<EnodeURL> 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);
}

@ -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<String> lines = Lists.newArrayList(nodesWhitelist, accountsWhitelist);
List<String> 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<String> updatedWhitelist = Collections.singleton("node5");
final Set<String> 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

@ -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));

@ -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);

@ -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<String> newNode1 = singletonList(EnodeURL.fromString(enode1).toString());
List<String> 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<NodeWhitelistUpdatedEvent> consumer = mock(Consumer.class);
final NodeWhitelistUpdatedEvent expectedEvent =
new NodeWhitelistUpdatedEvent(
public void whenAddingNodeShouldNotifyAllowlistModifiedSubscribers() {
final Consumer<NodeAllowlistUpdatedEvent> 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<NodeWhitelistUpdatedEvent> consumer = mock(Consumer.class);
final Consumer<NodeAllowlistUpdatedEvent> 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<NodeWhitelistUpdatedEvent> consumer = mock(Consumer.class);
final NodeWhitelistUpdatedEvent expectedEvent =
new NodeWhitelistUpdatedEvent(
final Consumer<NodeAllowlistUpdatedEvent> 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<NodeWhitelistUpdatedEvent> consumer = mock(Consumer.class);
final Consumer<NodeAllowlistUpdatedEvent> 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<NodeWhitelistUpdatedEvent> consumer = mock(Consumer.class);
final NodeWhitelistUpdatedEvent expectedEvent =
new NodeWhitelistUpdatedEvent(
final Consumer<NodeAllowlistUpdatedEvent> 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<NodeWhitelistUpdatedEvent> consumer = mock(Consumer.class);
final Consumer<NodeAllowlistUpdatedEvent> consumer = mock(Consumer.class);
when(permissioningConfig.getNodePermissioningConfigFilePath())
.thenReturn(permissionsFile.toAbsolutePath().toString());

@ -45,7 +45,7 @@ public class MetricsConfiguration {
private final String pushHost;
private final int pushInterval;
private final String prometheusJob;
private final List<String> hostsWhitelist;
private final List<String> 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<String> hostsWhitelist,
final List<String> 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<String> 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<String> hostsWhitelist = Arrays.asList("localhost", "127.0.0.1");
private List<String> 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<String> hostsWhitelist) {
this.hostsWhitelist = hostsWhitelist;
public Builder hostsAllowlist(final List<String> hostsAllowlist) {
this.hostsAllowlist = hostsAllowlist;
return this;
}
@ -262,7 +262,7 @@ public class MetricsConfiguration {
pushHost,
pushInterval,
prometheusJob,
hostsWhitelist,
hostsAllowlist,
timersEnabled);
}
}

Loading…
Cancel
Save