Skip to content

Commit

Permalink
Merge pull request #26 from web3-storage/more_test_coverage
Browse files Browse the repository at this point in the history
tests: add more tests around delegated caps.
  • Loading branch information
ice-breaker-tg committed Sep 29, 2022
2 parents 32457c9 + 3581ee0 commit 4d078a5
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/delegation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,46 @@ describe('delegation', () => {
expect(delegation).toBeDefined()
expect(delegation.expiration).toBeGreaterThan(now + 999)
})

it('should have any store capabilities by default', async ({ issuer }) => {
const now = Date.now()
const delegation = await generateDelegation({
issuer,
to: fixture.did,
expiration: 1000,
})

const capabilities = delegation.capabilities
const cans = capabilities?.map((x) => x.can)

expect(delegation).toBeDefined()
expect(capabilities).toBeDefined()
expect(cans).toContain('store/add')
expect(cans).toContain('store/remove')
expect(cans).toContain('store/list')
})

it('should NOT have any account capabilities by default', async ({
issuer,
}) => {
const now = Date.now()
const delegation = await generateDelegation({
issuer,
to: fixture.did,
expiration: 1000,
})

const capabilities = delegation.capabilities
const cans = capabilities?.map((x) => x.can)

expect(delegation).toBeDefined()
expect(capabilities).toBeDefined()
expect(cans).toContain('store/add')

expect(cans).not.toContain('identity/identify')
expect(cans).not.toContain('identity/register')
expect(cans).not.toContain('identity/validate')
})
})

describe('#importDelegation', () => {
Expand Down

0 comments on commit 4d078a5

Please sign in to comment.