Add support for vindex op
This commit is contained in:
parent
41cbd55d9e
commit
d6dfeb14f9
@ -77,7 +77,7 @@ class HKP {
|
|||||||
params.email = ctx.query.search;
|
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!');
|
ctx.throw(501, 'Not implemented!');
|
||||||
} else if (!params.keyid && !params.email) {
|
} else if (!params.keyid && !params.email) {
|
||||||
ctx.throw(400, 'Invalid request!');
|
ctx.throw(400, 'Invalid request!');
|
||||||
@ -121,7 +121,7 @@ class HKP {
|
|||||||
setGetBody(ctx, params, key) {
|
setGetBody(ctx, params, key) {
|
||||||
if (params.op === 'get') {
|
if (params.op === 'get') {
|
||||||
ctx.body = key.publicKeyArmored;
|
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
|
const VERSION = 1, COUNT = 1; // number of keys
|
||||||
let algo = (key.algorithm.indexOf('rsa') !== -1) ? 1 : '';
|
let algo = (key.algorithm.indexOf('rsa') !== -1) ? 1 : '';
|
||||||
let created = key.created ? (key.created.getTime() / 1000) : '';
|
let created = key.created ? (key.created.getTime() / 1000) : '';
|
||||||
|
@ -405,6 +405,14 @@ describe('Koa App (HTTP Server) Integration Tests', function() {
|
|||||||
.end(done);
|
.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 => {
|
it('should return 200 for "index" with "mr" option', done => {
|
||||||
request(app.listen())
|
request(app.listen())
|
||||||
.get('/pks/lookup?op=index&options=mr&search=0x' + emailParams.keyid)
|
.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);
|
.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())
|
request(app.listen())
|
||||||
.get('/pks/lookup?op=index&search=0x' + emailParams.keyid)
|
.get('/pks/lookup?op=x-email&search=0x' + emailParams.keyid)
|
||||||
.expect(501)
|
.expect(501)
|
||||||
.end(done);
|
.end(done);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user