@evanp/activitypub-bot 0.12.1 → 0.13.1
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.
- package/lib/app.js +19 -1
- package/lib/index.js +2 -0
- package/lib/routes/collection.js +83 -67
- package/lib/routes/inbox.js +8 -0
- package/lib/routes/object.js +25 -5
- package/package.json +3 -3
- package/.github/dependabot.yml +0 -11
- package/.github/workflows/main.yml +0 -34
- package/.github/workflows/tag.yml +0 -106
- package/.nvmrc +0 -1
- package/Dockerfile +0 -17
- package/docs/activitypub.bot.drawio +0 -110
- package/tests/activitydistributor.test.js +0 -606
- package/tests/activityhandler.test.js +0 -2276
- package/tests/activitypubclient.test.js +0 -210
- package/tests/actorstorage.test.js +0 -283
- package/tests/app.test.js +0 -17
- package/tests/authorizer.test.js +0 -301
- package/tests/bot.donothing.test.js +0 -30
- package/tests/bot.ok.test.js +0 -101
- package/tests/botcontext.test.js +0 -720
- package/tests/botdatastorage.test.js +0 -88
- package/tests/botfactory.provincebotfactory.test.js +0 -430
- package/tests/digester.test.js +0 -56
- package/tests/fixtures/bots.js +0 -27
- package/tests/fixtures/eventloggingbot.js +0 -57
- package/tests/fixtures/provincebotfactory.js +0 -53
- package/tests/httpsignature.test.js +0 -199
- package/tests/httpsignatureauthenticator.test.js +0 -463
- package/tests/index.test.js +0 -10
- package/tests/keystorage.test.js +0 -124
- package/tests/microsyntax.test.js +0 -123
- package/tests/objectcache.test.js +0 -133
- package/tests/objectstorage.test.js +0 -149
- package/tests/remotekeystorage.test.js +0 -78
- package/tests/routes.actor.test.js +0 -214
- package/tests/routes.collection.test.js +0 -433
- package/tests/routes.health.test.js +0 -41
- package/tests/routes.inbox.test.js +0 -136
- package/tests/routes.object.test.js +0 -525
- package/tests/routes.server.test.js +0 -69
- package/tests/routes.sharedinbox.test.js +0 -473
- package/tests/routes.webfinger.test.js +0 -68
- package/tests/urlformatter.test.js +0 -164
- package/tests/utils/digest.js +0 -7
- package/tests/utils/nock.js +0 -499
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import { describe, it } from 'node:test'
|
|
2
|
-
import assert from 'node:assert'
|
|
3
|
-
import { makeApp } from '../lib/app.js'
|
|
4
|
-
import request from 'supertest'
|
|
5
|
-
import bots from './fixtures/bots.js'
|
|
6
|
-
|
|
7
|
-
describe('actor routes', async () => {
|
|
8
|
-
const databaseUrl = 'sqlite::memory:'
|
|
9
|
-
const origin = 'https://activitypubbot.test'
|
|
10
|
-
const app = await makeApp(databaseUrl, origin, bots, 'silent')
|
|
11
|
-
|
|
12
|
-
describe('GET /user/{botid}', async () => {
|
|
13
|
-
let response = null
|
|
14
|
-
it('should work without an error', async () => {
|
|
15
|
-
response = await request(app).get('/user/ok')
|
|
16
|
-
})
|
|
17
|
-
it('should return 200 OK', async () => {
|
|
18
|
-
assert.strictEqual(response.status, 200)
|
|
19
|
-
})
|
|
20
|
-
it('should return AS2', async () => {
|
|
21
|
-
assert.strictEqual(response.type, 'application/activity+json')
|
|
22
|
-
})
|
|
23
|
-
it('should return an object', async () => {
|
|
24
|
-
assert.strictEqual(typeof response.body, 'object')
|
|
25
|
-
})
|
|
26
|
-
it('should return an object with an id', async () => {
|
|
27
|
-
assert.strictEqual(typeof response.body.id, 'string')
|
|
28
|
-
})
|
|
29
|
-
it('should return an object with an id matching the request', async () => {
|
|
30
|
-
assert.strictEqual(response.body.id, origin + '/user/ok')
|
|
31
|
-
})
|
|
32
|
-
it('should return an object with a type', async () => {
|
|
33
|
-
assert.strictEqual(typeof response.body.type, 'string')
|
|
34
|
-
})
|
|
35
|
-
it('should return an object with a type matching the request', async () => {
|
|
36
|
-
assert.strictEqual(response.body.type, 'Service')
|
|
37
|
-
})
|
|
38
|
-
it('should return an object with a preferredUsername', async () => {
|
|
39
|
-
assert.strictEqual(typeof response.body.preferredUsername, 'string')
|
|
40
|
-
})
|
|
41
|
-
it('should return an object with a preferredUsername matching the request', async () => {
|
|
42
|
-
assert.strictEqual(response.body.preferredUsername, 'ok')
|
|
43
|
-
})
|
|
44
|
-
it('should return an object with an inbox', async () => {
|
|
45
|
-
assert.strictEqual(typeof response.body.inbox, 'string')
|
|
46
|
-
})
|
|
47
|
-
it('should return an object with an outbox', async () => {
|
|
48
|
-
assert.strictEqual(typeof response.body.outbox, 'string')
|
|
49
|
-
})
|
|
50
|
-
it('should return an object with a followers', async () => {
|
|
51
|
-
assert.strictEqual(typeof response.body.followers, 'string')
|
|
52
|
-
})
|
|
53
|
-
it('should return an object with a following', async () => {
|
|
54
|
-
assert.strictEqual(typeof response.body.following, 'string')
|
|
55
|
-
})
|
|
56
|
-
it('should return an object with a liked', async () => {
|
|
57
|
-
assert.strictEqual(typeof response.body.liked, 'string')
|
|
58
|
-
})
|
|
59
|
-
it('should return an object with a to', async () => {
|
|
60
|
-
assert.strictEqual(typeof response.body.to, 'string')
|
|
61
|
-
})
|
|
62
|
-
it('should return an object with a to matching the request', async () => {
|
|
63
|
-
assert.strictEqual(response.body.to, 'as:Public')
|
|
64
|
-
})
|
|
65
|
-
it('should return an object with a summary', async () => {
|
|
66
|
-
assert.strictEqual(typeof response.body.summary, 'string')
|
|
67
|
-
})
|
|
68
|
-
it('should return an object with a summary matching the request', async () => {
|
|
69
|
-
assert.strictEqual(response.body.summary, 'A bot that says "OK" when mentioned.')
|
|
70
|
-
})
|
|
71
|
-
it('should return an object with a name', async () => {
|
|
72
|
-
assert.strictEqual(typeof response.body.name, 'string')
|
|
73
|
-
})
|
|
74
|
-
it('should return an object with a name matching the request', async () => {
|
|
75
|
-
assert.strictEqual(response.body.name, 'OK Bot')
|
|
76
|
-
})
|
|
77
|
-
it('should return an object with a publicKey', async () => {
|
|
78
|
-
assert.strictEqual(typeof response.body.publicKey, 'object')
|
|
79
|
-
assert.ok(response.body.publicKey)
|
|
80
|
-
})
|
|
81
|
-
it('should return an object with a publicKey matching the request', async () => {
|
|
82
|
-
assert.strictEqual(response.body.publicKey.id, origin + '/user/ok/publickey')
|
|
83
|
-
})
|
|
84
|
-
it('should return an object with a publicKey with an owner matching the request', async () => {
|
|
85
|
-
assert.strictEqual(response.body.publicKey.owner, origin + '/user/ok')
|
|
86
|
-
})
|
|
87
|
-
it('should return an object with a publicKey with a type', async () => {
|
|
88
|
-
assert.strictEqual(response.body.publicKey.type, 'CryptographicKey')
|
|
89
|
-
})
|
|
90
|
-
it('should return an object with a publicKey with a to', async () => {
|
|
91
|
-
assert.strictEqual(response.body.publicKey.to, 'as:Public')
|
|
92
|
-
})
|
|
93
|
-
it('should return an object with a publicKey with a publicKeyPem', async () => {
|
|
94
|
-
assert.strictEqual(typeof response.body.publicKey.publicKeyPem, 'string')
|
|
95
|
-
})
|
|
96
|
-
it('publicKeyPem should be an RSA PKCS-8 key', async () => {
|
|
97
|
-
assert.match(response.body.publicKey.publicKeyPem, /^-----BEGIN PUBLIC KEY-----\n/)
|
|
98
|
-
assert.match(response.body.publicKey.publicKeyPem, /\n-----END PUBLIC KEY-----\n$/)
|
|
99
|
-
})
|
|
100
|
-
it('should include endpoints', async () => {
|
|
101
|
-
assert.strictEqual(typeof response.body.endpoints, 'object')
|
|
102
|
-
})
|
|
103
|
-
it('should include a sharedInbox endpoint', async () => {
|
|
104
|
-
assert.strictEqual(typeof response.body.endpoints.sharedInbox, 'string')
|
|
105
|
-
})
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
describe('GET non-existent user', async () => {
|
|
109
|
-
let response = null
|
|
110
|
-
it('should work without an error', async () => {
|
|
111
|
-
response = await request(app).get('/user/dne')
|
|
112
|
-
})
|
|
113
|
-
it('should return 404 Not Found', async () => {
|
|
114
|
-
assert.strictEqual(response.status, 404)
|
|
115
|
-
})
|
|
116
|
-
it('should return Problem Details JSON', async () => {
|
|
117
|
-
assert.strictEqual(response.type, 'application/problem+json')
|
|
118
|
-
})
|
|
119
|
-
it('should return an object', async () => {
|
|
120
|
-
assert.strictEqual(typeof response.body, 'object')
|
|
121
|
-
})
|
|
122
|
-
it('should return an object with a type', async () => {
|
|
123
|
-
assert.strictEqual(typeof response.body.type, 'string')
|
|
124
|
-
})
|
|
125
|
-
it('should return an object with an type matching the request', async () => {
|
|
126
|
-
assert.strictEqual(response.body.type, 'about:blank')
|
|
127
|
-
})
|
|
128
|
-
it('should return an object with a title', async () => {
|
|
129
|
-
assert.strictEqual(typeof response.body.title, 'string')
|
|
130
|
-
})
|
|
131
|
-
it('should return an object with a title matching the request', async () => {
|
|
132
|
-
assert.strictEqual(response.body.title, 'Not Found')
|
|
133
|
-
})
|
|
134
|
-
it('should return an object with a status', async () => {
|
|
135
|
-
assert.strictEqual(typeof response.body.status, 'number')
|
|
136
|
-
})
|
|
137
|
-
it('should return an object with a status matching the request', async () => {
|
|
138
|
-
assert.strictEqual(response.body.status, 404)
|
|
139
|
-
})
|
|
140
|
-
it('should return an object with a detail', async () => {
|
|
141
|
-
assert.strictEqual(typeof response.body.detail, 'string')
|
|
142
|
-
})
|
|
143
|
-
it('should return an object with a detail matching the request', async () => {
|
|
144
|
-
assert.strictEqual(response.body.detail, 'User dne not found')
|
|
145
|
-
})
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
describe('GET /user/{dne}/publickey', async () => {
|
|
149
|
-
let response = null
|
|
150
|
-
it('should work without an error', async () => {
|
|
151
|
-
response = await request(app).get('/user/dne')
|
|
152
|
-
})
|
|
153
|
-
it('should return 404 Not Found', async () => {
|
|
154
|
-
assert.strictEqual(response.status, 404)
|
|
155
|
-
})
|
|
156
|
-
it('should return Problem Details JSON', async () => {
|
|
157
|
-
assert.strictEqual(response.type, 'application/problem+json')
|
|
158
|
-
})
|
|
159
|
-
it('should return the right object', async () => {
|
|
160
|
-
assert.strictEqual(typeof response.body, 'object')
|
|
161
|
-
assert.strictEqual(response.body.type, 'about:blank')
|
|
162
|
-
assert.strictEqual(response.body.title, 'Not Found')
|
|
163
|
-
assert.strictEqual(response.body.status, 404)
|
|
164
|
-
assert.strictEqual(response.body.detail, 'User dne not found')
|
|
165
|
-
})
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
describe('GET /user/{botid}/publickey', async () => {
|
|
169
|
-
let response = null
|
|
170
|
-
it('should work without an error', async () => {
|
|
171
|
-
response = await request(app).get('/user/ok/publickey')
|
|
172
|
-
})
|
|
173
|
-
it('should return 200 OK', async () => {
|
|
174
|
-
assert.strictEqual(response.status, 200)
|
|
175
|
-
})
|
|
176
|
-
it('should return AS2', async () => {
|
|
177
|
-
assert.strictEqual(response.type, 'application/activity+json')
|
|
178
|
-
})
|
|
179
|
-
it('should return an object', async () => {
|
|
180
|
-
assert.strictEqual(typeof response.body, 'object')
|
|
181
|
-
})
|
|
182
|
-
it('should return an object with an id', async () => {
|
|
183
|
-
assert.strictEqual(typeof response.body.id, 'string')
|
|
184
|
-
})
|
|
185
|
-
it('should return an object with the requested public key id', async () => {
|
|
186
|
-
assert.strictEqual(response.body.id, origin + '/user/ok/publickey')
|
|
187
|
-
})
|
|
188
|
-
it('should return an object with an owner', async () => {
|
|
189
|
-
assert.strictEqual(typeof response.body.owner, 'string')
|
|
190
|
-
})
|
|
191
|
-
it('should return an object with the bot as owner', async () => {
|
|
192
|
-
assert.strictEqual(response.body.owner, origin + '/user/ok')
|
|
193
|
-
})
|
|
194
|
-
it('should return an object with a publicKeyPem', async () => {
|
|
195
|
-
assert.strictEqual(typeof response.body.publicKeyPem, 'string')
|
|
196
|
-
})
|
|
197
|
-
it('publicKeyPem should be an RSA PKCS-8 key', async () => {
|
|
198
|
-
assert.match(response.body.publicKeyPem, /^-----BEGIN PUBLIC KEY-----\n/)
|
|
199
|
-
assert.match(response.body.publicKeyPem, /\n-----END PUBLIC KEY-----\n$/)
|
|
200
|
-
})
|
|
201
|
-
it('should return an object with a type', async () => {
|
|
202
|
-
assert.strictEqual(typeof response.body.type, 'string')
|
|
203
|
-
})
|
|
204
|
-
it('should return an object with a type matching the request', async () => {
|
|
205
|
-
assert.strictEqual(response.body.type, 'CryptographicKey')
|
|
206
|
-
})
|
|
207
|
-
it('should return an object with a to', async () => {
|
|
208
|
-
assert.strictEqual(typeof response.body.to, 'string')
|
|
209
|
-
})
|
|
210
|
-
it('should return an object with a to matching the request', async () => {
|
|
211
|
-
assert.strictEqual(response.body.to, 'as:Public')
|
|
212
|
-
})
|
|
213
|
-
})
|
|
214
|
-
})
|
|
@@ -1,433 +0,0 @@
|
|
|
1
|
-
import { describe, it } from 'node:test'
|
|
2
|
-
import assert from 'node:assert'
|
|
3
|
-
import { makeApp } from '../lib/app.js'
|
|
4
|
-
import request from 'supertest'
|
|
5
|
-
import bots from './fixtures/bots.js'
|
|
6
|
-
import as2 from '../lib/activitystreams.js'
|
|
7
|
-
import { nanoid } from 'nanoid'
|
|
8
|
-
|
|
9
|
-
describe('actor collection routes', async () => {
|
|
10
|
-
const databaseUrl = 'sqlite::memory:'
|
|
11
|
-
const origin = 'https://activitypubbot.test'
|
|
12
|
-
const app = await makeApp(databaseUrl, origin, bots, 'silent')
|
|
13
|
-
|
|
14
|
-
for (const coll of ['outbox', 'liked', 'followers', 'following']) {
|
|
15
|
-
describe(`${coll} collection`, async () => {
|
|
16
|
-
describe(`GET /user/{botid}/${coll}`, async () => {
|
|
17
|
-
let response = null
|
|
18
|
-
it('should work without an error', async () => {
|
|
19
|
-
response = await request(app).get(`/user/ok/${coll}`)
|
|
20
|
-
})
|
|
21
|
-
it('should return 200 OK', async () => {
|
|
22
|
-
assert.strictEqual(response.status, 200)
|
|
23
|
-
})
|
|
24
|
-
it('should return AS2', async () => {
|
|
25
|
-
assert.strictEqual(response.type, 'application/activity+json')
|
|
26
|
-
})
|
|
27
|
-
it('should return an object', async () => {
|
|
28
|
-
assert.strictEqual(typeof response.body, 'object')
|
|
29
|
-
})
|
|
30
|
-
it('should return an object with an id', async () => {
|
|
31
|
-
assert.strictEqual(typeof response.body.id, 'string')
|
|
32
|
-
})
|
|
33
|
-
it('should return an object with an id matching the request', async () => {
|
|
34
|
-
assert.strictEqual(response.body.id, origin + `/user/ok/${coll}`)
|
|
35
|
-
})
|
|
36
|
-
it('should return an object with a type', async () => {
|
|
37
|
-
assert.strictEqual(typeof response.body.type, 'string')
|
|
38
|
-
})
|
|
39
|
-
it('should return an object with a type matching the request', async () => {
|
|
40
|
-
assert.strictEqual(response.body.type, 'OrderedCollection')
|
|
41
|
-
})
|
|
42
|
-
it('should return an object with a totalItems', async () => {
|
|
43
|
-
assert.strictEqual(typeof response.body.totalItems, 'number')
|
|
44
|
-
})
|
|
45
|
-
it('should return an object with attributedTo', async () => {
|
|
46
|
-
assert.strictEqual(typeof response.body.attributedTo, 'string')
|
|
47
|
-
})
|
|
48
|
-
it('should return an object with attributedTo matching the bot', async () => {
|
|
49
|
-
assert.strictEqual(response.body.attributedTo, origin + '/user/ok')
|
|
50
|
-
})
|
|
51
|
-
it('should return an object with a to', async () => {
|
|
52
|
-
assert.strictEqual(typeof response.body.to, 'string')
|
|
53
|
-
})
|
|
54
|
-
it('should return an object with a to for the public', async () => {
|
|
55
|
-
assert.strictEqual(response.body.to, 'as:Public')
|
|
56
|
-
})
|
|
57
|
-
it('should return an object with a summary', async () => {
|
|
58
|
-
assert.strictEqual(typeof response.body.summaryMap, 'object')
|
|
59
|
-
assert.strictEqual(typeof response.body.summaryMap.en, 'string')
|
|
60
|
-
})
|
|
61
|
-
it('should return an object with a first', async () => {
|
|
62
|
-
assert.strictEqual(typeof response.body.first, 'string')
|
|
63
|
-
})
|
|
64
|
-
it('should return an object with a last', async () => {
|
|
65
|
-
assert.strictEqual(typeof response.body.last, 'string')
|
|
66
|
-
})
|
|
67
|
-
it(`should return an object with a ${coll}Of to the actor`, async () => {
|
|
68
|
-
assert.strictEqual(typeof response.body[coll + 'Of'], 'string')
|
|
69
|
-
assert.strictEqual(response.body[coll + 'Of'], origin + '/user/ok')
|
|
70
|
-
})
|
|
71
|
-
})
|
|
72
|
-
describe('GET collection for non-existent user', async () => {
|
|
73
|
-
let response = null
|
|
74
|
-
it('should work without an error', async () => {
|
|
75
|
-
response = await request(app).get('/user/dne/' + coll)
|
|
76
|
-
})
|
|
77
|
-
it('should return 404 Not Found', async () => {
|
|
78
|
-
assert.strictEqual(response.status, 404)
|
|
79
|
-
})
|
|
80
|
-
it('should return Problem Details JSON', async () => {
|
|
81
|
-
assert.strictEqual(response.type, 'application/problem+json')
|
|
82
|
-
})
|
|
83
|
-
it('should return an object', async () => {
|
|
84
|
-
assert.strictEqual(typeof response.body, 'object')
|
|
85
|
-
})
|
|
86
|
-
it('should return an object with a type', async () => {
|
|
87
|
-
assert.strictEqual(typeof response.body.type, 'string')
|
|
88
|
-
})
|
|
89
|
-
it('should return an object with an type matching the request', async () => {
|
|
90
|
-
assert.strictEqual(response.body.type, 'about:blank')
|
|
91
|
-
})
|
|
92
|
-
it('should return an object with a title', async () => {
|
|
93
|
-
assert.strictEqual(typeof response.body.title, 'string')
|
|
94
|
-
})
|
|
95
|
-
it('should return an object with a title matching the request', async () => {
|
|
96
|
-
assert.strictEqual(response.body.title, 'Not Found')
|
|
97
|
-
})
|
|
98
|
-
it('should return an object with a status', async () => {
|
|
99
|
-
assert.strictEqual(typeof response.body.status, 'number')
|
|
100
|
-
})
|
|
101
|
-
it('should return an object with a status matching the request', async () => {
|
|
102
|
-
assert.strictEqual(response.body.status, 404)
|
|
103
|
-
})
|
|
104
|
-
it('should return an object with a detail', async () => {
|
|
105
|
-
assert.strictEqual(typeof response.body.detail, 'string')
|
|
106
|
-
})
|
|
107
|
-
it('should return an object with a detail matching the request', async () => {
|
|
108
|
-
assert.strictEqual(response.body.detail, 'User dne not found')
|
|
109
|
-
})
|
|
110
|
-
})
|
|
111
|
-
describe(`GET /user/{botid}/${coll}/1`, async () => {
|
|
112
|
-
let response = null
|
|
113
|
-
it('should work without an error', async () => {
|
|
114
|
-
response = await request(app).get(`/user/ok/${coll}/1`)
|
|
115
|
-
})
|
|
116
|
-
it('should return 200 OK', async () => {
|
|
117
|
-
assert.strictEqual(response.status, 200)
|
|
118
|
-
})
|
|
119
|
-
it('should return AS2', async () => {
|
|
120
|
-
assert.strictEqual(response.type, 'application/activity+json')
|
|
121
|
-
})
|
|
122
|
-
it('should return an object', async () => {
|
|
123
|
-
assert.strictEqual(typeof response.body, 'object')
|
|
124
|
-
})
|
|
125
|
-
it('should return an object with an id', async () => {
|
|
126
|
-
assert.strictEqual(typeof response.body.id, 'string')
|
|
127
|
-
})
|
|
128
|
-
it('should return an object with an id matching the request', async () => {
|
|
129
|
-
assert.strictEqual(response.body.id, origin + `/user/ok/${coll}/1`)
|
|
130
|
-
})
|
|
131
|
-
it('should return an object with a type', async () => {
|
|
132
|
-
assert.strictEqual(typeof response.body.type, 'string')
|
|
133
|
-
})
|
|
134
|
-
it('should return an object with a type matching the request', async () => {
|
|
135
|
-
assert.strictEqual(response.body.type, 'OrderedCollectionPage')
|
|
136
|
-
})
|
|
137
|
-
it('should return an object with attributedTo', async () => {
|
|
138
|
-
assert.strictEqual(typeof response.body.attributedTo, 'string')
|
|
139
|
-
})
|
|
140
|
-
it('should return an object with attributedTo matching the bot', async () => {
|
|
141
|
-
assert.strictEqual(response.body.attributedTo, origin + '/user/ok')
|
|
142
|
-
})
|
|
143
|
-
it('should return an object with a to', async () => {
|
|
144
|
-
assert.strictEqual(typeof response.body.to, 'string')
|
|
145
|
-
})
|
|
146
|
-
it('should return an object with a to for the public', async () => {
|
|
147
|
-
assert.strictEqual(response.body.to, 'as:Public')
|
|
148
|
-
})
|
|
149
|
-
it('should return an object with a summary', async () => {
|
|
150
|
-
assert.strictEqual(typeof response.body.summaryMap, 'object')
|
|
151
|
-
assert.strictEqual(typeof response.body.summaryMap.en, 'string')
|
|
152
|
-
})
|
|
153
|
-
it('should return an object with a partOf', async () => {
|
|
154
|
-
assert.strictEqual(typeof response.body.partOf, 'string')
|
|
155
|
-
})
|
|
156
|
-
it('should return an object with a partOf matching the collection', async () => {
|
|
157
|
-
assert.strictEqual(response.body.partOf, origin + `/user/ok/${coll}`)
|
|
158
|
-
})
|
|
159
|
-
})
|
|
160
|
-
describe('GET collection page for non-existent user', async () => {
|
|
161
|
-
let response = null
|
|
162
|
-
it('should work without an error', async () => {
|
|
163
|
-
response = await request(app).get('/user/dne/' + coll + '/1')
|
|
164
|
-
})
|
|
165
|
-
it('should return 404 Not Found', async () => {
|
|
166
|
-
assert.strictEqual(response.status, 404)
|
|
167
|
-
})
|
|
168
|
-
it('should return Problem Details JSON', async () => {
|
|
169
|
-
assert.strictEqual(response.type, 'application/problem+json')
|
|
170
|
-
})
|
|
171
|
-
it('should return an object', async () => {
|
|
172
|
-
assert.strictEqual(typeof response.body, 'object')
|
|
173
|
-
})
|
|
174
|
-
it('should return an object with a type', async () => {
|
|
175
|
-
assert.strictEqual(typeof response.body.type, 'string')
|
|
176
|
-
})
|
|
177
|
-
it('should return an object with an type matching the request', async () => {
|
|
178
|
-
assert.strictEqual(response.body.type, 'about:blank')
|
|
179
|
-
})
|
|
180
|
-
it('should return an object with a title', async () => {
|
|
181
|
-
assert.strictEqual(typeof response.body.title, 'string')
|
|
182
|
-
})
|
|
183
|
-
it('should return an object with a title matching the request', async () => {
|
|
184
|
-
assert.strictEqual(response.body.title, 'Not Found')
|
|
185
|
-
})
|
|
186
|
-
it('should return an object with a status', async () => {
|
|
187
|
-
assert.strictEqual(typeof response.body.status, 'number')
|
|
188
|
-
})
|
|
189
|
-
it('should return an object with a status matching the request', async () => {
|
|
190
|
-
assert.strictEqual(response.body.status, 404)
|
|
191
|
-
})
|
|
192
|
-
it('should return an object with a detail', async () => {
|
|
193
|
-
assert.strictEqual(typeof response.body.detail, 'string')
|
|
194
|
-
})
|
|
195
|
-
it('should return an object with a detail matching the request', async () => {
|
|
196
|
-
assert.strictEqual(response.body.detail, 'User dne not found')
|
|
197
|
-
})
|
|
198
|
-
})
|
|
199
|
-
describe('GET non-existent page for existent collection and existent user', async () => {
|
|
200
|
-
let response = null
|
|
201
|
-
it('should work without an error', async () => {
|
|
202
|
-
response = await request(app).get('/user/ok/' + coll + '/99999999')
|
|
203
|
-
})
|
|
204
|
-
it('should return 404 Not Found', async () => {
|
|
205
|
-
assert.strictEqual(response.status, 404)
|
|
206
|
-
})
|
|
207
|
-
it('should return Problem Details JSON', async () => {
|
|
208
|
-
assert.strictEqual(response.type, 'application/problem+json')
|
|
209
|
-
})
|
|
210
|
-
it('should return an object', async () => {
|
|
211
|
-
assert.strictEqual(typeof response.body, 'object')
|
|
212
|
-
})
|
|
213
|
-
it('should return an object with a type', async () => {
|
|
214
|
-
assert.strictEqual(typeof response.body.type, 'string')
|
|
215
|
-
})
|
|
216
|
-
it('should return an object with an type matching the request', async () => {
|
|
217
|
-
assert.strictEqual(response.body.type, 'about:blank')
|
|
218
|
-
})
|
|
219
|
-
it('should return an object with a title', async () => {
|
|
220
|
-
assert.strictEqual(typeof response.body.title, 'string')
|
|
221
|
-
})
|
|
222
|
-
it('should return an object with a title matching the request', async () => {
|
|
223
|
-
assert.strictEqual(response.body.title, 'Not Found')
|
|
224
|
-
})
|
|
225
|
-
it('should return an object with a status', async () => {
|
|
226
|
-
assert.strictEqual(typeof response.body.status, 'number')
|
|
227
|
-
})
|
|
228
|
-
it('should return an object with a status matching the request', async () => {
|
|
229
|
-
assert.strictEqual(response.body.status, 404)
|
|
230
|
-
})
|
|
231
|
-
it('should return an object with a detail', async () => {
|
|
232
|
-
assert.strictEqual(typeof response.body.detail, 'string')
|
|
233
|
-
})
|
|
234
|
-
it('should return an object with a detail matching the request', async () => {
|
|
235
|
-
assert.strictEqual(response.body.detail, 'No such page 99999999 for collection ' + coll + ' for user ok')
|
|
236
|
-
})
|
|
237
|
-
})
|
|
238
|
-
})
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
describe('GET non-existent collection for existent user', async () => {
|
|
242
|
-
let response = null
|
|
243
|
-
it('should work without an error', async () => {
|
|
244
|
-
response = await request(app).get('/user/ok/dne')
|
|
245
|
-
})
|
|
246
|
-
it('should return 404 Not Found', async () => {
|
|
247
|
-
assert.strictEqual(response.status, 404)
|
|
248
|
-
})
|
|
249
|
-
it('should return Problem Details JSON', async () => {
|
|
250
|
-
assert.strictEqual(response.type, 'application/problem+json')
|
|
251
|
-
})
|
|
252
|
-
it('should return an object', async () => {
|
|
253
|
-
assert.strictEqual(typeof response.body, 'object')
|
|
254
|
-
})
|
|
255
|
-
it('should return an object with a type', async () => {
|
|
256
|
-
assert.strictEqual(typeof response.body.type, 'string')
|
|
257
|
-
})
|
|
258
|
-
it('should return an object with an type matching the request', async () => {
|
|
259
|
-
assert.strictEqual(response.body.type, 'about:blank')
|
|
260
|
-
})
|
|
261
|
-
it('should return an object with a title', async () => {
|
|
262
|
-
assert.strictEqual(typeof response.body.title, 'string')
|
|
263
|
-
})
|
|
264
|
-
it('should return an object with a title matching the request', async () => {
|
|
265
|
-
assert.strictEqual(response.body.title, 'Not Found')
|
|
266
|
-
})
|
|
267
|
-
it('should return an object with a status', async () => {
|
|
268
|
-
assert.strictEqual(typeof response.body.status, 'number')
|
|
269
|
-
})
|
|
270
|
-
it('should return an object with a status matching the request', async () => {
|
|
271
|
-
assert.strictEqual(response.body.status, 404)
|
|
272
|
-
})
|
|
273
|
-
it('should return an object with a detail', async () => {
|
|
274
|
-
assert.strictEqual(typeof response.body.detail, 'string')
|
|
275
|
-
})
|
|
276
|
-
it('should return an object with a detail matching the request', async () => {
|
|
277
|
-
assert.strictEqual(response.body.detail, 'No such collection dne for user ok')
|
|
278
|
-
})
|
|
279
|
-
})
|
|
280
|
-
|
|
281
|
-
describe('GET page for non-existent collection for existent user', async () => {
|
|
282
|
-
let response = null
|
|
283
|
-
it('should work without an error', async () => {
|
|
284
|
-
response = await request(app).get('/user/ok/dne/1')
|
|
285
|
-
})
|
|
286
|
-
it('should return 404 Not Found', async () => {
|
|
287
|
-
assert.strictEqual(response.status, 404)
|
|
288
|
-
})
|
|
289
|
-
it('should return Problem Details JSON', async () => {
|
|
290
|
-
assert.strictEqual(response.type, 'application/problem+json')
|
|
291
|
-
})
|
|
292
|
-
it('should return an object', async () => {
|
|
293
|
-
assert.strictEqual(typeof response.body, 'object')
|
|
294
|
-
})
|
|
295
|
-
it('should return an object with a type', async () => {
|
|
296
|
-
assert.strictEqual(typeof response.body.type, 'string')
|
|
297
|
-
})
|
|
298
|
-
it('should return an object with an type matching the request', async () => {
|
|
299
|
-
assert.strictEqual(response.body.type, 'about:blank')
|
|
300
|
-
})
|
|
301
|
-
it('should return an object with a title', async () => {
|
|
302
|
-
assert.strictEqual(typeof response.body.title, 'string')
|
|
303
|
-
})
|
|
304
|
-
it('should return an object with a title matching the request', async () => {
|
|
305
|
-
assert.strictEqual(response.body.title, 'Not Found')
|
|
306
|
-
})
|
|
307
|
-
it('should return an object with a status', async () => {
|
|
308
|
-
assert.strictEqual(typeof response.body.status, 'number')
|
|
309
|
-
})
|
|
310
|
-
it('should return an object with a status matching the request', async () => {
|
|
311
|
-
assert.strictEqual(response.body.status, 404)
|
|
312
|
-
})
|
|
313
|
-
it('should return an object with a detail', async () => {
|
|
314
|
-
assert.strictEqual(typeof response.body.detail, 'string')
|
|
315
|
-
})
|
|
316
|
-
it('should return an object with a detail matching the request', async () => {
|
|
317
|
-
assert.strictEqual(response.body.detail, 'No such collection dne for user ok')
|
|
318
|
-
})
|
|
319
|
-
})
|
|
320
|
-
|
|
321
|
-
describe('GET /user/{botid}/inbox', async () => {
|
|
322
|
-
let response = null
|
|
323
|
-
it('should work without an error', async () => {
|
|
324
|
-
response = await request(app).get('/user/ok/inbox')
|
|
325
|
-
})
|
|
326
|
-
it('should return 403 Forbidden', async () => {
|
|
327
|
-
assert.strictEqual(response.status, 403)
|
|
328
|
-
})
|
|
329
|
-
it('should return Problem Details JSON', async () => {
|
|
330
|
-
assert.strictEqual(response.type, 'application/problem+json')
|
|
331
|
-
})
|
|
332
|
-
it('should return an object', async () => {
|
|
333
|
-
assert.strictEqual(typeof response.body, 'object')
|
|
334
|
-
})
|
|
335
|
-
it('should return an object with a type', async () => {
|
|
336
|
-
assert.strictEqual(typeof response.body.type, 'string')
|
|
337
|
-
})
|
|
338
|
-
it('should return an object with an type matching the request', async () => {
|
|
339
|
-
assert.strictEqual(response.body.type, 'about:blank')
|
|
340
|
-
})
|
|
341
|
-
it('should return an object with a title', async () => {
|
|
342
|
-
assert.strictEqual(typeof response.body.title, 'string')
|
|
343
|
-
})
|
|
344
|
-
it('should return an object with a title matching the request', async () => {
|
|
345
|
-
assert.strictEqual(response.body.title, 'Forbidden')
|
|
346
|
-
})
|
|
347
|
-
it('should return an object with a status', async () => {
|
|
348
|
-
assert.strictEqual(typeof response.body.status, 'number')
|
|
349
|
-
})
|
|
350
|
-
it('should return an object with a status matching the request', async () => {
|
|
351
|
-
assert.strictEqual(response.body.status, 403)
|
|
352
|
-
})
|
|
353
|
-
it('should return an object with a detail', async () => {
|
|
354
|
-
assert.strictEqual(typeof response.body.detail, 'string')
|
|
355
|
-
})
|
|
356
|
-
it('should return an object with a detail matching the request', async () => {
|
|
357
|
-
assert.strictEqual(response.body.detail, 'No access to inbox collection')
|
|
358
|
-
})
|
|
359
|
-
})
|
|
360
|
-
|
|
361
|
-
describe('GET /user/{botid}/inbox/1', async () => {
|
|
362
|
-
let response = null
|
|
363
|
-
it('should work without an error', async () => {
|
|
364
|
-
response = await request(app).get('/user/ok/inbox/1')
|
|
365
|
-
})
|
|
366
|
-
it('should return 403 Forbidden', async () => {
|
|
367
|
-
assert.strictEqual(response.status, 403)
|
|
368
|
-
})
|
|
369
|
-
it('should return Problem Details JSON', async () => {
|
|
370
|
-
assert.strictEqual(response.type, 'application/problem+json')
|
|
371
|
-
})
|
|
372
|
-
it('should return an object', async () => {
|
|
373
|
-
assert.strictEqual(typeof response.body, 'object')
|
|
374
|
-
})
|
|
375
|
-
it('should return an object with a type', async () => {
|
|
376
|
-
assert.strictEqual(typeof response.body.type, 'string')
|
|
377
|
-
})
|
|
378
|
-
it('should return an object with an type matching the request', async () => {
|
|
379
|
-
assert.strictEqual(response.body.type, 'about:blank')
|
|
380
|
-
})
|
|
381
|
-
it('should return an object with a title', async () => {
|
|
382
|
-
assert.strictEqual(typeof response.body.title, 'string')
|
|
383
|
-
})
|
|
384
|
-
it('should return an object with a title matching the request', async () => {
|
|
385
|
-
assert.strictEqual(response.body.title, 'Forbidden')
|
|
386
|
-
})
|
|
387
|
-
it('should return an object with a status', async () => {
|
|
388
|
-
assert.strictEqual(typeof response.body.status, 'number')
|
|
389
|
-
})
|
|
390
|
-
it('should return an object with a status matching the request', async () => {
|
|
391
|
-
assert.strictEqual(response.body.status, 403)
|
|
392
|
-
})
|
|
393
|
-
it('should return an object with a detail', async () => {
|
|
394
|
-
assert.strictEqual(typeof response.body.detail, 'string')
|
|
395
|
-
})
|
|
396
|
-
it('should return an object with a detail matching the request', async () => {
|
|
397
|
-
assert.strictEqual(response.body.detail, 'No access to inbox collection')
|
|
398
|
-
})
|
|
399
|
-
})
|
|
400
|
-
|
|
401
|
-
describe('GET /user/{botid}/outbox/1 with contents', async () => {
|
|
402
|
-
let response = null
|
|
403
|
-
const username = 'test0'
|
|
404
|
-
const actorStorage = app.locals.actorStorage
|
|
405
|
-
const objectStorage = app.locals.objectStorage
|
|
406
|
-
const formatter = app.locals.formatter
|
|
407
|
-
|
|
408
|
-
for (let i = 0; i < 20; i++) {
|
|
409
|
-
const activity = await as2.import({
|
|
410
|
-
'@context': 'https://www.w3.org/ns/activitystreams',
|
|
411
|
-
to: 'as:Public',
|
|
412
|
-
actor: formatter.format({ username }),
|
|
413
|
-
type: 'IntransitiveActivity',
|
|
414
|
-
id: formatter.format({
|
|
415
|
-
username,
|
|
416
|
-
type: 'intransitiveactivity',
|
|
417
|
-
nanoid: nanoid()
|
|
418
|
-
}),
|
|
419
|
-
summary: 'An intransitive activity by the test0 bot',
|
|
420
|
-
published: (new Date()).toISOString()
|
|
421
|
-
})
|
|
422
|
-
await objectStorage.create(activity)
|
|
423
|
-
await actorStorage.addToCollection(username, 'outbox', activity)
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
it('should work without an error', async () => {
|
|
427
|
-
response = await request(app).get(`/user/${username}/outbox/1`)
|
|
428
|
-
})
|
|
429
|
-
it('should return 200 OK', async () => {
|
|
430
|
-
assert.strictEqual(response.status, 200)
|
|
431
|
-
})
|
|
432
|
-
})
|
|
433
|
-
})
|