Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where rpc authentication would be enabled even if it was disabled if credentials file was specified #454

Merged
merged 7 commits into from
Mar 12, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ws ut
Signed-off-by: Jason Frame <[email protected]>
  • Loading branch information
jframe committed Mar 12, 2020
commit 53bdccd6b1a7d83f76af3d56cb7e3a874d20a24c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import static org.assertj.core.api.Assertions.assertThat;

import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration;

import java.io.File;
import java.io.IOException;
Expand All @@ -28,7 +29,7 @@
public class AuthenticationServiceTest {

@Test
public void authenticationServiceNotCreatedWhenAuthenticationDisabledAndHasCredentialsFile() {
public void authenticationServiceNotCreatedWhenRpcAuthenticationDisabledAndHasCredentialsFile() {
final JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault();
jsonRpcConfiguration.setAuthenticationEnabled(false);
jsonRpcConfiguration.setAuthenticationCredentialsFile("some/file/path");
Expand All @@ -39,7 +40,7 @@ public void authenticationServiceNotCreatedWhenAuthenticationDisabledAndHasCrede
}

@Test
public void authenticationServiceNotCreatedWhenAuthenticationDisabledAndHasPublicKeyFile()
public void authenticationServiceNotCreatedWhenRpcAuthenticationDisabledAndHasPublicKeyFile()
throws IOException {
final File publicKeyFile = File.createTempFile("publicKey", "jwt");
final JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault();
Expand All @@ -53,7 +54,7 @@ public void authenticationServiceNotCreatedWhenAuthenticationDisabledAndHasPubli

@Test
public void
authenticationServiceNotCreatedWhenAuthenticationDisabledAndNoCredentialsFileOrPublicKeyFile()
authenticationServiceNotCreatedWhenRpcAuthenticationDisabledAndNoCredentialsFileOrPublicKeyFile()
throws IOException {
final File publicKeyFile = File.createTempFile("publicKey", "jwt");
final JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault();
Expand All @@ -65,4 +66,43 @@ public void authenticationServiceNotCreatedWhenAuthenticationDisabledAndHasPubli
AuthenticationService.create(Vertx.vertx(), jsonRpcConfiguration);
assertThat(authenticationService).isEmpty();
}

@Test
public void authenticationServiceNotCreatedWhenWsAuthenticationDisabledAndHasCredentialsFile() {
final WebSocketConfiguration webSocketConfiguration = WebSocketConfiguration.createDefault();
webSocketConfiguration.setAuthenticationEnabled(false);
webSocketConfiguration.setAuthenticationCredentialsFile("some/file/path");

final Optional<AuthenticationService> authenticationService =
AuthenticationService.create(Vertx.vertx(), webSocketConfiguration);
assertThat(authenticationService).isEmpty();
}

@Test
public void authenticationServiceNotCreatedWhenWsAuthenticationDisabledAndHasPublicKeyFile()
throws IOException {
final File publicKeyFile = File.createTempFile("publicKey", "jwt");
final WebSocketConfiguration webSocketConfiguration = WebSocketConfiguration.createDefault();
webSocketConfiguration.setAuthenticationEnabled(false);
webSocketConfiguration.setAuthenticationPublicKeyFile(publicKeyFile);

final Optional<AuthenticationService> authenticationService =
AuthenticationService.create(Vertx.vertx(), webSocketConfiguration);
assertThat(authenticationService).isEmpty();
}

@Test
public void
authenticationServiceNotCreatedWhenWsAuthenticationDisabledAndNoCredentialsFileOrPublicKeyFile()
throws IOException {
final File publicKeyFile = File.createTempFile("publicKey", "jwt");
final WebSocketConfiguration webSocketConfiguration = WebSocketConfiguration.createDefault();
webSocketConfiguration.setAuthenticationEnabled(false);
webSocketConfiguration.setAuthenticationPublicKeyFile(publicKeyFile);
webSocketConfiguration.setAuthenticationCredentialsFile("some/file/path");

final Optional<AuthenticationService> authenticationService =
AuthenticationService.create(Vertx.vertx(), webSocketConfiguration);
assertThat(authenticationService).isEmpty();
}
}