Skip to content

Commit

Permalink
test: add tests for conditional signed fetch in getActor
Browse files Browse the repository at this point in the history
  • Loading branch information
akhileshthite committed Nov 14, 2023
1 parent 71a1bcf commit 9c28117
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/server/apsystem.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,25 @@ test('hasPermissionActorRequest denies an invalid actor', async t => {
t.false(result)
})

test('getActor uses signedFetch when fromActor is provided', async t => {
const actorURL = 'http://remote.actor'
const fromActor = 'http://local.actor'

await t.notThrowsAsync(async () => {
const actor = await aps.getActor(actorURL, fromActor)
t.truthy(actor, 'Actor should be fetched successfully with signed request')
}, 'getActor should use signedFetch when fromActor is provided')
})

test('getActor uses regular fetch when fromActor is not provided', async t => {
const actorURL = 'http://remote.actor'

await t.notThrowsAsync(async () => {
const actor = await aps.getActor(actorURL)
t.truthy(actor, 'Actor should be fetched successfully without signed request')
}, 'getActor should use regular fetch when fromActor is not provided')
})

// After all tests, restore all sinon mocks
test.afterEach(() => {
// Restore all sinon mocks
Expand Down

0 comments on commit 9c28117

Please sign in to comment.