@@ -28,6 +28,10 @@ async function writeSuite(content: string): Promise<string> {
2828 return path ;
2929}
3030
31+ function resolvePublicHost ( _hostname : string ) : Promise < readonly string [ ] > {
32+ return Promise . resolve ( [ "93.184.216.34" ] ) ;
33+ }
34+
3135function inboxSuite ( target : URL , expectLine : string ) : string {
3236 // Uses `${{ target.host }}` templating to form the actor URI (WebFinger is
3337 // https-only, so an acct: handle would not resolve over http loopback).
@@ -246,6 +250,7 @@ scenarios:
246250 { headers : { "content-type" : "application/json" } } ,
247251 ) ,
248252 ) ,
253+ resolveTargetAddresses : resolvePublicHost ,
249254 } ) ;
250255 assert . strictEqual ( code , 2 ) ;
251256 assert . match ( message , / a d v e r t i s e - h o s t / ) ;
@@ -306,6 +311,7 @@ scenarios:
306311 log : ( m ) => {
307312 message = m ;
308313 } ,
314+ resolveTargetAddresses : resolvePublicHost ,
309315 } ) ;
310316 assert . strictEqual ( code , 2 ) ;
311317 assert . match ( message , / p u b l i c i n b o x | a l l o w - u n s a f e - t a r g e t / ) ;
@@ -314,6 +320,57 @@ scenarios:
314320 }
315321} ) ;
316322
323+ test ( "runBench - allows a DNS-resolved private inbox off the target" , async ( ) => {
324+ const target = await spawnBenchmarkTarget ( ) ;
325+ try {
326+ const file = await writeSuite ( `version: 1
327+ target: ${ target . url . href }
328+ scenarios:
329+ - name: inbox-shared
330+ type: inbox
331+ recipient: "${ new URL ( "/users/alice" , target . url ) . href } "
332+ inbox: "https://shared.staging.example/inbox"
333+ load: { concurrency: 2 }
334+ duration: 250ms
335+ ` ) ;
336+ let code = - 1 ;
337+ let message = "" ;
338+ const resolved : string [ ] = [ ] ;
339+ await runBench (
340+ command ( {
341+ scenario : file ,
342+ advertiseHost : "127.0.0.1" ,
343+ } ) ,
344+ {
345+ exit : ( c ) => {
346+ code = c ;
347+ } ,
348+ writeOutput : ( ) => Promise . resolve ( ) ,
349+ log : ( m ) => {
350+ message = m ;
351+ } ,
352+ resolveTargetAddresses : ( hostname ) => {
353+ resolved . push ( hostname ) ;
354+ return Promise . resolve (
355+ hostname === "shared.staging.example" ? [ "10.0.0.8" ] : [ ] ,
356+ ) ;
357+ } ,
358+ fetch : ( input ) => {
359+ const url = new URL ( input instanceof Request ? input . url : input ) ;
360+ if ( url . hostname === "shared.staging.example" ) {
361+ return Promise . resolve ( new Response ( "accepted" , { status : 202 } ) ) ;
362+ }
363+ return fetch ( input ) ;
364+ } ,
365+ } ,
366+ ) ;
367+ assert . strictEqual ( code , 0 , message ) ;
368+ assert . deepStrictEqual ( resolved , [ "shared.staging.example" ] ) ;
369+ } finally {
370+ await target . close ( ) ;
371+ }
372+ } ) ;
373+
317374test ( "runBench - unsafe public inbox destination needs an explicit CLI target" , async ( ) => {
318375 const target = await spawnBenchmarkTarget ( ) ;
319376 try {
@@ -343,6 +400,7 @@ scenarios:
343400 log : ( m ) => {
344401 message = m ;
345402 } ,
403+ resolveTargetAddresses : resolvePublicHost ,
346404 } ,
347405 ) ;
348406 assert . strictEqual ( code , 2 ) ;
@@ -381,6 +439,7 @@ scenarios:
381439 log : ( m ) => {
382440 message = m ;
383441 } ,
442+ resolveTargetAddresses : resolvePublicHost ,
384443 } ,
385444 ) ;
386445 assert . strictEqual ( code , 2 ) ;
@@ -421,6 +480,7 @@ scenarios:
421480 log : ( m ) => {
422481 message = m ;
423482 } ,
483+ resolveTargetAddresses : resolvePublicHost ,
424484 fetch : ( input ) => {
425485 const url = new URL ( input instanceof Request ? input . url : input ) ;
426486 if ( url . hostname === "prod.example" ) {
0 commit comments