交付 Windows 与 Web 端到端加密附件预览
This commit is contained in:
1 parent
d1efdedc57
commit
c24960d22a
19 files changed
+421
-58
No files matched your search
@@ -116,3 +116,33 @@ test('设备密钥包验证签名并只领取一次', { timeout: 25000 }, async
|
||||
assert.equal((await call('/devices/' + owner.device.id, 'DELETE', owner.token)).status, 204)
|
||||
assert.deepEqual(await json(directory, 'GET', contactUser.token), [])
|
||||
})
|
||||
|
||||
test('附件访问按设备授权并支持相同密文重试', { timeout: 15000 }, async () => {
|
||||
const sender = await register()
|
||||
const recipient = await register()
|
||||
const stranger = await register()
|
||||
const path = '/api/v1/attachments/' + randomUUID()
|
||||
const bytes = randomBytes(256)
|
||||
const upload = (body) => fetch(base + path + '?recipient=' + recipient.device.id, {
|
||||
method: 'POST',
|
||||
headers: { Authorization: 'Bearer ' + sender.token, 'Content-Type': 'application/octet-stream' },
|
||||
body,
|
||||
signal: AbortSignal.timeout(10_000),
|
||||
})
|
||||
const download = (token) => fetch(base + path, {
|
||||
headers: { Authorization: 'Bearer ' + token },
|
||||
signal: AbortSignal.timeout(10_000),
|
||||
})
|
||||
assert.equal((await upload(bytes)).status, 404)
|
||||
await contact(sender, recipient, 'request')
|
||||
await contact(recipient, sender, 'accept')
|
||||
assert.equal((await upload(bytes)).status, 204)
|
||||
assert.equal((await upload(bytes)).status, 204)
|
||||
assert.equal((await upload(randomBytes(256))).status, 409)
|
||||
assert.equal((await download(stranger.token)).status, 404)
|
||||
const response = await download(recipient.token)
|
||||
assert.equal(response.status, 200)
|
||||
assert.deepEqual(Buffer.from(await response.arrayBuffer()), bytes)
|
||||
assert.equal((await call('/devices/' + recipient.device.id, 'DELETE', recipient.token)).status, 204)
|
||||
assert.equal((await download(recipient.token)).status, 401)
|
||||
})
|
||||
Reference in new issue
Block a user