use of tech.pegasys.teku.beaconrestapi.BeaconRestApiConfig in project teku by ConsenSys.
the class RestApiHostAllowlistIntegrationTest method shouldReturnForbiddenIfHostNotAuthorized.
@Test
public void shouldReturnForbiddenIfHostNotAuthorized() throws Exception {
final Eth1Address depositContractAddress = new Eth1Address(Bytes.fromHexString("0xdddddddddddddddddddddddddddddddddddddddd"));
final BeaconRestApiConfig config = BeaconRestApiConfig.builder().restApiPort(0).restApiEnabled(true).restApiDocsEnabled(false).eth1DepositContractAddress(depositContractAddress).restApiHostAllowlist(List.of("not.authorized.host")).restApiCorsAllowedOrigins(new ArrayList<>()).build();
startPreGenesisRestAPIWithConfig(config);
final Response response = getLatest();
assertForbidden(response);
}
use of tech.pegasys.teku.beaconrestapi.BeaconRestApiConfig in project teku by ConsenSys.
the class BeaconRestApiOptionsTest method restApiHostAllowlist_shouldNotRequireAValue.
@Test
public void restApiHostAllowlist_shouldNotRequireAValue() {
TekuConfiguration tekuConfiguration = getTekuConfigurationFromArguments("--rest-api-host-allowlist");
final BeaconRestApiConfig config = getConfig(tekuConfiguration);
assertThat(config.getRestApiHostAllowlist()).isEmpty();
assertThat(createConfigBuilder().restApi(b -> b.restApiHostAllowlist(Collections.emptyList())).build()).usingRecursiveComparison().isEqualTo(tekuConfiguration);
}
use of tech.pegasys.teku.beaconrestapi.BeaconRestApiConfig in project teku by ConsenSys.
the class BeaconRestApiOptionsTest method restApiCorsAllowedOrigins_shouldSupportAllowingMultipleHosts.
@Test
public void restApiCorsAllowedOrigins_shouldSupportAllowingMultipleHosts() {
TekuConfiguration tekuConfiguration = getTekuConfigurationFromArguments("--rest-api-cors-origins", "my.host,their.host");
final BeaconRestApiConfig config = getConfig(tekuConfiguration);
assertThat(config.getRestApiCorsAllowedOrigins()).containsOnly("my.host", "their.host");
assertThat(createConfigBuilder().restApi(b -> b.restApiCorsAllowedOrigins(List.of("my.host", "their.host"))).build()).usingRecursiveComparison().isEqualTo(tekuConfiguration);
}
use of tech.pegasys.teku.beaconrestapi.BeaconRestApiConfig in project teku by ConsenSys.
the class BeaconRestApiOptionsTest method shouldReadFromConfigurationFile.
@Test
public void shouldReadFromConfigurationFile() {
final BeaconRestApiConfig config = getConfig(getTekuConfigurationFromFile("beaconRestApiOptions_config.yaml"));
assertThat(config.getRestApiInterface()).isEqualTo("127.100.0.1");
assertThat(config.getRestApiPort()).isEqualTo(5055);
assertThat(config.isRestApiDocsEnabled()).isTrue();
assertThat(config.isRestApiEnabled()).isTrue();
assertThat(config.getRestApiHostAllowlist()).containsExactly("test.domain.com", "11.12.13.14");
assertThat(config.getRestApiCorsAllowedOrigins()).containsExactly("127.1.2.3", "origin.allowed.com");
assertThat(config.getMaxUrlLength()).isEqualTo(65535);
}
use of tech.pegasys.teku.beaconrestapi.BeaconRestApiConfig in project teku by ConsenSys.
the class BeaconRestApiOptionsTest method restApiHostAllowlist_shouldSupportAllowingMultipleHosts.
@Test
public void restApiHostAllowlist_shouldSupportAllowingMultipleHosts() {
TekuConfiguration tekuConfiguration = getTekuConfigurationFromArguments("--rest-api-host-allowlist", "my.host,their.host");
final BeaconRestApiConfig config = getConfig(tekuConfiguration);
assertThat(config.getRestApiHostAllowlist()).containsOnly("my.host", "their.host");
assertThat(createConfigBuilder().restApi(b -> b.restApiHostAllowlist(List.of("my.host", "their.host"))).build()).usingRecursiveComparison().isEqualTo(tekuConfiguration);
}
Aggregations