Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fetching retrieves non-revoked keys for a payment pointer #1837

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}