@@ -23,34 +23,38 @@ describe("POST /@test/inbox", () => {
2323 test ( "should store a new Note object" , async ( ) => {
2424 const activityId = `https://example.com/objects/${ crypto . randomUUID ( ) } ` ;
2525
26- const response = await fetch ( `${ config . http . base_url } /users/test/inbox/` , {
27- method : "POST" ,
28- headers : {
29- "Content-Type" : "application/activity+json" ,
30- } ,
31- body : JSON . stringify ( {
32- "@context" : "https://www.w3.org/ns/activitystreams" ,
33- type : "Create" ,
34- id : activityId ,
35- actor : {
36- id : `${ config . http . base_url } /users/test` ,
37- type : "Person" ,
38- preferredUsername : "test" ,
26+ const response = await fetch (
27+ `${ config . http . base_url } /users/test/inbox/` ,
28+ {
29+ method : "POST" ,
30+ headers : {
31+ "Content-Type" : "application/activity+json" ,
32+ Origin : "http://lysand-test.localhost" ,
3933 } ,
40- to : [ "https://www.w3.org/ns/activitystreams#Public" ] ,
41- cc : [ ] ,
42- published : "2021-01-01T00:00:00.000Z" ,
43- object : {
34+ body : JSON . stringify ( {
4435 "@context" : "https://www.w3.org/ns/activitystreams" ,
45- id : "https://example.com/notes/1" ,
46- type : "Note" ,
47- content : "Hello, world!" ,
48- summary : null ,
49- inReplyTo : null ,
36+ type : "Create" ,
37+ id : activityId ,
38+ actor : {
39+ id : `${ config . http . base_url } /users/test` ,
40+ type : "Person" ,
41+ preferredUsername : "test" ,
42+ } ,
43+ to : [ "https://www.w3.org/ns/activitystreams#Public" ] ,
44+ cc : [ ] ,
5045 published : "2021-01-01T00:00:00.000Z" ,
51- } ,
52- } ) ,
53- } ) ;
46+ object : {
47+ "@context" : "https://www.w3.org/ns/activitystreams" ,
48+ id : "https://example.com/notes/1" ,
49+ type : "Note" ,
50+ content : "Hello, world!" ,
51+ summary : null ,
52+ inReplyTo : null ,
53+ published : "2021-01-01T00:00:00.000Z" ,
54+ } ,
55+ } ) ,
56+ }
57+ ) ;
5458
5559 expect ( response . status ) . toBe ( 200 ) ;
5660 expect ( response . headers . get ( "content-type" ) ) . toBe ( "application/json" ) ;
@@ -82,34 +86,38 @@ describe("POST /@test/inbox", () => {
8286 test ( "should try to update that Note object" , async ( ) => {
8387 const activityId = `https://example.com/objects/${ crypto . randomUUID ( ) } ` ;
8488
85- const response = await fetch ( `${ config . http . base_url } /users/test/inbox/` , {
86- method : "POST" ,
87- headers : {
88- "Content-Type" : "application/activity+json" ,
89- } ,
90- body : JSON . stringify ( {
91- "@context" : "https://www.w3.org/ns/activitystreams" ,
92- type : "Update" ,
93- id : activityId ,
94- actor : {
95- id : `${ config . http . base_url } /users/test` ,
96- type : "Person" ,
97- preferredUsername : "test" ,
89+ const response = await fetch (
90+ `${ config . http . base_url } /users/test/inbox/` ,
91+ {
92+ method : "POST" ,
93+ headers : {
94+ "Content-Type" : "application/activity+json" ,
95+ Origin : "http://lysand-test.localhost" ,
9896 } ,
99- to : [ "https://www.w3.org/ns/activitystreams#Public" ] ,
100- cc : [ ] ,
101- published : "2021-01-02T00:00:00.000Z" ,
102- object : {
97+ body : JSON . stringify ( {
10398 "@context" : "https://www.w3.org/ns/activitystreams" ,
104- id : "https://example.com/notes/1" ,
105- type : "Note" ,
106- content : "This note has been edited!" ,
107- summary : null ,
108- inReplyTo : null ,
109- published : "2021-01-01T00:00:00.000Z" ,
110- } ,
111- } ) ,
112- } ) ;
99+ type : "Update" ,
100+ id : activityId ,
101+ actor : {
102+ id : `${ config . http . base_url } /users/test` ,
103+ type : "Person" ,
104+ preferredUsername : "test" ,
105+ } ,
106+ to : [ "https://www.w3.org/ns/activitystreams#Public" ] ,
107+ cc : [ ] ,
108+ published : "2021-01-02T00:00:00.000Z" ,
109+ object : {
110+ "@context" : "https://www.w3.org/ns/activitystreams" ,
111+ id : "https://example.com/notes/1" ,
112+ type : "Note" ,
113+ content : "This note has been edited!" ,
114+ summary : null ,
115+ inReplyTo : null ,
116+ published : "2021-01-01T00:00:00.000Z" ,
117+ } ,
118+ } ) ,
119+ }
120+ ) ;
113121
114122 expect ( response . status ) . toBe ( 200 ) ;
115123 expect ( response . headers . get ( "content-type" ) ) . toBe ( "application/json" ) ;
@@ -140,34 +148,38 @@ describe("POST /@test/inbox", () => {
140148
141149 test ( "should delete the Note object" , async ( ) => {
142150 const activityId = `https://example.com/objects/${ crypto . randomUUID ( ) } ` ;
143- const response = await fetch ( `${ config . http . base_url } /users/test/inbox/` , {
144- method : "POST" ,
145- headers : {
146- "Content-Type" : "application/activity+json" ,
147- } ,
148- body : JSON . stringify ( {
149- "@context" : "https://www.w3.org/ns/activitystreams" ,
150- type : "Delete" ,
151- id : activityId ,
152- actor : {
153- id : `${ config . http . base_url } /users/test` ,
154- type : "Person" ,
155- preferredUsername : "test" ,
151+ const response = await fetch (
152+ `${ config . http . base_url } /users/test/inbox/` ,
153+ {
154+ method : "POST" ,
155+ headers : {
156+ "Content-Type" : "application/activity+json" ,
157+ Origin : "http://lysand-test.localhost" ,
156158 } ,
157- to : [ "https://www.w3.org/ns/activitystreams#Public" ] ,
158- cc : [ ] ,
159- published : "2021-01-03T00:00:00.000Z" ,
160- object : {
159+ body : JSON . stringify ( {
161160 "@context" : "https://www.w3.org/ns/activitystreams" ,
162- id : "https://example.com/notes/1" ,
163- type : "Note" ,
164- content : "This note has been edited!" ,
165- summary : null ,
166- inReplyTo : null ,
167- published : "2021-01-01T00:00:00.000Z" ,
168- } ,
169- } ) ,
170- } ) ;
161+ type : "Delete" ,
162+ id : activityId ,
163+ actor : {
164+ id : `${ config . http . base_url } /users/test` ,
165+ type : "Person" ,
166+ preferredUsername : "test" ,
167+ } ,
168+ to : [ "https://www.w3.org/ns/activitystreams#Public" ] ,
169+ cc : [ ] ,
170+ published : "2021-01-03T00:00:00.000Z" ,
171+ object : {
172+ "@context" : "https://www.w3.org/ns/activitystreams" ,
173+ id : "https://example.com/notes/1" ,
174+ type : "Note" ,
175+ content : "This note has been edited!" ,
176+ summary : null ,
177+ inReplyTo : null ,
178+ published : "2021-01-01T00:00:00.000Z" ,
179+ } ,
180+ } ) ,
181+ }
182+ ) ;
171183
172184 expect ( response . status ) . toBe ( 200 ) ;
173185 expect ( response . headers . get ( "content-type" ) ) . toBe ( "application/json" ) ;
@@ -226,30 +238,34 @@ describe("POST /@test/inbox", () => {
226238 test ( "should return a 404 error when trying to delete a non-existent Note object" , async ( ) => {
227239 const activityId = `https://example.com/objects/${ crypto . randomUUID ( ) } ` ;
228240
229- const response = await fetch ( `${ config . http . base_url } /users/test/inbox/` , {
230- method : "POST" ,
231- headers : {
232- "Content-Type" : "application/activity+json" ,
233- } ,
234- body : JSON . stringify ( {
235- "@context" : "https://www.w3.org/ns/activitystreams" ,
236- type : "Delete" ,
237- id : activityId ,
238- actor : {
239- id : `${ config . http . base_url } /users/test` ,
240- type : "Person" ,
241- preferredUsername : "test" ,
241+ const response = await fetch (
242+ `${ config . http . base_url } /users/test/inbox/` ,
243+ {
244+ method : "POST" ,
245+ headers : {
246+ "Content-Type" : "application/activity+json" ,
247+ Origin : "http://lysand-test.localhost" ,
242248 } ,
243- to : [ "https://www.w3.org/ns/activitystreams#Public" ] ,
244- cc : [ ] ,
245- published : "2021-01-03T00:00:00.000Z" ,
246- object : {
249+ body : JSON . stringify ( {
247250 "@context" : "https://www.w3.org/ns/activitystreams" ,
248- id : "https://example.com/notes/2345678909876543" ,
249- type : "Note" ,
250- } ,
251- } ) ,
252- } ) ;
251+ type : "Delete" ,
252+ id : activityId ,
253+ actor : {
254+ id : `${ config . http . base_url } /users/test` ,
255+ type : "Person" ,
256+ preferredUsername : "test" ,
257+ } ,
258+ to : [ "https://www.w3.org/ns/activitystreams#Public" ] ,
259+ cc : [ ] ,
260+ published : "2021-01-03T00:00:00.000Z" ,
261+ object : {
262+ "@context" : "https://www.w3.org/ns/activitystreams" ,
263+ id : "https://example.com/notes/2345678909876543" ,
264+ type : "Note" ,
265+ } ,
266+ } ) ,
267+ }
268+ ) ;
253269
254270 expect ( response . status ) . toBe ( 404 ) ;
255271 expect ( response . headers . get ( "content-type" ) ) . toBe ( "application/json" ) ;
0 commit comments