Remove share link (redundant to /pks/lookup)

This commit is contained in:
Tankred Hase 2016-06-14 10:55:27 +02:00
parent e09454242d
commit b29c8308a8
4 changed files with 1 additions and 99 deletions

View File

@ -74,12 +74,6 @@ GET /api/v1/key?fingerprint=e3317db04d3958fd5f662c37b8e4105cc9dedc77
GET /api/v1/key?email=user@example.com GET /api/v1/key?email=user@example.com
``` ```
#### By email address (shorthand link for sharing)
```
GET /user/user@example.com
```
#### Payload (JSON): #### Payload (JSON):
```json ```json

View File

@ -65,9 +65,6 @@ router.get('/api/v1/removeKey', function *() {
router.get('/api/v1/verifyRemove', function *() { router.get('/api/v1/verifyRemove', function *() {
yield rest.verifyRemove(this); yield rest.verifyRemove(this);
}); });
router.get('/user/:search', function *() {
yield rest.share(this);
});
// Redirect all http traffic to https // Redirect all http traffic to https
app.use(function *(next) { app.use(function *(next) {

View File

@ -61,7 +61,7 @@ class REST {
} }
yield this._publicKey.verify(q); yield this._publicKey.verify(q);
// create link for sharing // create link for sharing
let link = util.url(util.origin(ctx), '/user/' + q.keyId.toUpperCase()); let link = util.url(util.origin(ctx), '/pks/lookup?op=get&search=0x' + q.keyId.toUpperCase());
ctx.body = `<p>Email address successfully verified!</p><p>Link to share your key: <a href="${link}" target="_blank">${link}</a></p>`; ctx.body = `<p>Email address successfully verified!</p><p>Link to share your key: <a href="${link}" target="_blank">${link}</a></p>`;
ctx.set('Content-Type', 'text/html; charset=utf-8'); ctx.set('Content-Type', 'text/html; charset=utf-8');
} }
@ -78,25 +78,6 @@ class REST {
ctx.body = yield this._publicKey.get(q); ctx.body = yield this._publicKey.get(q);
} }
/**
* Public key fetch via http GET (shorthand link for sharing)
* @param {Object} ctx The koa request/response context
*/
*share(ctx) {
let q, search = ctx.params.search;
if (util.isEmail(search)) {
q = { email:search };
} else if (util.isKeyId(search)) {
q = { keyId:search };
} else if (util.isFingerPrint(search)) {
q = { fingerprint:search };
}
if (!q) {
ctx.throw(400, 'Invalid request!');
}
ctx.body = (yield this._publicKey.get(q)).publicKeyArmored;
}
/** /**
* Request public key removal via http DELETE * Request public key removal via http DELETE
* @param {Object} ctx The koa request/response context * @param {Object} ctx The koa request/response context

View File

@ -190,76 +190,6 @@ describe('Koa App (HTTP Server) Integration Tests', function() {
}); });
}); });
describe('GET /user/:search (sharing link)', () => {
beforeEach(done => {
request(app.listen())
.post('/api/v1/key')
.send({ publicKeyArmored, primaryEmail })
.expect(201)
.end(done);
});
describe('Not yet verified', () => {
it('should return 404', done => {
request(app.listen())
.get('/user/' + primaryEmail)
.expect(404)
.end(done);
});
});
describe('Verified', () => {
beforeEach(done => {
request(app.listen())
.get('/api/v1/verify?keyId=' + emailParams.keyId + '&nonce=' + emailParams.nonce)
.expect(200)
.end(done);
});
it('should return 200 for email address', done => {
request(app.listen())
.get('/user/' + primaryEmail)
.expect(200, publicKeyArmored)
.end(done);
});
it('should return 200 for key id', done => {
request(app.listen())
.get('/user/' + emailParams.keyId)
.expect(200, publicKeyArmored)
.end(done);
});
it('should return 200 for fingerprint', done => {
request(app.listen())
.get('/user/' + fingerprint)
.expect(200, publicKeyArmored)
.end(done);
});
it('should return 400 for invalid email', done => {
request(app.listen())
.get('/user/a@bco')
.expect(400)
.end(done);
});
it('should return 404 for unkown email', done => {
request(app.listen())
.get('/user/a@b.co')
.expect(404)
.end(done);
});
it('should return 404 for missing email', done => {
request(app.listen())
.get('/user/')
.expect(404)
.end(done);
});
});
});
describe('DELETE /api/v1/key', () => { describe('DELETE /api/v1/key', () => {
beforeEach(done => { beforeEach(done => {
request(app.listen()) request(app.listen())