Remove primaryEmail parameter from REST api.
This commit is contained in:
parent
4c28da4eab
commit
5fa36e6d52
@ -37,12 +37,12 @@ class REST {
|
|||||||
* @param {Object} ctx The koa request/response context
|
* @param {Object} ctx The koa request/response context
|
||||||
*/
|
*/
|
||||||
async create(ctx) {
|
async create(ctx) {
|
||||||
const {publicKeyArmored, primaryEmail} = ctx.request.body;
|
const {publicKeyArmored} = ctx.request.body;
|
||||||
if (!publicKeyArmored || (primaryEmail && !util.isEmail(primaryEmail))) {
|
if (!publicKeyArmored) {
|
||||||
ctx.throw(400, 'Invalid request!');
|
ctx.throw(400, 'Invalid request!');
|
||||||
}
|
}
|
||||||
const origin = util.origin(ctx);
|
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.body = 'Upload successful. Check your inbox to verify your email address.';
|
||||||
ctx.status = 201;
|
ctx.status = 201;
|
||||||
}
|
}
|
||||||
|
@ -68,26 +68,7 @@ describe('Koa App (HTTP Server) Integration Tests', function() {
|
|||||||
.end(done);
|
.end(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return 400 for an invalid primaryEmail', done => {
|
it('should return 201', 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 => {
|
|
||||||
request(app.listen())
|
request(app.listen())
|
||||||
.post('/api/v1/key')
|
.post('/api/v1/key')
|
||||||
.send({publicKeyArmored})
|
.send({publicKeyArmored})
|
||||||
@ -103,7 +84,7 @@ describe('Koa App (HTTP Server) Integration Tests', function() {
|
|||||||
beforeEach(done => {
|
beforeEach(done => {
|
||||||
request(app.listen())
|
request(app.listen())
|
||||||
.post('/api/v1/key')
|
.post('/api/v1/key')
|
||||||
.send({publicKeyArmored, primaryEmail})
|
.send({publicKeyArmored})
|
||||||
.expect(201)
|
.expect(201)
|
||||||
.end(done);
|
.end(done);
|
||||||
});
|
});
|
||||||
@ -134,7 +115,7 @@ describe('Koa App (HTTP Server) Integration Tests', function() {
|
|||||||
beforeEach(done => {
|
beforeEach(done => {
|
||||||
request(app.listen())
|
request(app.listen())
|
||||||
.post('/api/v1/key')
|
.post('/api/v1/key')
|
||||||
.send({publicKeyArmored, primaryEmail})
|
.send({publicKeyArmored})
|
||||||
.expect(201)
|
.expect(201)
|
||||||
.end(done);
|
.end(done);
|
||||||
});
|
});
|
||||||
@ -196,7 +177,7 @@ describe('Koa App (HTTP Server) Integration Tests', function() {
|
|||||||
beforeEach(done => {
|
beforeEach(done => {
|
||||||
request(app.listen())
|
request(app.listen())
|
||||||
.post('/api/v1/key')
|
.post('/api/v1/key')
|
||||||
.send({publicKeyArmored, primaryEmail})
|
.send({publicKeyArmored})
|
||||||
.expect(201)
|
.expect(201)
|
||||||
.end(done);
|
.end(done);
|
||||||
});
|
});
|
||||||
@ -234,7 +215,7 @@ describe('Koa App (HTTP Server) Integration Tests', function() {
|
|||||||
beforeEach(done => {
|
beforeEach(done => {
|
||||||
request(app.listen())
|
request(app.listen())
|
||||||
.post('/api/v1/key')
|
.post('/api/v1/key')
|
||||||
.send({publicKeyArmored, primaryEmail})
|
.send({publicKeyArmored})
|
||||||
.expect(201)
|
.expect(201)
|
||||||
.end(() => {
|
.end(() => {
|
||||||
request(app.listen())
|
request(app.listen())
|
||||||
|
Loading…
Reference in New Issue
Block a user