Fix BTCPay webhook not returning response
Adds a test for successful Webhook responses and fixes the missing return.
This commit is contained in:
parent
c8a38e4d78
commit
4518cc84c2
|
@ -36,13 +36,15 @@ class MastodonBtcPayHookRoute extends BaseRoute {
|
|||
content: message
|
||||
}).then(() => res.status(200))
|
||||
.catch(err => this.handleError(res, err))
|
||||
|
||||
return res.status(200).json({ status: 'OK' })
|
||||
}
|
||||
|
||||
private createMessage (inviteCode: String) {
|
||||
const inviteUrl = `${process.env.MASTODON_HOST}/invite/${inviteCode}`
|
||||
const message = 'Here\'s your invite link for creating an account on kosmos.social:'
|
||||
+ `\n\n${inviteUrl}\n\n`
|
||||
+ 'Thanks a lot for supporting community service providers!'
|
||||
+ 'Welcome to the community!'
|
||||
return message
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,10 @@ setup()
|
|||
|
||||
describe('POST /accounts/mastodon/btcpay_hook', () => {
|
||||
|
||||
before(() => {
|
||||
process.env.BTCPAY_WEBHOOK_TOKEN = 'supersecure'
|
||||
})
|
||||
|
||||
describe('auth token missing', () => {
|
||||
it('returns an error', async () => {
|
||||
await supertest
|
||||
|
@ -32,4 +36,34 @@ describe('POST /accounts/mastodon/btcpay_hook', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('successful request', () => {
|
||||
before(() => {
|
||||
sandbox
|
||||
.stub(BaseRoute.prototype, 'createMastodonClient')
|
||||
.returns({
|
||||
post: url => {
|
||||
return Promise.resolve({
|
||||
data: { code: '123abc' }
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('returns an error', async () => {
|
||||
await supertest
|
||||
.post('/accounts/mastodon/btcpay_hook?token=supersecure')
|
||||
.set('Content-Type', 'application/json')
|
||||
.send({
|
||||
buyerFields: {
|
||||
buyerEmail: 'satoshi@kosmos.org'
|
||||
},
|
||||
status: 'confirmed'
|
||||
})
|
||||
.expect(200)
|
||||
.then(res => {
|
||||
expect(res.body.status).to.eq('OK')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
|
Reference in New Issue