forked from smithy-lang/smithy-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a generator for @httpMalformedRequestTests
@httpMalformedRequestTests allow server implementations to generate tests that exercise how the implementation deals with requests that are rejected before they reach the customer's business logic. See smithy-lang/smithy#871 for more information.
- Loading branch information
1 parent
1027aa8
commit 5e1db33
Showing
2 changed files
with
185 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...urces/software/amazon/smithy/typescript/codegen/malformed-request-test-regex-json-stub.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* Returns 'true' if the 'message' field in the serialized JSON document matches the given regex. | ||
*/ | ||
const matchMessageInJsonBody = (body: string, messageRegex: string): Object => { | ||
const parsedBody = JSON.parse(body); | ||
if (!parsedBody.hasOwnProperty("message")) { | ||
return false; | ||
} | ||
return new RegExp(messageRegex).test(parsedBody["message"]); | ||
} |