feat(firehose): validate and persist ProcessingConfiguration (#3375)

* feat(firehose): validate and persist ProcessingConfiguration

A stream configured with a record transformation was accepted with a 200,
the member dropped by ignoreUnknown, and nothing echoed back. It is now
modelled, validated and stored, so a caller sees what it configured. The
transformation itself is not applied yet: records are still delivered
untransformed, and create and update say so in a warning.

The behavior follows what real AWS does, probed in us-west-2:

- A Lambda processor requires a LambdaArn, which must be a well-formed
  function ARN, and BufferSizeInMBs and BufferIntervalInSeconds are
  all-or-nothing.
- Processor types and parameter names are checked against AWS's enums,
  reproducing the order those sets are printed in and the 1-based member
  paths of the constraint messages.
- UpdateDestination replaces the whole block rather than merging it
  member-wise, the opposite of DataFormatConversionConfiguration: an update
  carrying only {"Enabled": false} leaves no processors behind, and an
  update is validated against its own content.
- A stored Lambda processor gains NumberOfRetries 3 and the stream's
  RoleArn, echoed in AWS's own parameter order.

Two checks AWS does not make are deliberately absent: NumberOfRetries is
not range-checked, accepted as 0 or 9 despite the documented 1 to 8, and the
function a LambdaArn names is not required to exist, unlike the Glue table a
conversion schema names.

* docs(firehose): record what AWS does with a null processor list member

Probed: real AWS answers InternalFailure for "Processors": [null] and for
"Parameters": [null], a fault of its own rather than a validation error.
Reproducing that helps nobody, so the entry stays ignored, which leaves the
configuration a caller would have had by omitting it, and the deviation is
written down instead. A test pins the choice so it reads as a decision.

The review also asked for a maximum of 3 on the processor list. Probing found
no such bound: three, four and five processors all pass validation and reach
the role check, so nothing is enforced here.
This commit is contained in:
Kenshin Okinaka authored and GitHub committed 2026-09-10 23:25:18 -04:00
1 parent 1726c6a8a3
commit debf9fb0dc
10 files changed
+1056 -9

No files matched your search

@@ -186,6 +186,49 @@ class FirehoseDataFormatConversionIntegrationTest {
.body(DESCRIPTION_PATH + ".DataFormatConversionConfiguration", nullValue());
}
/**
* The processing member is extended-only in AWS's model too, so the legacy shapes
* drop it the same way. Wire-level rather than through the service, since the
* dropping happens in the handler as the request is unmarshalled.
*/
@Test
@Order(7)
void legacyS3DestinationShapeIgnoresTheProcessingMember() {
given()
.contentType(CONTENT_TYPE)
.header("X-Amz-Target", TARGET_PREFIX + "CreateDeliveryStream")
.body("""
{
"DeliveryStreamName": "legacy-shape-processing-stream",
"S3DestinationConfiguration": {
"RoleARN": "%s",
"BucketARN": "%s",
"CompressionFormat": "UNCOMPRESSED",
"ProcessingConfiguration": {
"Enabled": true,
"Processors": [ { "Type": "Lambda", "Parameters": [
{ "ParameterName": "LambdaArn",
"ParameterValue": "arn:aws:lambda:us-east-1:000000000000:function:t" } ] } ]
}
}
}
""".formatted(ROLE_ARN, BUCKET_ARN))
.when()
.post("/")
.then()
.statusCode(200);
given()
.contentType(CONTENT_TYPE)
.header("X-Amz-Target", TARGET_PREFIX + "DescribeDeliveryStream")
.body("{ \"DeliveryStreamName\": \"legacy-shape-processing-stream\" }")
.when()
.post("/")
.then()
.statusCode(200)
.body(DESCRIPTION_PATH + ".ProcessingConfiguration", nullValue());
}
@Test
@Order(4)
void createRejectsCompressedDestinationsWithTheAwsMessage() {
@@ -0,0 +1,348 @@
package io.github.hectorvent.floci.services.firehose;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.common.RegionResolver;
import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
import io.github.hectorvent.floci.core.storage.StorageFactory;
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.ProcessingConfiguration;
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.Processor;
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.ProcessorParameter;
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.S3Destination;
import io.github.hectorvent.floci.services.kinesis.KinesisService;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.testing.MutableClock;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.Mockito;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/**
* The messages, the enum orders and the storage behavior asserted here were probed
* against real AWS (us-west-2, 2026-09-10). Two of them are deliberate absences:
* NumberOfRetries is not range-checked, and the function a LambdaArn names is not
* required to exist.
*/
class FirehoseProcessingConfigurationTest {
private static final String ROLE_ARN = "arn:aws:iam::000000000000:role/firehose-role";
private static final String LAMBDA_ARN = "arn:aws:lambda:us-east-1:000000000000:function:transform";
private static final String DESTINATION_ID = "destinationId-000000000001";
private static final String BUFFER_PAIR_MESSAGE = "Both BufferSizeInMBs and BufferIntervalInSeconds"
+ " are required to configure buffering for lambda processor.";
private FirehoseService service;
@BeforeEach
void setUp() {
StorageFactory storageFactory = mock(StorageFactory.class);
Map<String, AccountAwareStorageBackend<?>> backends = new HashMap<>();
when(storageFactory.create(anyString(), anyString(), any()))
.thenAnswer(invocation -> backends.computeIfAbsent(
invocation.getArgument(0) + "/" + invocation.getArgument(1),
k -> AccountAwareStorageBackend.inMemory("000000000000")));
EmulatorConfig.FirehoseServiceConfig firehoseCfg = mock(EmulatorConfig.FirehoseServiceConfig.class);
when(firehoseCfg.enabled()).thenReturn(true);
when(firehoseCfg.tickIntervalSeconds()).thenReturn(10L);
when(firehoseCfg.flushRecordCount()).thenReturn(0);
EmulatorConfig.ServicesConfig servicesCfg = mock(EmulatorConfig.ServicesConfig.class);
when(servicesCfg.firehose()).thenReturn(firehoseCfg);
EmulatorConfig config = mock(EmulatorConfig.class);
when(config.services()).thenReturn(servicesCfg);
RegionResolver regionResolver = mock(RegionResolver.class);
when(regionResolver.getDefaultRegion()).thenReturn("us-east-1");
when(regionResolver.getAccountId()).thenReturn("000000000000");
service = new FirehoseService(storageFactory, mock(S3Service.class),
Mockito.mock(KinesisService.class), regionResolver, new MutableClock(), config,
Mockito.mock(FirehoseParquetConverter.class));
}
private static ProcessorParameter parameter(String name, String value) {
ProcessorParameter parameter = new ProcessorParameter();
parameter.setParameterName(name);
parameter.setParameterValue(value);
return parameter;
}
private static ProcessingConfiguration processing(String type, ProcessorParameter... parameters) {
Processor processor = new Processor();
processor.setType(type);
processor.setParameters(new ArrayList<>(List.of(parameters)));
ProcessingConfiguration processing = new ProcessingConfiguration();
processing.setEnabled(true);
processing.setProcessors(new ArrayList<>(List.of(processor)));
return processing;
}
private static ProcessingConfiguration lambdaProcessing(ProcessorParameter... parameters) {
return processing("Lambda", parameters);
}
private static S3Destination destination(Consumer<S3Destination> customizer) {
S3Destination s3 = new S3Destination();
s3.setRoleArn(ROLE_ARN);
s3.setBucketArn("arn:aws:s3:::results");
customizer.accept(s3);
return s3;
}
private String currentVersion(String name) {
return service.describeDeliveryStream(name).getVersionId();
}
private List<String> storedParameterNames(String name) {
List<ProcessorParameter> parameters = service.describeDeliveryStream(name).s3Destination()
.getProcessingConfiguration().getProcessors().get(0).getParameters();
List<String> names = new ArrayList<>();
parameters.forEach(parameter -> names.add(parameter.getParameterName()));
return names;
}
@Test
void aLambdaProcessorWithoutALambdaArnIsRejected() {
AwsException error = assertThrows(AwsException.class, () -> service.createDeliveryStream("stream",
destination(s3 -> s3.setProcessingConfiguration(
lambdaProcessing(parameter("NumberOfRetries", "2"))))));
assertEquals("InvalidArgumentException", error.getErrorCode());
assertEquals("LambdaArn is required when Lambda processor is used.", error.getMessage());
}
// Probed: AWS rejects a function name that is not one Lambda would accept, so the
// shape has to be Lambda's rather than merely arn-looking.
@ParameterizedTest
@ValueSource(strings = {
"not-an-arn",
"arn:aws:lambda:us-east-1:000000000000:function:bad name",
"arn:aws:lambda:us-east-1:000000000000:function:name/with/slashes",
"arn:aws:lambda:us-east-1:000000000000:function:bad?name",
"arn:aws:lambda:us-east-1:000000000000:function:bad@name",
"arn:aws:lambda:us-east-1:000000000000:function:bad[name",
})
void aMalformedLambdaArnIsRejected(String lambdaArn) {
AwsException error = assertThrows(AwsException.class, () -> service.createDeliveryStream("stream",
destination(s3 -> s3.setProcessingConfiguration(
lambdaProcessing(parameter("LambdaArn", lambdaArn))))));
assertEquals("Invalid lambda ARN.", error.getMessage());
}
@ParameterizedTest
@ValueSource(strings = {
"arn:aws:lambda:us-east-1:000000000000:function:transform",
"arn:aws:lambda:us-east-1:000000000000:function:transform:$LATEST",
"arn:aws:lambda:us-east-1:000000000000:function:transform:prod",
})
void aQualifiedOrUnqualifiedFunctionArnIsAccepted(String lambdaArn) {
assertDoesNotThrow(() -> service.createDeliveryStream("stream-" + lambdaArn.hashCode(),
destination(s3 -> s3.setProcessingConfiguration(
lambdaProcessing(parameter("LambdaArn", lambdaArn))))));
}
// A function that does not exist is still accepted: unlike a conversion schema's
// Glue table, AWS resolves nothing at configuration time.
@Test
void aWellFormedArnToAnyFunctionIsAccepted() {
assertDoesNotThrow(() -> service.createDeliveryStream("stream",
destination(s3 -> s3.setProcessingConfiguration(
lambdaProcessing(parameter("LambdaArn",
"arn:aws:lambda:us-east-1:000000000000:function:never-created"))))));
}
@ParameterizedTest
@ValueSource(strings = {"BufferSizeInMBs", "BufferIntervalInSeconds"})
void oneBufferingParameterWithoutTheOtherIsRejected(String parameterName) {
AwsException error = assertThrows(AwsException.class, () -> service.createDeliveryStream("stream",
destination(s3 -> s3.setProcessingConfiguration(lambdaProcessing(
parameter("LambdaArn", LAMBDA_ARN), parameter(parameterName, "2"))))));
assertEquals(BUFFER_PAIR_MESSAGE, error.getMessage());
}
@Test
void bothBufferingParametersTogetherAreAccepted() {
assertDoesNotThrow(() -> service.createDeliveryStream("stream",
destination(s3 -> s3.setProcessingConfiguration(lambdaProcessing(
parameter("LambdaArn", LAMBDA_ARN),
parameter("BufferSizeInMBs", "2"),
parameter("BufferIntervalInSeconds", "70"))))));
}
// Deliberate: real AWS accepts both, despite the documented 1 to 8.
@ParameterizedTest
@ValueSource(strings = {"0", "9"})
void numberOfRetriesIsNotRangeChecked(String retries) {
assertDoesNotThrow(() -> service.createDeliveryStream("stream-" + retries,
destination(s3 -> s3.setProcessingConfiguration(lambdaProcessing(
parameter("LambdaArn", LAMBDA_ARN), parameter("NumberOfRetries", retries))))));
}
// The LambdaArn rule belongs to the Lambda processor, not to every processor.
@Test
void anotherProcessorTypeIsNotSubjectToTheLambdaRules() {
assertDoesNotThrow(() -> service.createDeliveryStream("stream",
destination(s3 -> s3.setProcessingConfiguration(
processing("AppendDelimiterToRecord", parameter("Delimiter", "\\n"))))));
}
@Test
void storedParametersGainTheDefaultsAndAFixedOrder() {
service.createDeliveryStream("stream", destination(s3 -> s3.setProcessingConfiguration(
lambdaProcessing(parameter("BufferIntervalInSeconds", "70"),
parameter("BufferSizeInMBs", "2"),
parameter("LambdaArn", LAMBDA_ARN)))));
assertEquals(List.of("LambdaArn", "NumberOfRetries", "RoleArn", "BufferSizeInMBs",
"BufferIntervalInSeconds"), storedParameterNames("stream"));
List<ProcessorParameter> stored = service.describeDeliveryStream("stream").s3Destination()
.getProcessingConfiguration().getProcessors().get(0).getParameters();
assertEquals("3", stored.get(1).getParameterValue());
assertEquals(ROLE_ARN, stored.get(2).getParameterValue());
}
@Test
void aRepeatedParameterNameIsRejected() {
AwsException error = assertThrows(AwsException.class, () -> service.createDeliveryStream("stream",
destination(s3 -> s3.setProcessingConfiguration(lambdaProcessing(
parameter("LambdaArn", LAMBDA_ARN), parameter("LambdaArn", "not-an-arn"))))));
assertEquals("Duplicate ProcessorParameter passed to ProcessingConfiguration.", error.getMessage());
}
// The duplicate check runs first: the processor is missing its LambdaArn as well,
// and AWS still reports the duplicate.
@Test
void aRepeatedParameterIsReportedBeforeTheMissingLambdaArn() {
AwsException error = assertThrows(AwsException.class, () -> service.createDeliveryStream("stream",
destination(s3 -> s3.setProcessingConfiguration(lambdaProcessing(
parameter("NumberOfRetries", "2"), parameter("NumberOfRetries", "3"))))));
assertEquals("Duplicate ProcessorParameter passed to ProcessingConfiguration.", error.getMessage());
}
@Test
void moreThanOneLambdaProcessorIsRejected() {
Processor first = new Processor();
first.setType("Lambda");
first.setParameters(List.of(parameter("LambdaArn", LAMBDA_ARN)));
Processor second = new Processor();
second.setType("Lambda");
second.setParameters(List.of(parameter("LambdaArn", LAMBDA_ARN)));
ProcessingConfiguration processing = new ProcessingConfiguration();
processing.setEnabled(true);
processing.setProcessors(List.of(first, second));
AwsException error = assertThrows(AwsException.class, () -> service.createDeliveryStream("stream",
destination(s3 -> s3.setProcessingConfiguration(processing))));
assertEquals("Cannot have more than 1 Lambda processor.", error.getMessage());
}
// A Lambda processor alongside another type is fine.
@Test
void twoProcessorsOfDifferentTypesAreAccepted() {
Processor lambda = new Processor();
lambda.setType("Lambda");
lambda.setParameters(List.of(parameter("LambdaArn", LAMBDA_ARN)));
Processor delimiter = new Processor();
delimiter.setType("AppendDelimiterToRecord");
delimiter.setParameters(List.of(parameter("Delimiter", "\\n")));
ProcessingConfiguration processing = new ProcessingConfiguration();
processing.setEnabled(true);
processing.setProcessors(List.of(lambda, delimiter));
assertDoesNotThrow(() -> service.createDeliveryStream("stream",
destination(s3 -> s3.setProcessingConfiguration(processing))));
}
// Settled when written, so reading cannot change what a later update sees: the
// injected RoleArn must be the same whether or not a Describe happened in between.
@Test
void describeDoesNotDecideWhatALaterUpdateSees() {
service.createDeliveryStream("read-first", destination(s3 -> s3.setProcessingConfiguration(
lambdaProcessing(parameter("LambdaArn", LAMBDA_ARN)))));
service.createDeliveryStream("no-read", destination(s3 -> s3.setProcessingConfiguration(
lambdaProcessing(parameter("LambdaArn", LAMBDA_ARN)))));
service.describeDeliveryStream("read-first");
String otherRole = "arn:aws:iam::000000000000:role/other";
for (String name : List.of("read-first", "no-read")) {
service.updateDestination(name, currentVersion(name), DESTINATION_ID,
destination(s3 -> s3.setRoleArn(otherRole)));
}
assertEquals(storedRoleParameter("read-first"), storedRoleParameter("no-read"));
assertEquals(ROLE_ARN, storedRoleParameter("no-read"));
}
private String storedRoleParameter(String name) {
for (ProcessorParameter parameter : service.describeDeliveryStream(name).s3Destination()
.getProcessingConfiguration().getProcessors().get(0).getParameters()) {
if ("RoleArn".equals(parameter.getParameterName())) {
return parameter.getParameterValue();
}
}
return null;
}
// The opposite of the conversion block, which merges member-wise.
@Test
void anUpdateReplacesTheWholeBlockRatherThanMergingIt() {
service.createDeliveryStream("stream", destination(s3 -> s3.setProcessingConfiguration(
lambdaProcessing(parameter("LambdaArn", LAMBDA_ARN)))));
ProcessingConfiguration disabled = new ProcessingConfiguration();
disabled.setEnabled(false);
service.updateDestination("stream", currentVersion("stream"), DESTINATION_ID,
destination(s3 -> s3.setProcessingConfiguration(disabled)));
ProcessingConfiguration stored = service.describeDeliveryStream("stream").s3Destination()
.getProcessingConfiguration();
assertEquals(false, stored.getEnabled());
assertTrue(stored.getProcessors() == null || stored.getProcessors().isEmpty(),
"processors were " + stored.getProcessors());
}
@Test
void anUpdateThatDoesNotMentionTheBlockPreservesIt() {
service.createDeliveryStream("stream", destination(s3 -> s3.setProcessingConfiguration(
lambdaProcessing(parameter("LambdaArn", LAMBDA_ARN)))));
service.updateDestination("stream", currentVersion("stream"), DESTINATION_ID,
destination(s3 -> s3.setPrefix("changed/")));
assertEquals(List.of("LambdaArn", "NumberOfRetries", "RoleArn"), storedParameterNames("stream"));
}
// Validation runs against the update's own content, since the update replaces the
// block: a stored LambdaArn does not satisfy an update that omits one.
@Test
void anUpdateIsValidatedAgainstItsOwnContent() {
service.createDeliveryStream("stream", destination(s3 -> s3.setProcessingConfiguration(
lambdaProcessing(parameter("LambdaArn", LAMBDA_ARN)))));
AwsException error = assertThrows(AwsException.class, () -> service.updateDestination("stream",
currentVersion("stream"), DESTINATION_ID, destination(s3 -> s3.setProcessingConfiguration(
lambdaProcessing(parameter("NumberOfRetries", "7"))))));
assertEquals("LambdaArn is required when Lambda processor is used.", error.getMessage());
}
}
@@ -2,6 +2,9 @@ package io.github.hectorvent.floci.services.firehose;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription;
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.ProcessingConfiguration;
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.Processor;
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.ProcessorParameter;
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription.S3Destination;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
@@ -10,6 +13,7 @@ import org.junit.jupiter.params.provider.ValueSource;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* The error codes and messages asserted here were captured from real AWS's raw
@@ -19,6 +23,139 @@ class S3DestinationValidatorTest {
private static final String ENUM_SET = "[ZIP, HADOOP_SNAPPY, Snappy, GZIP, UNCOMPRESSED]";
private static final String PROCESSOR_TYPE_SET = "[Decompression, Lambda, RecordDeAggregation,"
+ " MetadataExtraction, AppendDelimiterToRecord, CloudWatchLogProcessing]";
private static final String PARAMETER_NAME_SET = "[DataMessageExtraction, NumberOfRetries, Delimiter,"
+ " RoleArn, JsonParsingEngine, SubRecordType, MetadataExtractionQuery,"
+ " BufferIntervalInSeconds, LambdaArn, BufferSizeInMBs, CompressionFormat]";
private static ProcessorParameter namedParameter(String name, String value) {
ProcessorParameter parameter = new ProcessorParameter();
parameter.setParameterName(name);
parameter.setParameterValue(value);
return parameter;
}
private static S3Destination withProcessors(String unusedShapeName, Processor... processors) {
ProcessingConfiguration processing = new ProcessingConfiguration();
processing.setEnabled(true);
processing.setProcessors(java.util.List.of(processors));
S3Destination config = new S3Destination();
config.setProcessingConfiguration(processing);
return config;
}
private static S3Destination withProcessor(String type, String... parameterNames) {
Processor processor = new Processor();
processor.setType(type);
java.util.List<ProcessorParameter> parameters = new java.util.ArrayList<>();
for (String name : parameterNames) {
ProcessorParameter parameter = new ProcessorParameter();
parameter.setParameterName(name);
parameter.setParameterValue("value");
parameters.add(parameter);
}
processor.setParameters(parameters);
ProcessingConfiguration processing = new ProcessingConfiguration();
processing.setEnabled(true);
processing.setProcessors(java.util.List.of(processor));
S3Destination config = new S3Destination();
config.setProcessingConfiguration(processing);
return config;
}
// The enum sets and the 1-based member paths are the ones AWS prints (probed).
@Test
void anUnknownProcessorTypeFailsItsEnum() {
AwsException error = assertThrows(AwsException.class, () -> S3DestinationValidator.validateWireShape(
withProcessor("Bogus"), "extendedS3DestinationConfiguration"));
assertEquals("1 validation error detected: Value at 'extendedS3DestinationConfiguration"
+ ".processingConfiguration.processors.1.member.type' failed to satisfy constraint:"
+ " Member must satisfy enum value set: " + PROCESSOR_TYPE_SET, error.getMessage());
}
@Test
void anUnknownParameterNameFailsItsEnum() {
AwsException error = assertThrows(AwsException.class, () -> S3DestinationValidator.validateWireShape(
withProcessor("Lambda", "LambdaArn", "Bogus"), "extendedS3DestinationUpdate"));
assertEquals("1 validation error detected: Value at 'extendedS3DestinationUpdate"
+ ".processingConfiguration.processors.1.member.parameters.2.member.parameterName'"
+ " failed to satisfy constraint: Member must satisfy enum value set: "
+ PARAMETER_NAME_SET, error.getMessage());
}
@Test
void aProcessorWithoutATypeFailsAsRequired() {
Processor processor = new Processor();
processor.setParameters(java.util.List.of(namedParameter("LambdaArn", "value")));
AwsException error = assertThrows(AwsException.class, () -> S3DestinationValidator.validateWireShape(
withProcessors("extendedS3DestinationConfiguration", processor),
"extendedS3DestinationConfiguration"));
assertEquals("1 validation error detected: Value at 'extendedS3DestinationConfiguration"
+ ".processingConfiguration.processors.1.member.type' failed to satisfy constraint:"
+ " Member must not be null", error.getMessage());
}
@Test
void aParameterMissingEitherMemberFailsAsRequired() {
Processor processor = new Processor();
processor.setType("Lambda");
processor.setParameters(java.util.List.of(new ProcessorParameter()));
AwsException error = assertThrows(AwsException.class, () -> S3DestinationValidator.validateWireShape(
withProcessors("extendedS3DestinationConfiguration", processor),
"extendedS3DestinationConfiguration"));
assertTrue(error.getMessage().contains("parameters.1.member.parameterName' failed to satisfy"
+ " constraint: Member must not be null"), error.getMessage());
assertTrue(error.getMessage().contains("parameters.1.member.parameterValue' failed to satisfy"
+ " constraint: Member must not be null"), error.getMessage());
}
// An empty value trips the length and the pattern, in that order.
@Test
void anEmptyParameterValueFailsBothItsConstraints() {
Processor processor = new Processor();
processor.setType("Lambda");
processor.setParameters(java.util.List.of(namedParameter("LambdaArn", "")));
AwsException error = assertThrows(AwsException.class, () -> S3DestinationValidator.validateWireShape(
withProcessors("extendedS3DestinationConfiguration", processor),
"extendedS3DestinationConfiguration"));
assertEquals("2 validation errors detected: Value at 'extendedS3DestinationConfiguration"
+ ".processingConfiguration.processors.1.member.parameters.1.member.parameterValue'"
+ " failed to satisfy constraint: Member must have length greater than or equal to 1;"
+ " Value at 'extendedS3DestinationConfiguration.processingConfiguration.processors.1"
+ ".member.parameters.1.member.parameterValue' failed to satisfy constraint: Member"
+ " must satisfy regular expression pattern: ^(?!\\s*$).+", error.getMessage());
}
// Probed: real AWS answers InternalFailure for a null list member. Reproducing a
// fault of its own helps nobody, and skipping the entry leaves the configuration
// the caller would have had by omitting it.
@Test
void aNullListMemberIsIgnoredRatherThanReported() {
Processor processor = new Processor();
processor.setType("Lambda");
processor.setParameters(java.util.Arrays.asList(namedParameter("LambdaArn", "value"), null));
ProcessingConfiguration processing = new ProcessingConfiguration();
processing.setEnabled(true);
processing.setProcessors(java.util.Arrays.asList(processor, null));
S3Destination config = new S3Destination();
config.setProcessingConfiguration(processing);
assertDoesNotThrow(() -> S3DestinationValidator.validateWireShape(
config, "extendedS3DestinationConfiguration"));
}
@Test
void aKnownProcessorAndParameterPass() {
assertDoesNotThrow(() -> S3DestinationValidator.validateWireShape(
withProcessor("Lambda", "LambdaArn", "NumberOfRetries"), "extendedS3DestinationConfiguration"));
}
private static S3Destination withCompressionFormat(String compressionFormat) {
S3Destination config = new S3Destination();
config.setCompressionFormat(compressionFormat);