Remove share link (redundant to /pks/lookup)
This commit is contained in:
parent
e09454242d
commit
b29c8308a8
@ -74,12 +74,6 @@ GET /api/v1/key?fingerprint=e3317db04d3958fd5f662c37b8e4105cc9dedc77
|
||||
GET /api/v1/key?email=user@example.com
|
||||
```
|
||||
|
||||
#### By email address (shorthand link for sharing)
|
||||
|
||||
```
|
||||
GET /user/user@example.com
|
||||
```
|
||||
|
||||
#### Payload (JSON):
|
||||
|
||||
```json
|
||||
|
@ -65,9 +65,6 @@ router.get('/api/v1/removeKey', function *() {
|
||||
router.get('/api/v1/verifyRemove', function *() {
|
||||
yield rest.verifyRemove(this);
|
||||
});
|
||||
router.get('/user/:search', function *() {
|
||||
yield rest.share(this);
|
||||
});
|
||||
|
||||
// Redirect all http traffic to https
|
||||
app.use(function *(next) {
|
||||
|
@ -61,7 +61,7 @@ class REST {
|
||||
}
|
||||
yield this._publicKey.verify(q);
|
||||
// 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.set('Content-Type', 'text/html; charset=utf-8');
|
||||
}
|
||||
@ -78,25 +78,6 @@ class REST {
|
||||
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
|
||||
* @param {Object} ctx The koa request/response context
|
||||
|
@ -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', () => {
|
||||
beforeEach(done => {
|
||||
request(app.listen())
|
||||
|
Loading…
Reference in New Issue
Block a user