99 Note ,
1010 type Object ,
1111 Person ,
12+ Tombstone ,
1213} from "@fedify/vocab" ;
1314import { FetchError } from "@fedify/vocab-runtime" ;
1415import { assert , assertEquals } from "@std/assert" ;
@@ -68,6 +69,7 @@ const WRAPPER_QUOTE_CONTEXT_TERMS = {
6869
6970test ( "handleActor()" , async ( ) => {
7071 const federation = createFederation < void > ( { kv : new MemoryKvStore ( ) } ) ;
72+ const deletedAt = Temporal . Instant . from ( "2024-01-15T00:00:00Z" ) ;
7173 let context = createRequestContext < void > ( {
7274 federation,
7375 data : undefined ,
@@ -83,6 +85,13 @@ test("handleActor()", async () => {
8385 name : "Someone" ,
8486 } ) ;
8587 } ;
88+ const tombstoneDispatcher : ActorDispatcher < void > = ( ctx , identifier ) => {
89+ if ( identifier !== "gone" ) return null ;
90+ return new Tombstone ( {
91+ id : ctx . getActorUri ( identifier ) ,
92+ deleted : deletedAt ,
93+ } ) ;
94+ } ;
8695 let onNotFoundCalled : Request | null = null ;
8796 const onNotFound = ( request : Request ) => {
8897 onNotFoundCalled = request ;
@@ -294,6 +303,53 @@ test("handleActor()", async () => {
294303 } ) ;
295304 assertEquals ( onNotFoundCalled , null ) ;
296305 assertEquals ( onUnauthorizedCalled , null ) ;
306+
307+ onNotFoundCalled = null ;
308+ response = await handleActor (
309+ context . request ,
310+ {
311+ context,
312+ identifier : "gone" ,
313+ actorDispatcher : tombstoneDispatcher ,
314+ authorizePredicate : ( ) => false ,
315+ onNotFound,
316+ onUnauthorized,
317+ } ,
318+ ) ;
319+ assertEquals ( response . status , 401 ) ;
320+ assertEquals ( onNotFoundCalled , null ) ;
321+ assertEquals ( onUnauthorizedCalled , context . request ) ;
322+
323+ onUnauthorizedCalled = null ;
324+ response = await handleActor (
325+ context . request ,
326+ {
327+ context,
328+ identifier : "gone" ,
329+ actorDispatcher : tombstoneDispatcher ,
330+ authorizePredicate : ( ) => true ,
331+ onNotFound,
332+ onUnauthorized,
333+ } ,
334+ ) ;
335+ assertEquals ( response . status , 410 ) ;
336+ assertEquals (
337+ response . headers . get ( "Content-Type" ) ,
338+ "application/activity+json" ,
339+ ) ;
340+ assertEquals ( response . headers . get ( "Vary" ) , "Accept" ) ;
341+ assertEquals ( await response . json ( ) , {
342+ "@context" : [
343+ "https://www.w3.org/ns/activitystreams" ,
344+ "https://w3id.org/security/data-integrity/v1" ,
345+ "https://gotosocial.org/ns" ,
346+ ] ,
347+ id : "https://example.com/users/gone" ,
348+ type : "Tombstone" ,
349+ deleted : "2024-01-15T00:00:00Z" ,
350+ } ) ;
351+ assertEquals ( onNotFoundCalled , null ) ;
352+ assertEquals ( onUnauthorizedCalled , null ) ;
297353} ) ;
298354
299355test ( "handleObject()" , async ( ) => {
0 commit comments