@kensio/yulin-aws-simulation 1.15.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://anthropic.com/claude-code/plugin.schema.json",
|
|
3
3
|
"name": "yulin-aws-simulation",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.16.0",
|
|
5
5
|
"description": "How to test AWS code well with the @kensio/yulin in-process simulator.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Kensio Software",
|
package/README.md
CHANGED
|
@@ -67,6 +67,12 @@ ambiguous with the suffix Secrets Manager appends to an ARN and advised against
|
|
|
67
67
|
already reached production. It caught a wrongly computed Cognito `SECRET_HASH` the stub had happily
|
|
68
68
|
accepted.
|
|
69
69
|
|
|
70
|
+
**Drive requests into the simulation with `SimAwsHttp`.** Reading state back covers the resources.
|
|
71
|
+
`http.fetch("https://www.example.test/docs/x")` covers the path through them, with nothing listening
|
|
72
|
+
and no port to add. One request resolves the hostname through simulated Route 53, finds the
|
|
73
|
+
Distribution its alias records point at, and runs the deployed CloudFront Function at
|
|
74
|
+
viewer-request. A template assertion over the same stack passes with every Route 53 record missing.
|
|
75
|
+
|
|
70
76
|
**Match service errors by `name`.** The SDK exports its exception classes, which invites the wrong
|
|
71
77
|
check. `instanceof` holds only while exactly one copy of the SDK is in play. It passes in production
|
|
72
78
|
and fails against the simulator. `name` is what the wire carries, and is the check that is right in
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: yulin-aws-simulation
|
|
3
|
-
description: Use the @kensio/yulin in-process AWS simulator well when testing AWS code, using it directly rather than building a harness around it, driving tests, local dev and production from one synthesized CDK template, deploying a whole cdk.out cloud assembly, intercepting SDK clients with SimSdk, controlling simulated time, matching service errors by name, and handling properties Yulin refuses to simulate. Use when writing or reviewing tests that touch AWS, when replacing aws-sdk-client-mock or hand-rolled AWS stubs, when a CDK stack needs testing, when test setup around Yulin is growing helper classes or wrapper functions, and when Yulin refuses a template property or an SDK command.
|
|
3
|
+
description: Use the @kensio/yulin in-process AWS simulator well when testing AWS code, using it directly rather than building a harness around it, driving tests, local dev and production from one synthesized CDK template, deploying a whole cdk.out cloud assembly, intercepting SDK clients with SimSdk, driving HTTP requests into the simulation with SimAwsHttp, controlling simulated time, matching service errors by name, and handling properties Yulin refuses to simulate. Use when writing or reviewing tests that touch AWS, when replacing aws-sdk-client-mock or hand-rolled AWS stubs, when a CDK stack needs testing, when a CloudFront Distribution, its DNS records or its certificate need testing, when test setup around Yulin is growing helper classes or wrapper functions, and when Yulin refuses a template property or an SDK command.
|
|
4
4
|
license: Apache-2.0
|
|
5
5
|
metadata:
|
|
6
|
-
version: "1.
|
|
6
|
+
version: "1.16.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
# Testing with Yulin
|
|
@@ -213,6 +213,33 @@ scope has), so look on the other scope before concluding a service is missing. E
|
|
|
213
213
|
plain `{ input: { ... } }` in place of a Command object. An assertion can therefore read a service
|
|
214
214
|
back without adding an `@aws-sdk/client-*` package the production code has no use for.
|
|
215
215
|
|
|
216
|
+
## Drive requests into the simulation
|
|
217
|
+
|
|
218
|
+
Reading state back covers the resources. `SimAwsHttp` from `@kensio/yulin/serve` covers the path
|
|
219
|
+
through them, by sending a request into the environment with nothing listening. It takes what the
|
|
220
|
+
global `fetch` takes and answers with a `Response`:
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
const http = new SimAwsHttp({ simAws });
|
|
224
|
+
const response = await http.fetch("https://www.example.test/docs/x?a=1", { redirect: "manual" });
|
|
225
|
+
|
|
226
|
+
// Then the apex redirect the CloudFront Function performs has been applied.
|
|
227
|
+
expect(response.status).toBe(301);
|
|
228
|
+
expect(response.headers.get("location")).toBe("https://example.test/docs/x?a=1");
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
A hostname simulated Route 53 answers for is requested by its own name, with no port to add and no
|
|
232
|
+
`localUrl(...)` adapting (an `https` URL works with no certificate set up for it). That one request
|
|
233
|
+
resolves the hostname, finds the Distribution its alias records point at, and runs the deployed
|
|
234
|
+
CloudFront Function at viewer-request. The certificate, the Hosted Zone records, the Distribution's
|
|
235
|
+
aliases and the function are covered together. A template assertion over the same stack passes with
|
|
236
|
+
every Route 53 record missing.
|
|
237
|
+
|
|
238
|
+
Reach for `serveSimAws` when the request comes from outside the process, such as a browser, `curl`
|
|
239
|
+
or an SDK client pointed at a local endpoint. Both go through the same routing and service code, and
|
|
240
|
+
`SimAwsHttp` leaves parallel test files no port to collide over. See
|
|
241
|
+
[the serving docs](https://yulinsim.dev/serve/) for the API.
|
|
242
|
+
|
|
216
243
|
## Match service errors by name
|
|
217
244
|
|
|
218
245
|
```typescript
|