mirror of
https://github.com/Permissionless-Software-Foundation/bch-dex.git
synced 2026-09-21 16:52:00 -07:00
Merge pull request #109 from Permissionless-Software-Foundation/dh-access-validation
feat(test): Added user/admin access validation to endpoint
This commit is contained in:
@@ -54,7 +54,7 @@ class OrderRouter {
|
|||||||
// Define the routes and attach the controller.
|
// Define the routes and attach the controller.
|
||||||
this.router.post('/', this.createOrder)
|
this.router.post('/', this.createOrder)
|
||||||
this.router.get('/list/all/:page', _this.orderRESTController.listOrders)
|
this.router.get('/list/all/:page', _this.orderRESTController.listOrders)
|
||||||
this.router.post('/delete', _this.orderRESTController.deleteOrder)
|
this.router.post('/delete', this.deleteOrder)
|
||||||
|
|
||||||
// Attach the Controller routes to the Koa app.
|
// Attach the Controller routes to the Koa app.
|
||||||
app.use(_this.router.routes())
|
app.use(_this.router.routes())
|
||||||
@@ -65,6 +65,11 @@ class OrderRouter {
|
|||||||
await _this.validators.ensureUser(ctx, next)
|
await _this.validators.ensureUser(ctx, next)
|
||||||
await _this.orderRESTController.createOrder(ctx, next)
|
await _this.orderRESTController.createOrder(ctx, next)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async deleteOrder (ctx, next) {
|
||||||
|
await _this.validators.ensureUser(ctx, next)
|
||||||
|
await _this.orderRESTController.deleteOrder(ctx, next)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default OrderRouter
|
export default OrderRouter
|
||||||
|
|||||||
@@ -83,4 +83,13 @@ describe('#Order-REST-Router', () => {
|
|||||||
assert.isTrue(spy.calledOnce)
|
assert.isTrue(spy.calledOnce)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
describe('#deleteOrder', () => {
|
||||||
|
it('should route to controller', async () => {
|
||||||
|
sandbox.stub(uut.validators, 'ensureUser').resolves(true)
|
||||||
|
const spy = sandbox.stub(uut.orderRESTController, 'deleteOrder').resolves(true)
|
||||||
|
|
||||||
|
await uut.deleteOrder()
|
||||||
|
assert.isTrue(spy.calledOnce)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user