From d6dfeb14f96bad982a2e5a071f8d16f12b067c25 Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Thu, 2 Jun 2016 23:32:23 +0200 Subject: [PATCH] Add support for vindex op --- src/route/hkp.js | 4 ++-- test/integration/app-test.js | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/route/hkp.js b/src/route/hkp.js index 9c74286..a1ea661 100644 --- a/src/route/hkp.js +++ b/src/route/hkp.js @@ -77,7 +77,7 @@ class HKP { params.email = ctx.query.search; } - if ((params.op !== 'get' && params.op !== 'index') || (params.op === 'index' && !params.mr)) { + if (['get','index','vindex'].indexOf(params.op) === -1) { ctx.throw(501, 'Not implemented!'); } else if (!params.keyid && !params.email) { ctx.throw(400, 'Invalid request!'); @@ -121,7 +121,7 @@ class HKP { setGetBody(ctx, params, key) { if (params.op === 'get') { ctx.body = key.publicKeyArmored; - } else if (params.op === 'index' && params.mr) { + } else if (['index','vindex'].indexOf(params.op) !== -1) { const VERSION = 1, COUNT = 1; // number of keys let algo = (key.algorithm.indexOf('rsa') !== -1) ? 1 : ''; let created = key.created ? (key.created.getTime() / 1000) : ''; diff --git a/test/integration/app-test.js b/test/integration/app-test.js index e6d8ce9..cf90495 100644 --- a/test/integration/app-test.js +++ b/test/integration/app-test.js @@ -405,6 +405,14 @@ describe('Koa App (HTTP Server) Integration Tests', function() { .end(done); }); + it('should return 200 for "vindex" op', done => { + request(app.listen()) + .get('/pks/lookup?op=vindex&search=0x' + emailParams.keyid) + .expect('Content-Type', 'text/plain; charset=utf-8') + .expect(200) + .end(done); + }); + it('should return 200 for "index" with "mr" option', done => { request(app.listen()) .get('/pks/lookup?op=index&options=mr&search=0x' + emailParams.keyid) @@ -448,9 +456,9 @@ describe('Koa App (HTTP Server) Integration Tests', function() { .end(done); }); - it('should return 501 (Not implemented) for "index" op', done => { + it('should return 501 (Not implemented) for "x-email" op', done => { request(app.listen()) - .get('/pks/lookup?op=index&search=0x' + emailParams.keyid) + .get('/pks/lookup?op=x-email&search=0x' + emailParams.keyid) .expect(501) .end(done); });