PIE-1526: Fix account permissioning check case matching (#1314)

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Lucas Saldanha 6 years ago committed by GitHub
parent b00e788642
commit d2d1d82df7
  1. 2
      ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/AccountWhitelistController.java
  2. 10
      ethereum/permissioning/src/test/java/tech/pegasys/pantheon/ethereum/permissioning/AccountWhitelistControllerTest.java

@ -141,7 +141,7 @@ public class AccountWhitelistController {
}
public boolean contains(final String account) {
return (accountWhitelist.contains(account));
return accountWhitelist.stream().anyMatch(a -> a.equalsIgnoreCase(account));
}
public List<String> getAccountWhitelist() {

@ -231,6 +231,16 @@ public class AccountWhitelistControllerTest {
.isTrue();
}
@Test
public void shouldMatchAccountsWithInconsistentCasing() {
when(permissioningConfig.isAccountWhitelistEnabled()).thenReturn(true);
when(permissioningConfig.getAccountWhitelist())
.thenReturn(singletonList("0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"));
controller = new AccountWhitelistController(permissioningConfig, whitelistPersistor);
assertThat(controller.contains("0xFE3B557E8Fb62b89F4916B721be55cEb828dBd73")).isTrue();
}
private Path createPermissionsFileWithAccount(final String account) throws IOException {
final String nodePermissionsFileContent = "accounts-whitelist=[\"" + account + "\"]";
final Path permissionsFile = Files.createTempFile("account_permissions", "");

Loading…
Cancel
Save