33
33
import software .amazon .smithy .model .traits .TimestampFormatTrait ;
34
34
import software .amazon .smithy .model .traits .TimestampFormatTrait .Format ;
35
35
import software .amazon .smithy .model .traits .XmlNamespaceTrait ;
36
+ import software .amazon .smithy .protocoltests .traits .HttpMalformedRequestTestCase ;
36
37
import software .amazon .smithy .protocoltests .traits .HttpMessageTestCase ;
37
38
import software .amazon .smithy .typescript .codegen .HttpProtocolTestGenerator ;
38
39
import software .amazon .smithy .typescript .codegen .TypeScriptSettings ;
@@ -281,7 +282,10 @@ static String getInputTimestampValueProvider(
281
282
}
282
283
283
284
static void generateProtocolTests (ProtocolGenerator generator , GenerationContext context ) {
284
- new HttpProtocolTestGenerator (context , generator , AwsProtocolUtils ::filterProtocolTests ).run ();
285
+ new HttpProtocolTestGenerator (context ,
286
+ generator ,
287
+ AwsProtocolUtils ::filterProtocolTests ,
288
+ AwsProtocolUtils ::filterMalformedRequestTests ).run ();
285
289
}
286
290
287
291
private static boolean filterProtocolTests (
@@ -299,4 +303,61 @@ private static boolean filterProtocolTests(
299
303
}
300
304
return false ;
301
305
}
306
+
307
+ private static boolean filterMalformedRequestTests (
308
+ ServiceShape service ,
309
+ OperationShape operation ,
310
+ HttpMalformedRequestTestCase testCase ,
311
+ TypeScriptSettings settings
312
+ ) {
313
+ //TODO: underflow/overflow not rejected yet
314
+ if (testCase .hasTag ("underflow/overflow" )) {
315
+ return true ;
316
+ }
317
+
318
+ //TODO: float truncation not rejected yet
319
+ if (testCase .hasTag ("float_truncation" )) {
320
+ return true ;
321
+ }
322
+
323
+ // TODO: handle timestamps
324
+ if (testCase .hasTag ("timestamp" )) {
325
+ return true ;
326
+ }
327
+
328
+ if (!testCase .getId ().matches ("^RestJsonBody\\ w+MalformedValueRejected.*" )) {
329
+ //TODO: trailing characters in untyped contexts not rejected yet
330
+ if (testCase .hasTag ("trailing_chars" ) || testCase .hasTag ("hex" )) {
331
+ return true ;
332
+ }
333
+ }
334
+
335
+ //TODO: request serialization does not verify that the request is an object
336
+ if (testCase .hasTag ("technically_valid_json_body" )) {
337
+ return true ;
338
+ }
339
+ //TODO: we don't do any union validation
340
+ if (testCase .getId ().startsWith ("RestJsonMalformedUnion" )) {
341
+ return true ;
342
+ }
343
+ //TODO: we don't do any set validation
344
+ if (testCase .getId ().startsWith ("RestJsonMalformedSet" )) {
345
+ return true ;
346
+ }
347
+ //TODO: we don't do any list validation
348
+ if (testCase .getId ().startsWith ("RestJsonBodyMalformedList" )) {
349
+ return true ;
350
+ }
351
+ //TODO: we don't validate map values
352
+ if (testCase .getId ().equals ("RestJsonBodyMalformedMapNullValue" )) {
353
+ return true ;
354
+ }
355
+ //TODO: Buffer.from isn't decoding base64 strictly.
356
+ if (testCase .getId ().equals ("RestJsonBodyMalformedBlobInvalidBase64_case1" )
357
+ || testCase .getId ().equals ("RestJsonBodyMalformedBlobInvalidBase64_case2" )) {
358
+ return true ;
359
+ }
360
+
361
+ return false ;
362
+ }
302
363
}
0 commit comments