Skip to content

Commit

Permalink
feat: fetching retrieves non-revoked keys for a payment pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
JoblersTune committed Sep 6, 2023
1 parent 409d1a4 commit 66a6cef
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,28 @@ describe('Payment Pointer Key Service', (): void => {
paymentPointerKeyService.getKeysByPaymentPointerId(paymentPointer.id)
).resolves.toEqual([key])
})

test('Fetching Only Retrieves Non-Revoked Keys for a Payment Pointer', async (): Promise<void> => {
const paymentPointer = await createPaymentPointer(deps)

const keyOption1 = {
paymentPointerId: paymentPointer.id,
jwk: TEST_KEY
}

const keyOption2 = {
paymentPointerId: paymentPointer.id,
jwk: generateJwk({ keyId: uuid() })
}

const key1 = await paymentPointerKeyService.create(keyOption1)
const key2 = await paymentPointerKeyService.create(keyOption2)
await paymentPointerKeyService.revoke(key1.id)

await expect(
paymentPointerKeyService.getKeysByPaymentPointerId(paymentPointer.id)
).resolves.toEqual([key2])
})
})

describe('Revoke Payment Pointer Keys', (): void => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ async function getKeysByPaymentPointerId(
paymentPointerId: string
): Promise<PaymentPointerKey[]> {
const keys = await PaymentPointerKey.query(deps.knex).where({
paymentPointerId
paymentPointerId,
revoked: false
})
return keys
}

0 comments on commit 66a6cef

Please sign in to comment.