test: 覆盖NapCat WebUI会话密钥校验
This commit is contained in:
parent
8ee7866afe
commit
87b0368b9a
@ -403,7 +403,7 @@ describe('InternalSessionController', () => {
|
|||||||
expect(response.body.iframeUrl).not.toContain('127.0.0.1');
|
expect(response.body.iframeUrl).not.toContain('127.0.0.1');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rejects missing or wrong secrets for mutating calls', async () => {
|
it('rejects missing or wrong secrets for all mutating calls', async () => {
|
||||||
await request(app.getHttpServer())
|
await request(app.getHttpServer())
|
||||||
.post('/internal/sessions')
|
.post('/internal/sessions')
|
||||||
.send(createSessionInput())
|
.send(createSessionInput())
|
||||||
@ -413,6 +413,24 @@ describe('InternalSessionController', () => {
|
|||||||
.set('x-kt-gateway-secret', 'wrong-secret')
|
.set('x-kt-gateway-secret', 'wrong-secret')
|
||||||
.send(createSessionInput())
|
.send(createSessionInput())
|
||||||
.expect(HttpStatus.UNAUTHORIZED);
|
.expect(HttpStatus.UNAUTHORIZED);
|
||||||
|
await request(app.getHttpServer())
|
||||||
|
.post('/internal/sessions/session-1/heartbeat')
|
||||||
|
.send({ adminUserId: 'admin-1' })
|
||||||
|
.expect(HttpStatus.UNAUTHORIZED);
|
||||||
|
await request(app.getHttpServer())
|
||||||
|
.post('/internal/sessions/session-1/heartbeat')
|
||||||
|
.set('x-kt-gateway-secret', 'wrong-secret')
|
||||||
|
.send({ adminUserId: 'admin-1' })
|
||||||
|
.expect(HttpStatus.UNAUTHORIZED);
|
||||||
|
await request(app.getHttpServer())
|
||||||
|
.post('/internal/sessions/session-1/revoke')
|
||||||
|
.send({ adminUserId: 'admin-1' })
|
||||||
|
.expect(HttpStatus.UNAUTHORIZED);
|
||||||
|
await request(app.getHttpServer())
|
||||||
|
.post('/internal/sessions/session-1/revoke')
|
||||||
|
.set('x-kt-gateway-secret', 'wrong-secret')
|
||||||
|
.send({ adminUserId: 'admin-1' })
|
||||||
|
.expect(HttpStatus.UNAUTHORIZED);
|
||||||
await request(app.getHttpServer())
|
await request(app.getHttpServer())
|
||||||
.get('/internal/health')
|
.get('/internal/health')
|
||||||
.expect(HttpStatus.OK);
|
.expect(HttpStatus.OK);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user