FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
plugins/compose.test.js at gh-pages · JavaScriptSolidServer/plugins · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
JavaScriptSolidServer
/
plugins
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Issues
11
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
plugins
/
compose.test.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
480 lines (435 loc) · 21.6 KB
Breadcrumbs
plugins
/
compose.test.js
Copy path
File metadata and controls
480 lines (435 loc) · 21.6 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
// The money shot: ONE JavaScript Solid Server from npm, EVERY plugin in
// this repo loaded from pure config, each surface exercised over the wire,
// pods + WAC intact beside them all.
import
{
describe
,
it
,
after
}
from
'node:test'
;
import
assert
from
'node:assert'
;
import
fs
from
'node:fs'
;
import
os
from
'node:os'
;
import
path
from
'node:path'
;
import
{
fileURLToPath
}
from
'node:url'
;
import
{
WebSocket
}
from
'ws'
;
import
{
probePort
,
startJss
}
from
'./helpers.js'
;
import
{
finalizeEvent
,
generateSecretKey
}
from
'./relay/nip01.js'
;
const
__dirname
=
path
.
dirname
(
fileURLToPath
(
new
URL
(
import
.
meta
.
url
)
)
)
;
const
at
=
(
p
)
=>
path
.
join
(
__dirname
,
p
)
;
function
openWs
(
url
,
headers
)
{
const
socket
=
new
WebSocket
(
url
,
headers
?
{
headers
}
:
undefined
)
;
return
new
Promise
(
(
resolve
,
reject
)
=>
{
const
lines
=
[
]
;
socket
.
on
(
'message'
,
(
d
)
=>
lines
.
push
(
String
(
d
)
)
)
;
socket
.
on
(
'open'
,
(
)
=>
resolve
(
{
socket
,
lines
}
)
)
;
socket
.
on
(
'error'
,
reject
)
;
}
)
;
}
function
waitFor
(
lines
,
predicate
,
timeoutMs
=
5000
)
{
return
new
Promise
(
(
resolve
,
reject
)
=>
{
const
started
=
Date
.
now
(
)
;
const
timer
=
setInterval
(
(
)
=>
{
const
hit
=
lines
.
find
(
predicate
)
;
if
(
hit
)
{
clearInterval
(
timer
)
;
resolve
(
hit
)
;
}
else
if
(
Date
.
now
(
)
-
started
>
timeoutMs
)
{
clearInterval
(
timer
)
;
reject
(
new
Error
(
`timeout; lines:
${
JSON
.
stringify
(
lines
.
slice
(
0
,
10
)
)
}
`
)
)
;
}
}
,
25
)
;
}
)
;
}
describe
(
'composition: every plugin on one server'
,
(
)
=>
{
let
jss
;
let
base
;
let
wsBase
;
after
(
async
(
)
=>
{
if
(
jss
)
await
jss
.
close
(
)
;
}
)
;
it
(
'boots pods + idp + thirty-three plugins from config'
,
async
(
)
=>
{
const
port
=
await
probePort
(
)
;
base
=
`http://127.0.0.1:
${
port
}
`
;
wsBase
=
`ws://127.0.0.1:
${
port
}
`
;
const
root
=
fs
.
mkdtempSync
(
path
.
join
(
os
.
tmpdir
(
)
,
'jss-compose-'
)
)
;
jss
=
await
startJss
(
{
port
,
root
,
idp
:
true
,
// No appPaths and no explicit ids: as of JSS 0.0.219 the protocol
// shims self-reserve their fixed roots (api.reservePath, #602) and
// the loader derives each id from the parent dir (#596 fix) — both
// operator workarounds this file used to carry, consumed.
plugins
:
[
{
module
:
at
(
'relay/plugin.js'
)
,
prefix
:
'/relay'
}
,
{
module
:
at
(
'webrtc/plugin.js'
)
,
prefix
:
'/webrtc'
}
,
{
module
:
at
(
'globs/plugin.js'
)
,
prefix
:
'/globs'
,
config
:
{
aimTimeMs
:
300
,
interRoundMs
:
0
}
}
,
{
module
:
at
(
'terminal/plugin.js'
)
,
prefix
:
'/terminal'
,
config
:
{
token
:
'compose-secret'
}
}
,
{
module
:
at
(
'tunnel/plugin.js'
)
,
prefix
:
'/tunnel'
}
,
{
module
:
at
(
'notifications/plugin.js'
)
,
prefix
:
'/.notifications'
,
config
:
{
podsRoot
:
root
,
baseUrl
:
base
}
,
}
,
{
module
:
at
(
'pay/plugin.js'
)
,
prefix
:
'/paid'
,
config
:
{
cost
:
2
,
address
:
'x'
}
}
,
{
module
:
at
(
'nip05/plugin.js'
)
,
prefix
:
'/nip05'
,
config
:
{
podsRoot
:
root
}
}
,
{
module
:
at
(
'corsproxy/plugin.js'
)
,
prefix
:
'/proxy'
,
config
:
{
}
}
,
{
module
:
at
(
'capability/plugin.js'
)
,
prefix
:
'/cap'
,
config
:
{
}
}
,
{
module
:
at
(
'webdav/plugin.js'
)
,
prefix
:
'/webdav'
,
config
:
{
baseUrl
:
base
,
loopbackUrl
:
base
}
}
,
{
module
:
at
(
'gitscratch/plugin.js'
)
,
prefix
:
'/git'
,
config
:
{
}
}
,
{
module
:
at
(
'sparql/plugin.js'
)
,
prefix
:
'/sparql'
,
config
:
{
baseUrl
:
base
,
loopbackUrl
:
base
}
}
,
{
module
:
at
(
'otp/plugin.js'
)
,
prefix
:
'/otp'
,
config
:
{
}
}
,
{
module
:
at
(
'carddav/plugin.js'
)
,
prefix
:
'/carddav'
,
config
:
{
baseUrl
:
base
,
loopbackUrl
:
base
}
}
,
{
module
:
at
(
'mastodon/plugin.js'
)
,
prefix
:
'/mastodon'
,
config
:
{
baseUrl
:
base
,
loopbackUrl
:
base
}
}
,
{
module
:
at
(
'bluesky/plugin.js'
)
,
prefix
:
'/bluesky'
,
config
:
{
baseUrl
:
base
,
loopbackUrl
:
base
}
}
,
{
module
:
at
(
'caldav/plugin.js'
)
,
prefix
:
'/caldav'
,
config
:
{
baseUrl
:
base
,
loopbackUrl
:
base
}
}
,
{
module
:
at
(
'webfinger/plugin.js'
)
,
prefix
:
'/webfinger'
,
config
:
{
podsRoot
:
root
,
baseUrl
:
base
}
}
,
{
module
:
at
(
'activitypub/plugin.js'
)
,
prefix
:
'/activitypub'
,
config
:
{
baseUrl
:
base
,
loopbackUrl
:
base
}
}
,
{
module
:
at
(
'rss/plugin.js'
)
,
prefix
:
'/feed'
,
config
:
{
baseUrl
:
base
,
loopbackUrl
:
base
}
}
,
{
module
:
at
(
'matrix/plugin.js'
)
,
prefix
:
'/matrix'
,
config
:
{
baseUrl
:
base
,
loopbackUrl
:
base
}
}
,
{
module
:
at
(
'search/plugin.js'
)
,
prefix
:
'/search'
,
config
:
{
baseUrl
:
base
,
loopbackUrl
:
base
}
}
,
{
module
:
at
(
'didweb/plugin.js'
)
,
prefix
:
'/didweb'
,
config
:
{
podsRoot
:
root
,
baseUrl
:
base
}
}
,
{
module
:
at
(
's3/plugin.js'
)
,
prefix
:
'/s3'
,
config
:
{
baseUrl
:
base
,
loopbackUrl
:
base
}
}
,
{
module
:
at
(
'micropub/plugin.js'
)
,
prefix
:
'/micropub'
,
config
:
{
baseUrl
:
base
,
loopbackUrl
:
base
}
}
,
{
module
:
at
(
'backup/plugin.js'
)
,
prefix
:
'/backup'
,
config
:
{
baseUrl
:
base
,
loopbackUrl
:
base
}
}
,
{
module
:
at
(
'shortlink/plugin.js'
)
,
prefix
:
'/short'
,
config
:
{
baseUrl
:
base
}
}
,
{
module
:
at
(
'markets/plugin.js'
)
,
prefix
:
'/predict'
,
config
:
{
baseUrl
:
base
}
}
,
{
module
:
at
(
'oembed/plugin.js'
)
,
prefix
:
'/oembed'
,
config
:
{
baseUrl
:
base
,
loopbackUrl
:
base
}
}
,
{
module
:
at
(
'jmap/plugin.js'
)
,
prefix
:
'/jmap'
,
config
:
{
baseUrl
:
base
,
loopbackUrl
:
base
}
}
,
// Zero config on purpose — gallery/ is the first plugin needing none
// (origin via api.serverInfo, container defaults to the caller's pod).
{
module
:
at
(
'gallery/plugin.js'
)
,
prefix
:
'/gallery'
}
,
{
module
:
at
(
'forge/plugin.js'
)
,
prefix
:
'/forge'
}
,
{
module
:
at
(
'recordweb/plugin.js'
)
,
prefix
:
'/recordweb'
,
config
:
{
baseUrl
:
base
,
loopbackUrl
:
base
}
}
,
{
module
:
at
(
'ripple/plugin.js'
)
,
prefix
:
'/ripple'
}
,
{
module
:
at
(
'remotestorage/plugin.js'
)
,
prefix
:
'/remotestorage'
,
// webfinger/ already owns /.well-known/webfinger on this server —
// the witnessed collision (see remotestorage/README.md) — so this
// instance stands down and serves only its own-prefix JRD.
config
:
{
baseUrl
:
base
,
loopbackUrl
:
base
,
claimWellKnown
:
false
}
,
}
,
{
module
:
at
(
'metrics/plugin.js'
)
,
prefix
:
'/metrics'
,
config
:
{
loopbackUrl
:
base
}
}
,
{
module
:
at
(
'admin/plugin.js'
)
,
prefix
:
'/admin'
,
// Auto-discovers via api.plugins (#610), origin via api.serverInfo
// (#601) — no hand-fed list, no loopbackUrl. No adminAgents → open
// mode (the plugin warns; the finding: no operator concept yet).
config
:
{
podsRoot
:
root
,
probes
:
{
relay
:
{
kind
:
'ws'
}
,
webrtc
:
{
kind
:
'ws'
}
,
terminal
:
{
kind
:
'ws'
}
,
tunnel
:
{
kind
:
'ws'
}
,
notifications
:
{
kind
:
'ws'
}
,
}
,
}
,
}
,
{
module
:
at
(
'dashboard/plugin.js'
)
,
prefix
:
'/dashboard'
,
// No hand-fed list and no loopbackUrl: the dashboard auto-discovers
// every plugin via api.plugins (#610) and reaches the host via
// api.serverInfo (#601). Only the WebSocket endpoints need a
// refinement so a plain-GET upgrade refusal reads as alive.
config
:
{
probes
:
{
relay
:
{
kind
:
'ws'
}
,
webrtc
:
{
kind
:
'ws'
}
,
terminal
:
{
kind
:
'ws'
}
,
tunnel
:
{
kind
:
'ws'
}
,
notifications
:
{
kind
:
'ws'
}
,
// admin probes every plugin on page render; hit its cheap
// healthz so the two ops consoles don't storm each other.
admin
:
{
probe
:
'/admin/healthz'
,
expect
:
[
200
]
}
,
}
,
}
,
}
,
]
,
}
)
;
assert
.
ok
(
jss
.
base
)
;
}
)
;
it
(
'relay: signed event round-trips'
,
async
(
)
=>
{
const
{
socket
,
lines
}
=
await
openWs
(
`
${
wsBase
}
/relay`
)
;
const
event
=
finalizeEvent
(
{
kind
:
1
,
content
:
'compose'
}
,
generateSecretKey
(
)
)
;
socket
.
send
(
JSON
.
stringify
(
[
'EVENT'
,
event
]
)
)
;
await
waitFor
(
lines
,
(
l
)
=>
{
const
m
=
JSON
.
parse
(
l
)
;
return
m
[
0
]
===
'OK'
&&
m
[
1
]
===
event
.
id
&&
m
[
2
]
===
true
;
}
)
;
socket
.
close
(
)
;
}
)
;
it
(
'webrtc: content-addressed room relays an offer between peers'
,
async
(
)
=>
{
// Anonymous content-addressed dialect (no credentials needed).
const
room
=
'a'
.
repeat
(
64
)
;
// hex hash "resource"
const
a
=
await
openWs
(
`
${
wsBase
}
/webrtc`
)
;
const
b
=
await
openWs
(
`
${
wsBase
}
/webrtc`
)
;
a
.
socket
.
send
(
JSON
.
stringify
(
{
type
:
'announce'
,
resource
:
room
,
offers
:
[
]
}
)
)
;
await
waitFor
(
a
.
lines
,
(
l
)
=>
JSON
.
parse
(
l
)
.
type
===
'resource-peers'
)
;
b
.
socket
.
send
(
JSON
.
stringify
(
{
type
:
'announce'
,
resource
:
room
,
offers
:
[
{
sdp
:
'compose-offer'
,
offer_id
:
'o1'
}
]
,
}
)
)
;
await
waitFor
(
a
.
lines
,
(
l
)
=>
{
const
m
=
JSON
.
parse
(
l
)
;
return
m
.
type
===
'offer'
&&
m
.
offer_id
===
'o1'
;
}
)
;
a
.
socket
.
close
(
)
;
b
.
socket
.
close
(
)
;
}
)
;
it
(
'terminal: token-gated shell echoes'
,
async
(
)
=>
{
const
socket
=
new
WebSocket
(
`
${
wsBase
}
/terminal?token=compose-secret`
)
;
let
buf
=
''
;
socket
.
on
(
'message'
,
(
d
)
=>
{
buf
+=
String
(
d
)
;
}
)
;
await
new
Promise
(
(
resolve
,
reject
)
=>
{
socket
.
on
(
'open'
,
resolve
)
;
socket
.
on
(
'error'
,
reject
)
;
}
)
;
await
new
Promise
(
(
r
)
=>
setTimeout
(
r
,
400
)
)
;
// let the shell spawn
socket
.
send
(
'echo compose-ok\n'
)
;
await
new
Promise
(
(
resolve
,
reject
)
=>
{
const
t
=
setTimeout
(
(
)
=>
reject
(
new
Error
(
`no echo; got
${
JSON
.
stringify
(
buf
)
}
`
)
)
,
5000
)
;
const
iv
=
setInterval
(
(
)
=>
{
if
(
buf
.
includes
(
'compose-ok'
)
)
{
clearTimeout
(
t
)
;
clearInterval
(
iv
)
;
resolve
(
)
;
}
}
,
25
)
;
}
)
;
socket
.
close
(
)
;
}
)
;
it
(
'notifications: pod write fans out to a subscriber'
,
async
(
)
=>
{
fs
.
writeFileSync
(
path
.
join
(
jss
.
root
,
'note.txt.acl'
)
,
`@prefix acl: <http://www.w3.org/ns/auth/acl#>.
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
<#public> a acl:Authorization; acl:agentClass foaf:Agent;
acl:accessTo <./note.txt>; acl:mode acl:Read.
`
,
)
;
const
{
socket
,
lines
}
=
await
openWs
(
`
${
wsBase
}
/.notifications`
)
;
await
waitFor
(
lines
,
(
l
)
=>
l
===
'protocol solid-0.1'
)
;
socket
.
send
(
`sub
${
base
}
/note.txt`
)
;
await
waitFor
(
lines
,
(
l
)
=>
l
===
`ack
${
base
}
/note.txt`
)
;
fs
.
writeFileSync
(
path
.
join
(
jss
.
root
,
'note.txt'
)
,
'hello'
)
;
await
waitFor
(
lines
,
(
l
)
=>
l
===
`pub
${
base
}
/note.txt`
)
;
socket
.
close
(
)
;
}
)
;
it
(
'pay: 402 then paid content'
,
async
(
)
=>
{
let
res
=
await
fetch
(
`
${
base
}
/paid/demo`
)
;
assert
.
strictEqual
(
res
.
status
,
402
)
;
res
=
await
fetch
(
`
${
base
}
/paid/demo`
,
{
headers
:
{
'x-payment-proof'
:
'demo-proof-of-payment'
}
}
)
;
assert
.
strictEqual
(
res
.
status
,
200
)
;
}
)
;
it
(
'nip05: serves the discovery document'
,
async
(
)
=>
{
const
res
=
await
fetch
(
`
${
base
}
/nip05/nostr.json`
)
;
assert
.
strictEqual
(
res
.
status
,
200
)
;
assert
.
ok
(
'names'
in
(
await
res
.
json
(
)
)
)
;
}
)
;
it
(
'corsproxy: refuses a missing/blocked target but is alive'
,
async
(
)
=>
{
const
res
=
await
fetch
(
`
${
base
}
/proxy`
)
;
// no ?url
assert
.
strictEqual
(
res
.
status
,
400
)
;
}
)
;
it
(
'capability: minting requires identity (401 anon)'
,
async
(
)
=>
{
const
res
=
await
fetch
(
`
${
base
}
/cap/issue`
,
{
method
:
'POST'
,
headers
:
{
'content-type'
:
'application/json'
}
,
body
:
JSON
.
stringify
(
{
resource
:
'/cap/x'
,
modes
:
[
'read'
]
,
ttl
:
60
}
)
,
}
)
;
assert
.
strictEqual
(
res
.
status
,
401
)
;
}
)
;
it
(
'webdav: OPTIONS advertises DAV class 1'
,
async
(
)
=>
{
const
res
=
await
fetch
(
`
${
base
}
/webdav/`
,
{
method
:
'OPTIONS'
}
)
;
assert
.
ok
(
res
.
status
<
500
)
;
assert
.
match
(
res
.
headers
.
get
(
'dav'
)
||
''
,
/
1
/
)
;
}
)
;
it
(
'gitscratch: an anonymous push is refused'
,
async
(
)
=>
{
const
res
=
await
fetch
(
`
${
base
}
/git/probe.git/info/refs?service=git-receive-pack`
)
;
assert
.
strictEqual
(
res
.
status
,
401
)
;
}
)
;
it
(
'sparql: rejects a non-sparql content type (415)'
,
async
(
)
=>
{
const
res
=
await
fetch
(
`
${
base
}
/sparql`
,
{
method
:
'POST'
,
headers
:
{
'content-type'
:
'text/plain'
}
,
body
:
'nope'
,
}
)
;
assert
.
ok
(
[
400
,
415
]
.
includes
(
res
.
status
)
,
`got
${
res
.
status
}
`
)
;
}
)
;
it
(
'otp: whoami without a session token is 401'
,
async
(
)
=>
{
const
res
=
await
fetch
(
`
${
base
}
/otp/whoami`
)
;
assert
.
strictEqual
(
res
.
status
,
401
)
;
}
)
;
it
(
'carddav: OPTIONS advertises the addressbook'
,
async
(
)
=>
{
const
res
=
await
fetch
(
`
${
base
}
/carddav/`
,
{
method
:
'OPTIONS'
}
)
;
assert
.
ok
(
res
.
status
<
500
)
;
assert
.
match
(
res
.
headers
.
get
(
'dav'
)
||
''
,
/
a
d
d
r
e
s
s
b
o
o
k
/
)
;
}
)
;
it
(
'mastodon: the instance endpoint answers (fixed /api root, self-reserved)'
,
async
(
)
=>
{
const
res
=
await
fetch
(
`
${
base
}
/api/v1/instance`
)
;
assert
.
strictEqual
(
res
.
status
,
200
)
;
assert
.
ok
(
'title'
in
(
await
res
.
json
(
)
)
)
;
}
)
;
it
(
'bluesky: the XRPC describeServer answers (fixed /xrpc root)'
,
async
(
)
=>
{
const
res
=
await
fetch
(
`
${
base
}
/xrpc/com.atproto.server.describeServer`
)
;
assert
.
strictEqual
(
res
.
status
,
200
)
;
}
)
;
it
(
'caldav: OPTIONS advertises calendar-access'
,
async
(
)
=>
{
const
res
=
await
fetch
(
`
${
base
}
/caldav/`
,
{
method
:
'OPTIONS'
}
)
;
assert
.
ok
(
res
.
status
<
500
)
;
assert
.
match
(
res
.
headers
.
get
(
'dav'
)
||
''
,
/
c
a
l
e
n
d
a
r
-
a
c
c
e
s
s
/
)
;
}
)
;
it
(
'webfinger: missing resource is 400 (endpoint alive)'
,
async
(
)
=>
{
const
res
=
await
fetch
(
`
${
base
}
/.well-known/webfinger`
)
;
assert
.
strictEqual
(
res
.
status
,
400
)
;
}
)
;
it
(
'activitypub: unauthenticated outbox POST is refused'
,
async
(
)
=>
{
const
res
=
await
fetch
(
`
${
base
}
/ap/alice/outbox`
,
{
method
:
'POST'
,
headers
:
{
'content-type'
:
'application/activity+json'
}
,
body
:
JSON
.
stringify
(
{
type
:
'Note'
,
content
:
'x'
}
)
,
}
)
;
assert
.
strictEqual
(
res
.
status
,
401
)
;
}
)
;
it
(
'rss: missing container is 400 (endpoint alive)'
,
async
(
)
=>
{
const
res
=
await
fetch
(
`
${
base
}
/feed/atom`
)
;
assert
.
strictEqual
(
res
.
status
,
400
)
;
}
)
;
it
(
'matrix: the versions endpoint answers (fixed /_matrix root)'
,
async
(
)
=>
{
const
res
=
await
fetch
(
`
${
base
}
/_matrix/client/versions`
)
;
assert
.
strictEqual
(
res
.
status
,
200
)
;
}
)
;
it
(
'search: missing query is 400 (endpoint alive)'
,
async
(
)
=>
{
const
res
=
await
fetch
(
`
${
base
}
/search`
)
;
assert
.
strictEqual
(
res
.
status
,
400
)
;
}
)
;
it
(
'didweb: unknown pod DID is 404 (resolver alive)'
,
async
(
)
=>
{
const
res
=
await
fetch
(
`
${
base
}
/didweb/nobody/did.json`
)
;
assert
.
strictEqual
(
res
.
status
,
404
)
;
}
)
;
it
(
's3: an unauthenticated object GET is denied (gateway alive)'
,
async
(
)
=>
{
const
res
=
await
fetch
(
`
${
base
}
/s3/bucket/key`
)
;
assert
.
strictEqual
(
res
.
status
,
403
)
;
}
)
;
it
(
'micropub: q=config answers; unauthenticated POST is 401'
,
async
(
)
=>
{
let
res
=
await
fetch
(
`
${
base
}
/micropub?q=config`
)
;
assert
.
strictEqual
(
res
.
status
,
200
)
;
assert
.
ok
(
'syndicate-to'
in
(
await
res
.
json
(
)
)
)
;
res
=
await
fetch
(
`
${
base
}
/micropub`
,
{
method
:
'POST'
,
headers
:
{
'content-type'
:
'application/x-www-form-urlencoded'
}
,
body
:
'h=entry&content=compose'
,
}
)
;
assert
.
strictEqual
(
res
.
status
,
401
)
;
}
)
;
it
(
'backup: bare GET is 400 with usage (no whole-server export)'
,
async
(
)
=>
{
const
res
=
await
fetch
(
`
${
base
}
/backup`
)
;
assert
.
strictEqual
(
res
.
status
,
400
)
;
}
)
;
it
(
'shortlink: anonymous mint is 401; unknown slug is 404'
,
async
(
)
=>
{
let
res
=
await
fetch
(
`
${
base
}
/short`
,
{
method
:
'POST'
,
headers
:
{
'content-type'
:
'application/json'
}
,
body
:
JSON
.
stringify
(
{
url
:
`
${
base
}
/x`
}
)
,
}
)
;
assert
.
strictEqual
(
res
.
status
,
401
)
;
res
=
await
fetch
(
`
${
base
}
/short/nosuchslug`
,
{
redirect
:
'manual'
}
)
;
assert
.
strictEqual
(
res
.
status
,
404
)
;
}
)
;
it
(
'markets: public list is 200, anonymous trade is 401, UI serves'
,
async
(
)
=>
{
let
res
=
await
fetch
(
`
${
base
}
/predict/api/markets`
)
;
assert
.
strictEqual
(
res
.
status
,
200
)
;
assert
.
deepStrictEqual
(
await
res
.
json
(
)
,
{
markets
:
[
]
,
total
:
0
,
nextCursor
:
null
}
)
;
res
=
await
fetch
(
`
${
base
}
/predict/api/me`
)
;
assert
.
strictEqual
(
res
.
status
,
401
)
;
res
=
await
fetch
(
`
${
base
}
/predict`
)
;
assert
.
strictEqual
(
res
.
status
,
200
)
;
assert
.
match
(
res
.
headers
.
get
(
'content-type'
)
,
/
t
e
x
t
\/
h
t
m
l
/
)
;
}
)
;
it
(
'oembed: missing url is 400 (endpoint alive, never fetches external)'
,
async
(
)
=>
{
const
res
=
await
fetch
(
`
${
base
}
/oembed`
)
;
assert
.
strictEqual
(
res
.
status
,
400
)
;
}
)
;
it
(
'forge: the repo list answers; an anonymous push is refused'
,
async
(
)
=>
{
const
page
=
await
fetch
(
`
${
base
}
/forge/`
)
;
assert
.
strictEqual
(
page
.
status
,
200
)
;
assert
.
match
(
page
.
headers
.
get
(
'content-type'
)
||
''
,
/
t
e
x
t
\/
h
t
m
l
/
)
;
const
api
=
await
fetch
(
`
${
base
}
/forge/api/repos`
)
;
assert
.
strictEqual
(
api
.
status
,
200
)
;
assert
.
ok
(
Array
.
isArray
(
(
await
api
.
json
(
)
)
.
repos
)
)
;
const
push
=
await
fetch
(
`
${
base
}
/forge/nobody/x.git/info/refs?service=git-receive-pack`
)
;
assert
.
strictEqual
(
push
.
status
,
401
)
;
}
)
;
it
(
'gallery: the page answers anonymously; an anonymous upload is refused'
,
async
(
)
=>
{
const
page
=
await
fetch
(
`
${
base
}
/gallery`
)
;
assert
.
strictEqual
(
page
.
status
,
200
)
;
assert
.
match
(
page
.
headers
.
get
(
'content-type'
)
||
''
,
/
t
e
x
t
\/
h
t
m
l
/
)
;
const
up
=
await
fetch
(
`
${
base
}
/gallery/upload/x.png`
,
{
method
:
'POST'
,
body
:
'nope'
}
)
;
assert
.
ok
(
[
401
,
403
]
.
includes
(
up
.
status
)
,
`anon upload:
${
up
.
status
}
`
)
;
}
)
;
it
(
'ripple: the UI answers; an anonymous trustline is refused'
,
async
(
)
=>
{
const
page
=
await
fetch
(
`
${
base
}
/ripple`
)
;
assert
.
strictEqual
(
page
.
status
,
200
)
;
assert
.
match
(
page
.
headers
.
get
(
'content-type'
)
||
''
,
/
t
e
x
t
\/
h
t
m
l
/
)
;
const
tl
=
await
fetch
(
`
${
base
}
/ripple/api/trustlines`
,
{
method
:
'POST'
,
headers
:
{
'content-type'
:
'application/json'
}
,
body
:
JSON
.
stringify
(
{
peer
:
'x'
,
currency
:
'USD'
,
limit
:
1
}
)
,
}
)
;
assert
.
strictEqual
(
tl
.
status
,
401
,
`anon trustline:
${
tl
.
status
}
`
)
;
}
)
;
it
(
'recordweb: the resolver-discovery doc answers; an anonymous Record create is refused'
,
async
(
)
=>
{
const
wk
=
await
fetch
(
`
${
base
}
/.well-known/rwp-resolver.json`
)
;
assert
.
strictEqual
(
wk
.
status
,
200
)
;
assert
.
strictEqual
(
(
await
wk
.
json
(
)
)
.
v
,
'rwp1'
)
;
const
create
=
await
fetch
(
`
${
base
}
/recordweb/records`
,
{
method
:
'POST'
,
headers
:
{
'content-type'
:
'application/json'
}
,
body
:
JSON
.
stringify
(
{
payload
:
{
x
:
1
}
}
)
,
}
)
;
assert
.
strictEqual
(
create
.
status
,
401
,
`anon create:
${
create
.
status
}
`
)
;
}
)
;
it
(
'jmap: anonymous session is 401; /.well-known/jmap redirects to it'
,
async
(
)
=>
{
let
res
=
await
fetch
(
`
${
base
}
/jmap/session`
)
;
assert
.
strictEqual
(
res
.
status
,
401
)
;
res
=
await
fetch
(
`
${
base
}
/.well-known/jmap`
,
{
redirect
:
'manual'
}
)
;
assert
.
strictEqual
(
res
.
status
,
301
)
;
}
)
;
it
(
'remotestorage: own-prefix webfinger answers (well-known stood down to webfinger/)'
,
async
(
)
=>
{
const
res
=
await
fetch
(
`
${
base
}
/remotestorage/webfinger`
)
;
assert
.
strictEqual
(
res
.
status
,
400
)
;
// missing ?resource — endpoint alive
}
)
;
it
(
'admin: auto-discovers plugins (api.plugins) and reports pods stats'
,
async
(
)
=>
{
let
res
=
await
fetch
(
`
${
base
}
/admin/`
)
;
assert
.
strictEqual
(
res
.
status
,
200
)
;
const
page
=
await
res
.
text
(
)
;
for
(
const
id
of
[
'nip05'
,
'metrics'
,
'rss'
,
's3'
]
)
assert
.
ok
(
page
.
includes
(
id
)
,
id
)
;
res
=
await
fetch
(
`
${
base
}
/admin/status.json`
)
;
assert
.
strictEqual
(
res
.
status
,
200
)
;
const
status
=
await
res
.
json
(
)
;
assert
.
strictEqual
(
status
.
server
.
alive
,
true
)
;
// Discovered ~every sibling, not a hand-fed few.
assert
.
ok
(
status
.
plugins
.
length
>=
25
,
`discovered only
${
status
.
plugins
.
length
}
`
)
;
const
byId
=
Object
.
fromEntries
(
status
.
plugins
.
map
(
(
p
)
=>
[
p
.
id
,
p
]
)
)
;
for
(
const
id
of
[
'nip05'
,
'rss'
,
'mastodon'
,
's3'
,
'metrics'
]
)
{
assert
.
ok
(
byId
[
id
]
?.
alive
,
`
${
id
}
:
${
JSON
.
stringify
(
byId
[
id
]
)
}
`
)
;
}
// podsRoot configured → pod stats present.
assert
.
ok
(
status
.
pods
&&
typeof
status
.
pods
.
count
===
'number'
,
JSON
.
stringify
(
status
.
pods
)
)
;
}
)
;
it
(
'metrics: healthz is ok and the exposition names the process gauges'
,
async
(
)
=>
{
let
res
=
await
fetch
(
`
${
base
}
/metrics/healthz`
)
;
assert
.
strictEqual
(
res
.
status
,
200
)
;
assert
.
strictEqual
(
(
await
res
.
json
(
)
)
.
status
,
'ok'
)
;
res
=
await
fetch
(
`
${
base
}
/metrics/metrics`
)
;
assert
.
strictEqual
(
res
.
status
,
200
)
;
assert
.
match
(
await
res
.
text
(
)
,
/
p
r
o
c
e
s
s
_
u
p
t
i
m
e
_
s
e
c
o
n
d
s
/
)
;
}
)
;
it
(
'dashboard: auto-discovers every plugin via api.plugins; status.json probes live'
,
async
(
)
=>
{
let
res
=
await
fetch
(
`
${
base
}
/dashboard/`
)
;
assert
.
strictEqual
(
res
.
status
,
200
)
;
const
page
=
await
res
.
text
(
)
;
// Auto-discovered, not a hand-fed three — a broad sample must appear.
for
(
const
id
of
[
'nip05'
,
'rss'
,
'relay'
,
's3'
,
'micropub'
,
'metrics'
]
)
{
assert
.
ok
(
page
.
includes
(
id
)
,
id
)
;
}
res
=
await
fetch
(
`
${
base
}
/dashboard/status.json`
)
;
assert
.
strictEqual
(
res
.
status
,
200
)
;
const
status
=
await
res
.
json
(
)
;
assert
.
strictEqual
(
status
.
server
.
alive
,
true
)
;
// Discovered ~every sibling (minus itself), far more than a curated list.
assert
.
ok
(
status
.
plugins
.
length
>=
25
,
`discovered only
${
status
.
plugins
.
length
}
`
)
;
// The well-understood HTTP plugins answer <500 at their prefix → alive.
const
byId
=
Object
.
fromEntries
(
status
.
plugins
.
map
(
(
p
)
=>
[
p
.
id
,
p
]
)
)
;
for
(
const
id
of
[
'nip05'
,
'rss'
,
'mastodon'
,
's3'
,
'micropub'
,
'backup'
,
'metrics'
]
)
{
assert
.
strictEqual
(
byId
[
id
]
?.
alive
,
true
,
`
${
id
}
:
${
JSON
.
stringify
(
byId
[
id
]
)
}
`
)
;
}
}
)
;
it
(
'pods still work beside all of it (idp register + WAC)'
,
async
(
)
=>
{
let
res
=
await
fetch
(
`
${
base
}
/idp/register`
,
{
method
:
'POST'
,
headers
:
{
'content-type'
:
'application/json'
}
,
body
:
JSON
.
stringify
(
{
username
:
'composer'
,
password
:
'compose-pass'
,
confirmPassword
:
'compose-pass'
}
)
,
}
)
;
assert
.
ok
(
res
.
status
<
400
,
`register:
${
res
.
status
}
`
)
;
res
=
await
fetch
(
`
${
base
}
/composer/private/x`
,
{
method
:
'PUT'
,
body
:
'nope'
}
)
;
assert
.
ok
(
[
401
,
403
]
.
includes
(
res
.
status
)
,
`WAC:
${
res
.
status
}
`
)
;
}
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL