From 5fa36e6d522d6c7b0e9d3e7b8a44c1d41d9a2d69 Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Wed, 23 Aug 2017 18:19:59 +0800 Subject: [PATCH] Remove primaryEmail parameter from REST api. --- src/route/rest.js | 6 +++--- test/integration/app-test.js | 29 +++++------------------------ 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/src/route/rest.js b/src/route/rest.js index af386cf..d9447b7 100644 --- a/src/route/rest.js +++ b/src/route/rest.js @@ -37,12 +37,12 @@ class REST { * @param {Object} ctx The koa request/response context */ async create(ctx) { - const {publicKeyArmored, primaryEmail} = ctx.request.body; - if (!publicKeyArmored || (primaryEmail && !util.isEmail(primaryEmail))) { + const {publicKeyArmored} = ctx.request.body; + if (!publicKeyArmored) { ctx.throw(400, 'Invalid request!'); } const origin = util.origin(ctx); - await this._publicKey.put({publicKeyArmored, primaryEmail, origin}); + await this._publicKey.put({publicKeyArmored, origin}); ctx.body = 'Upload successful. Check your inbox to verify your email address.'; ctx.status = 201; } diff --git a/test/integration/app-test.js b/test/integration/app-test.js index 2edf598..63bd9ad 100644 --- a/test/integration/app-test.js +++ b/test/integration/app-test.js @@ -68,26 +68,7 @@ describe('Koa App (HTTP Server) Integration Tests', function() { .end(done); }); - it('should return 400 for an invalid primaryEmail', done => { - request(app.listen()) - .post('/api/v1/key') - .send({publicKeyArmored, primaryEmail: 'foo'}) - .expect(400) - .end(done); - }); - - it('should return 201 with primaryEmail', done => { - request(app.listen()) - .post('/api/v1/key') - .send({publicKeyArmored, primaryEmail}) - .expect(201) - .end(() => { - expect(emailParams).to.exist; - done(); - }); - }); - - it('should return 201 without primaryEmail', done => { + it('should return 201', done => { request(app.listen()) .post('/api/v1/key') .send({publicKeyArmored}) @@ -103,7 +84,7 @@ describe('Koa App (HTTP Server) Integration Tests', function() { beforeEach(done => { request(app.listen()) .post('/api/v1/key') - .send({publicKeyArmored, primaryEmail}) + .send({publicKeyArmored}) .expect(201) .end(done); }); @@ -134,7 +115,7 @@ describe('Koa App (HTTP Server) Integration Tests', function() { beforeEach(done => { request(app.listen()) .post('/api/v1/key') - .send({publicKeyArmored, primaryEmail}) + .send({publicKeyArmored}) .expect(201) .end(done); }); @@ -196,7 +177,7 @@ describe('Koa App (HTTP Server) Integration Tests', function() { beforeEach(done => { request(app.listen()) .post('/api/v1/key') - .send({publicKeyArmored, primaryEmail}) + .send({publicKeyArmored}) .expect(201) .end(done); }); @@ -234,7 +215,7 @@ describe('Koa App (HTTP Server) Integration Tests', function() { beforeEach(done => { request(app.listen()) .post('/api/v1/key') - .send({publicKeyArmored, primaryEmail}) + .send({publicKeyArmored}) .expect(201) .end(() => { request(app.listen())