Skip to content

Commit

Permalink
test: test access for outbox
Browse files Browse the repository at this point in the history
Signed-off-by: Evan Prodromou <[email protected]>
  • Loading branch information
Evan Prodromou committed Aug 27, 2024
1 parent 244f63d commit 6e24211
Showing 1 changed file with 70 additions and 1 deletion.
71 changes: 70 additions & 1 deletion index.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5379,7 +5379,9 @@ describe('onepage.pub', () => {
assert('@context' in obj)
assert(Array.isArray(obj['@context']))
assert(
obj['@context'].includes('https://purl.archive.org/socialweb/webfinger')
obj['@context'].includes(
'https://purl.archive.org/socialweb/webfinger'
)
)
assert('webfinger' in obj)
assert.strictEqual(typeof obj.webfinger, 'string')
Expand Down Expand Up @@ -5442,4 +5444,71 @@ describe('onepage.pub', () => {
assert.match(output, /^{\s*"@context":/)
})
})

describe('User collections have correct addressees', () => {
let actor1 = null
let token1 = null
let token2 = null
let outbox = null
before(async () => {
[actor1, token1] = await registerActor();
[, token2] = await registerActor()
for (let i = 0; i < 23; i++) {
await doActivity(actor1, token1, {
to: [PUBLIC],
type: 'Create',
object: {
type: 'Note',
contentMap: {
en: `Hello, World! (iteration ${i})`
}
}
})
}
await settle(MAIN_PORT)
})
it('Collection has correct addressees', async () => {
outbox = await getObject(actor1.outbox, token1)
assert.strictEqual(outbox.to.length, 1)
assert.strictEqual(outbox.to[0].id, PUBLIC)
})
it('First collection page has correct addressees', async () => {
const firstPage = await getObject(outbox.first.id, token1)
assert.strictEqual(firstPage.to.length, 1)
assert.strictEqual(firstPage.to[0].id, PUBLIC)
})
it('Last collection page has correct addressees', async () => {
const firstPage = await getObject(outbox.last.id, token1)
assert.strictEqual(firstPage.to.length, 1)
assert.strictEqual(firstPage.to[0].id, PUBLIC)
})
it('Other actor can get outbox', async () => {
const outbox = await getObject(actor1.outbox, token2)
assert.strictEqual(outbox.totalItems, 23)
})
it('Other actor can get first outbox page', async () => {
const outbox = await getObject(actor1.outbox, token2)
const firstPage = await getObject(outbox.first.id, token2)
assert.ok(firstPage)
})
it('Other actor can get last outbox page', async () => {
const outbox = await getObject(actor1.outbox, token2)
const lastPage = await getObject(outbox.last.id, token2)
assert.ok(lastPage)
})
it('Unauthenticated user can get outbox', async () => {
const outbox = await getObject(actor1.outbox)
assert.strictEqual(outbox.totalItems, 23)
})
it('Unauthenticated user can get first outbox page', async () => {
const outbox = await getObject(actor1.outbox)
const firstPage = await getObject(outbox.first.id)
assert.ok(firstPage)
})
it('Unauthenticated user can get last outbox page', async () => {
const outbox = await getObject(actor1.outbox)
const lastPage = await getObject(outbox.last.id)
assert.ok(lastPage)
})
})
})

0 comments on commit 6e24211

Please sign in to comment.