use of io.envoyproxy.envoy.extensions.filters.http.fault.v3.HTTPFault in project grpc-java by grpc.
the class ClientXdsClientDataTest method parseOverrideFilterConfigs_unsupportedAndRequired.
@Test
public void parseOverrideFilterConfigs_unsupportedAndRequired() {
filterRegistry.register(FaultFilter.INSTANCE);
HTTPFault httpFault = HTTPFault.newBuilder().setDelay(FaultDelay.newBuilder().setFixedDelay(Durations.fromNanos(3000))).build();
Map<String, Any> configOverrides = ImmutableMap.of("envoy.fault", Any.pack(httpFault), "unsupported.filter", Any.pack(io.envoyproxy.envoy.config.route.v3.FilterConfig.newBuilder().setIsOptional(false).setConfig(Any.pack(StringValue.of("string value"))).build()));
assertThat(ClientXdsClient.parseOverrideFilterConfigs(configOverrides, filterRegistry).getErrorDetail()).isEqualTo("HttpFilter [unsupported.filter]" + "(type.googleapis.com/google.protobuf.StringValue) is required but unsupported");
configOverrides = ImmutableMap.of("envoy.fault", Any.pack(httpFault), "unsupported.filter", Any.pack(StringValue.of("string value")));
assertThat(ClientXdsClient.parseOverrideFilterConfigs(configOverrides, filterRegistry).getErrorDetail()).isEqualTo("HttpFilter [unsupported.filter]" + "(type.googleapis.com/google.protobuf.StringValue) is required but unsupported");
}
use of io.envoyproxy.envoy.extensions.filters.http.fault.v3.HTTPFault in project grpc-java by grpc.
the class ClientXdsClientDataTest method parseOverrideFilterConfigs_unsupportedButOptional.
@Test
public void parseOverrideFilterConfigs_unsupportedButOptional() {
filterRegistry.register(FaultFilter.INSTANCE);
HTTPFault httpFault = HTTPFault.newBuilder().setDelay(FaultDelay.newBuilder().setFixedDelay(Durations.fromNanos(3000))).build();
Map<String, Any> configOverrides = ImmutableMap.of("envoy.fault", Any.pack(httpFault), "unsupported.filter", Any.pack(io.envoyproxy.envoy.config.route.v3.FilterConfig.newBuilder().setIsOptional(true).setConfig(Any.pack(StringValue.of("string value"))).build()));
Map<String, FilterConfig> parsedConfigs = ClientXdsClient.parseOverrideFilterConfigs(configOverrides, filterRegistry).getStruct();
assertThat(parsedConfigs).hasSize(1);
assertThat(parsedConfigs).containsKey("envoy.fault");
}
use of io.envoyproxy.envoy.extensions.filters.http.fault.v3.HTTPFault in project grpc-java by grpc.
the class FaultFilter method parseFilterConfig.
@Override
public ConfigOrError<FaultConfig> parseFilterConfig(Message rawProtoMessage) {
HTTPFault httpFaultProto;
if (!(rawProtoMessage instanceof Any)) {
return ConfigOrError.fromError("Invalid config type: " + rawProtoMessage.getClass());
}
Any anyMessage = (Any) rawProtoMessage;
try {
httpFaultProto = anyMessage.unpack(HTTPFault.class);
} catch (InvalidProtocolBufferException e) {
return ConfigOrError.fromError("Invalid proto: " + e);
}
return parseHttpFault(httpFaultProto);
}
Aggregations